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