| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 - (IBAction)cancel:(id)sender { | 123 - (IBAction)cancel:(id)sender { |
| 124 [self closeDialog]; | 124 [self closeDialog]; |
| 125 } | 125 } |
| 126 | 126 |
| 127 - (BOOL)isPhishingReport { | 127 - (BOOL)isPhishingReport { |
| 128 return bugType_ == [bugTypeList_ indexOfObject: | 128 return bugType_ == [bugTypeList_ indexOfObject: |
| 129 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_PHISHING_PAGE)]; | 129 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_PHISHING_PAGE)]; |
| 130 } | 130 } |
| 131 | 131 |
| 132 - (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item { | 132 - (void)menu:(NSMenu*)menu willHighlightItem:(NSMenuItem *)item { |
| 133 NSString* buttonTitle = [[item title] isEqualToString: | 133 NSString* buttonTitle = [[item title] isEqualToString: |
| 134 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_PHISHING_PAGE)] ? | 134 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_PHISHING_PAGE)] ? |
| 135 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_SEND_PHISHING_REPORT) : | 135 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_SEND_PHISHING_REPORT) : |
| 136 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_SEND_REPORT); | 136 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_SEND_REPORT); |
| 137 if (![buttonTitle isEqualToString:[sendReportButton_ title]]) { | 137 if (![buttonTitle isEqualToString:[sendReportButton_ title]]) { |
| 138 [sendReportButton_ setTitle:buttonTitle]; | 138 [sendReportButton_ setTitle:buttonTitle]; |
| 139 CGFloat deltaWidth = | 139 CGFloat deltaWidth = |
| 140 [GTMUILocalizerAndLayoutTweaker sizeToFitView:sendReportButton_].width; | 140 [GTMUILocalizerAndLayoutTweaker sizeToFitView:sendReportButton_].width; |
| 141 NSRect newSendButtonFrame = [sendReportButton_ frame]; | 141 NSRect newSendButtonFrame = [sendReportButton_ frame]; |
| 142 newSendButtonFrame.origin.x -= deltaWidth; | 142 newSendButtonFrame.origin.x -= deltaWidth; |
| 143 NSRect newCancelButtonFrame = [cancelButton_ frame]; | 143 NSRect newCancelButtonFrame = [cancelButton_ frame]; |
| 144 newCancelButtonFrame.origin.x -= deltaWidth; | 144 newCancelButtonFrame.origin.x -= deltaWidth; |
| 145 [sendReportButton_ setFrame:newSendButtonFrame]; | 145 [sendReportButton_ setFrame:newSendButtonFrame]; |
| 146 [cancelButton_ setFrame:newCancelButtonFrame]; | 146 [cancelButton_ setFrame:newCancelButtonFrame]; |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 | 149 |
| 150 - (BOOL)control:(NSControl*)control textView:(NSTextView*)textView |
| 151 doCommandBySelector:(SEL)commandSelector { |
| 152 if (commandSelector == @selector(insertNewline:)) { |
| 153 [textView insertNewlineIgnoringFieldEditor:self]; |
| 154 return YES; |
| 155 } |
| 156 return NO; |
| 157 } |
| 158 |
| 150 // BugReportWindowController needs to change the title of the Send Report | 159 // BugReportWindowController needs to change the title of the Send Report |
| 151 // button when the user chooses the phishing bug type, so we need to bind | 160 // button when the user chooses the phishing bug type, so we need to bind |
| 152 // the function that changes the button title to the bug type key. | 161 // the function that changes the button title to the bug type key. |
| 153 + (NSSet*)keyPathsForValuesAffectingValueForKey:(NSString*)key { | 162 + (NSSet*)keyPathsForValuesAffectingValueForKey:(NSString*)key { |
| 154 NSSet* paths = [super keyPathsForValuesAffectingValueForKey:key]; | 163 NSSet* paths = [super keyPathsForValuesAffectingValueForKey:key]; |
| 155 if ([key isEqualToString:@"isPhishingReport"]) { | 164 if ([key isEqualToString:@"isPhishingReport"]) { |
| 156 paths = [paths setByAddingObject:@"bugType"]; | 165 paths = [paths setByAddingObject:@"bugType"]; |
| 157 } | 166 } |
| 158 return paths; | 167 return paths; |
| 159 } | 168 } |
| 160 | 169 |
| 161 @end | 170 @end |
| 162 | 171 |
| 163 | 172 |
| OLD | NEW |