| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/cocoa/bug_report_window_controller.h" | 5 #import "chrome/browser/cocoa/bug_report_window_controller.h" |
| 6 | 6 |
| 7 #include "app/l10n_util_mac.h" | 7 #include "app/l10n_util_mac.h" |
| 8 #include "base/mac_util.h" | 8 #include "base/mac_util.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "chrome/browser/bug_report_util.h" | 10 #include "chrome/browser/bug_report_util.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 @synthesize disableScreenshot = disableScreenshot_; | 26 @synthesize disableScreenshot = disableScreenshot_; |
| 27 @synthesize bugTypeList = bugTypeList_; | 27 @synthesize bugTypeList = bugTypeList_; |
| 28 | 28 |
| 29 - (id)initWithTabContents:(TabContents*)currentTab | 29 - (id)initWithTabContents:(TabContents*)currentTab |
| 30 profile:(Profile*)profile { | 30 profile:(Profile*)profile { |
| 31 NSString* nibpath = [mac_util::MainAppBundle() pathForResource:@"ReportBug" | 31 NSString* nibpath = [mac_util::MainAppBundle() pathForResource:@"ReportBug" |
| 32 ofType:@"nib"]; | 32 ofType:@"nib"]; |
| 33 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { | 33 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { |
| 34 currentTab_ = currentTab; | 34 currentTab_ = currentTab; |
| 35 profile_ = profile; | 35 profile_ = profile; |
| 36 [self setBugDescription:@""]; | |
| 37 | 36 |
| 38 if (currentTab_ != NULL) { | 37 if (currentTab_ != NULL) { |
| 39 // Get data from current tab, if one exists. This dialog could be called | 38 // Get data from current tab, if one exists. This dialog could be called |
| 40 // from the main menu with no tab contents, so currentTab_ is not | 39 // from the main menu with no tab contents, so currentTab_ is not |
| 41 // guaranteed to be non-NULL. | 40 // guaranteed to be non-NULL. |
| 42 // TODO(mirandac): This dialog should be a tab-modal sheet if a browser | 41 // TODO(mirandac): This dialog should be a tab-modal sheet if a browser |
| 43 // window exists. | 42 // window exists. |
| 44 [self setSendScreenshot:YES]; | 43 [self setSendScreenshot:YES]; |
| 45 [self setDisableScreenshot:NO]; | 44 [self setDisableScreenshot:NO]; |
| 46 bugTypeList_ = [[NSArray alloc] initWithObjects: | 45 bugTypeList_ = [[NSArray alloc] initWithObjects: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 62 // If no current tab exists, create a menu without the "broken page" | 61 // If no current tab exists, create a menu without the "broken page" |
| 63 // options, with page URL and title empty, and screenshot disabled. | 62 // options, with page URL and title empty, and screenshot disabled. |
| 64 [self setSendScreenshot:NO]; | 63 [self setSendScreenshot:NO]; |
| 65 [self setDisableScreenshot:YES]; | 64 [self setDisableScreenshot:YES]; |
| 66 bugTypeList_ = [[NSArray alloc] initWithObjects: | 65 bugTypeList_ = [[NSArray alloc] initWithObjects: |
| 67 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_CHROME_MISBEHAVES), | 66 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_CHROME_MISBEHAVES), |
| 68 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_SOMETHING_MISSING), | 67 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_SOMETHING_MISSING), |
| 69 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_BROWSER_CRASH), | 68 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_BROWSER_CRASH), |
| 70 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_OTHER_PROBLEM), | 69 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_OTHER_PROBLEM), |
| 71 nil]; | 70 nil]; |
| 72 // Because "Report Bug" is being called with no browser open in this | |
| 73 // case, make URL and title empty. | |
| 74 [self setPageURL:@""]; | |
| 75 [self setPageTitle:@""]; | |
| 76 } | 71 } |
| 77 } | 72 } |
| 78 return self; | 73 return self; |
| 79 } | 74 } |
| 80 | 75 |
| 81 - (void)dealloc { | 76 - (void)dealloc { |
| 82 [pageURL_ release]; | 77 [pageURL_ release]; |
| 83 [pageTitle_ release]; | 78 [pageTitle_ release]; |
| 84 [bugDescription_ release]; | 79 [bugDescription_ release]; |
| 85 [bugTypeList_ release]; | 80 [bugTypeList_ release]; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 102 [NSApp runModalForWindow:bugReportWindow]; | 97 [NSApp runModalForWindow:bugReportWindow]; |
| 103 } | 98 } |
| 104 | 99 |
| 105 - (IBAction)sendReport:(id)sender { | 100 - (IBAction)sendReport:(id)sender { |
| 106 if ([self isPhishingReport]) { | 101 if ([self isPhishingReport]) { |
| 107 BugReportUtil::ReportPhishing(currentTab_, | 102 BugReportUtil::ReportPhishing(currentTab_, |
| 108 pageURL_ ? base::SysNSStringToUTF8(pageURL_) : ""); | 103 pageURL_ ? base::SysNSStringToUTF8(pageURL_) : ""); |
| 109 } else { | 104 } else { |
| 110 BugReportUtil::SendReport( | 105 BugReportUtil::SendReport( |
| 111 profile_, | 106 profile_, |
| 112 pageTitle_ ? base::SysNSStringToUTF8(pageTitle_) : "", | 107 base::SysNSStringToUTF8(pageTitle_), |
| 113 bugType_, | 108 bugType_, |
| 114 pageURL_ ? base::SysNSStringToUTF8(pageURL_) : "", | 109 base::SysNSStringToUTF8(pageURL_), |
| 115 bugDescription_ ? base::SysNSStringToUTF8(bugDescription_) : "", | 110 base::SysNSStringToUTF8(bugDescription_), |
| 116 sendScreenshot_ && !pngData_.empty() ? | 111 sendScreenshot_ && !pngData_.empty() ? |
| 117 reinterpret_cast<const char *>(&(pngData_[0])) : NULL, | 112 reinterpret_cast<const char *>(&(pngData_[0])) : NULL, |
| 118 pngData_.size()); | 113 pngData_.size()); |
| 119 } | 114 } |
| 120 [self closeDialog]; | 115 [self closeDialog]; |
| 121 } | 116 } |
| 122 | 117 |
| 123 - (IBAction)cancel:(id)sender { | 118 - (IBAction)cancel:(id)sender { |
| 124 [self closeDialog]; | 119 [self closeDialog]; |
| 125 } | 120 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 NSSet* paths = [super keyPathsForValuesAffectingValueForKey:key]; | 158 NSSet* paths = [super keyPathsForValuesAffectingValueForKey:key]; |
| 164 if ([key isEqualToString:@"isPhishingReport"]) { | 159 if ([key isEqualToString:@"isPhishingReport"]) { |
| 165 paths = [paths setByAddingObject:@"bugType"]; | 160 paths = [paths setByAddingObject:@"bugType"]; |
| 166 } | 161 } |
| 167 return paths; | 162 return paths; |
| 168 } | 163 } |
| 169 | 164 |
| 170 @end | 165 @end |
| 171 | 166 |
| 172 | 167 |
| OLD | NEW |