/ src / client / mac / sender / crash_report_sender.h
crash_report_sender.h
  1  // Copyright 2006 Google LLC
  2  //
  3  // Redistribution and use in source and binary forms, with or without
  4  // modification, are permitted provided that the following conditions are
  5  // met:
  6  //
  7  //     * Redistributions of source code must retain the above copyright
  8  // notice, this list of conditions and the following disclaimer.
  9  //     * Redistributions in binary form must reproduce the above
 10  // copyright notice, this list of conditions and the following disclaimer
 11  // in the documentation and/or other materials provided with the
 12  // distribution.
 13  //     * Neither the name of Google LLC nor the names of its
 14  // contributors may be used to endorse or promote products derived from
 15  // this software without specific prior written permission.
 16  //
 17  // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 18  // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 19  // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 20  // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 21  // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 22  // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 23  // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 24  // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 25  // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 26  // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 27  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 28  //
 29  // This component uses the HTTPMultipartUpload of the breakpad project to send
 30  // the minidump and associated data to the crash reporting servers.
 31  // It will perform throttling based on the parameters passed to it and will
 32  // prompt the user to send the minidump.
 33  
 34  #import <Cocoa/Cocoa.h>
 35  
 36  #include "client/mac/sender/uploader.h"
 37  #import "GTMDefines.h"
 38  
 39  // We're sublcassing NSTextField in order to override a particular
 40  // method (see the implementation) that lets us reject changes if they
 41  // are longer than a particular length.  Bindings would normally solve
 42  // this problem, but when we implemented a validation method, and
 43  // returned NO for strings that were too long, the UI was not updated
 44  // right away, which was a poor user experience.  The UI would be
 45  // updated as soon as the text field lost first responder status,
 46  // which isn't soon enough.  It is a known bug that the UI KVO didn't
 47  // work in the middle of a validation.
 48  @interface LengthLimitingTextField : NSTextField {
 49    @private
 50     NSUInteger maximumLength_;
 51  }
 52  
 53  - (void)setMaximumLength:(NSUInteger)maxLength;
 54  @end
 55  
 56  @interface Reporter : NSObject {
 57   @public
 58    IBOutlet NSWindow *alertWindow_;        // The alert window
 59  
 60    // Grouping boxes used for resizing.
 61    IBOutlet NSBox *headerBox_;
 62    IBOutlet NSBox *preEmailBox_;
 63    IBOutlet NSBox *emailSectionBox_;
 64    // Localized elements (or things that need to be moved during localization).
 65    IBOutlet NSTextField                *dialogTitle_;
 66    IBOutlet NSTextField                *commentMessage_;
 67    IBOutlet NSTextField                *emailMessage_;
 68    IBOutlet NSTextField                *emailLabel_;
 69    IBOutlet NSTextField                *privacyLinkLabel_;
 70    IBOutlet NSButton                   *sendButton_;
 71    IBOutlet NSButton                   *cancelButton_;
 72    IBOutlet LengthLimitingTextField    *emailEntryField_;
 73    IBOutlet LengthLimitingTextField    *commentsEntryField_;
 74    IBOutlet NSTextField                *countdownLabel_;
 75    IBOutlet NSView                     *privacyLinkArrow_;
 76  
 77    // Text field bindings, for user input.
 78    NSString *commentsValue_;                // Comments from the user
 79    NSString *emailValue_;                   // Email from the user
 80    NSString *countdownMessage_;             // Message indicating time
 81                                             // left for input.
 82   @private
 83    NSTimeInterval remainingDialogTime_;     // Keeps track of how long
 84                                             // we have until we cancel
 85                                             // the dialog
 86    NSTimer *messageTimer_;                  // Timer we use to update
 87                                             // the dialog
 88    Uploader* uploader_;                     // Uploader we use to send the data.
 89  }
 90  
 91  // Stops the modal panel with an NSAlertDefaultReturn value. This is the action
 92  // invoked by the "Send Report" button.
 93  - (IBAction)sendReport:(id)sender;
 94  // Stops the modal panel with an NSAlertAlternateReturn value. This is the
 95  // action invoked by the "Cancel" button.
 96  - (IBAction)cancel:(id)sender;
 97  // Opens the Privacy Policy url in the default web browser.
 98  - (IBAction)showPrivacyPolicy:(id)sender;
 99  
100  // Delegate methods for the NSTextField for comments. We want to capture the
101  // Return key and use it to send the message when no text has been entered.
102  // Otherwise, we want Return to add a carriage return to the comments field.
103  - (BOOL)control:(NSControl *)control textView:(NSTextView *)textView
104                            doCommandBySelector:(SEL)commandSelector;
105  
106  // Accessors to make bindings work
107  - (NSString *)commentsValue;
108  - (void)setCommentsValue:(NSString *)value;
109  
110  - (NSString *)emailValue;
111  - (void)setEmailValue:(NSString *)value;
112  
113  - (NSString *)countdownMessage;
114  - (void)setCountdownMessage:(NSString *)value;
115  
116  @end