OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/cocoa/bug_report_window_controller.h" | 5 #import "chrome/browser/ui/cocoa/bug_report_window_controller.h" |
6 | 6 |
7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "chrome/browser/bug_report_util.h" | 9 #include "chrome/browser/bug_report_util.h" |
10 #include "chrome/browser/tab_contents/tab_contents.h" | 10 #include "chrome/browser/tab_contents/tab_contents.h" |
11 #include "chrome/browser/tab_contents/tab_contents_view.h" | 11 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 12 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" |
12 #include "grit/chromium_strings.h" | 13 #include "grit/chromium_strings.h" |
13 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
14 #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" | 15 #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" |
15 #include "ui/base/l10n/l10n_util_mac.h" | 16 #include "ui/base/l10n/l10n_util_mac.h" |
16 | 17 |
17 @implementation BugReportWindowController | 18 @implementation BugReportWindowController |
18 | 19 |
19 @synthesize bugDescription = bugDescription_; | 20 @synthesize bugDescription = bugDescription_; |
20 @synthesize bugTypeIndex = bugTypeIndex_; | 21 @synthesize bugTypeIndex = bugTypeIndex_; |
21 @synthesize pageURL = pageURL_; | 22 @synthesize pageURL = pageURL_; |
(...skipping 12 matching lines...) Expand all Loading... |
34 | 35 |
35 // The order of strings in this array must match the order of the bug types | 36 // The order of strings in this array must match the order of the bug types |
36 // declared below in the bugTypeFromIndex function. | 37 // declared below in the bugTypeFromIndex function. |
37 bugTypeList_ = [[NSMutableArray alloc] initWithObjects: | 38 bugTypeList_ = [[NSMutableArray alloc] initWithObjects: |
38 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_CHROME_MISBEHAVES), | 39 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_CHROME_MISBEHAVES), |
39 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_SOMETHING_MISSING), | 40 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_SOMETHING_MISSING), |
40 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_BROWSER_CRASH), | 41 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_BROWSER_CRASH), |
41 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_OTHER_PROBLEM), | 42 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_OTHER_PROBLEM), |
42 nil]; | 43 nil]; |
43 | 44 |
| 45 pngHeight_ = 0; |
| 46 pngWidth_ = 0; |
| 47 |
44 if (currentTab_ != NULL) { | 48 if (currentTab_ != NULL) { |
45 // Get data from current tab, if one exists. This dialog could be called | 49 // Get data from current tab, if one exists. This dialog could be called |
46 // from the main menu with no tab contents, so currentTab_ is not | 50 // from the main menu with no tab contents, so currentTab_ is not |
47 // guaranteed to be non-NULL. | 51 // guaranteed to be non-NULL. |
48 // TODO(mirandac): This dialog should be a tab-modal sheet if a browser | 52 // TODO(mirandac): This dialog should be a tab-modal sheet if a browser |
49 // window exists. | 53 // window exists. |
50 [self setSendScreenshot:YES]; | 54 [self setSendScreenshot:YES]; |
51 [self setDisableScreenshotCheckbox:NO]; | 55 [self setDisableScreenshotCheckbox:NO]; |
52 // Insert menu items about bugs related to specific pages. | 56 // Insert menu items about bugs related to specific pages. |
53 [bugTypeList_ insertObjects: | 57 [bugTypeList_ insertObjects: |
54 [NSArray arrayWithObjects: | 58 [NSArray arrayWithObjects: |
55 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_PAGE_WONT_LOAD), | 59 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_PAGE_WONT_LOAD), |
56 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_PAGE_LOOKS_ODD), | 60 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_PAGE_LOOKS_ODD), |
57 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_PHISHING_PAGE), | 61 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_PHISHING_PAGE), |
58 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_CANT_SIGN_IN), | 62 l10n_util::GetNSStringWithFixup(IDS_BUGREPORT_CANT_SIGN_IN), |
59 nil] | 63 nil] |
60 atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 4)]]; | 64 atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 4)]]; |
61 | 65 |
62 [self setPageURL:base::SysUTF8ToNSString( | 66 [self setPageURL:base::SysUTF8ToNSString( |
63 currentTab_->controller().GetActiveEntry()->url().spec())]; | 67 currentTab_->controller().GetActiveEntry()->url().spec())]; |
64 [self setPageTitle:base::SysUTF16ToNSString(currentTab_->GetTitle())]; | 68 [self setPageTitle:base::SysUTF16ToNSString(currentTab_->GetTitle())]; |
65 base::mac::GrabWindowSnapshot( | 69 gfx::Rect pngRect = browser::GrabWindowSnapshot( |
66 currentTab_->view()->GetTopLevelNativeWindow(), &pngData_, | 70 currentTab_->view()->GetTopLevelNativeWindow(), &pngData_); |
67 &pngWidth_, &pngHeight_); | 71 pngWidth_ = pngRect.width(); |
| 72 pngHeight_ = pngRect.height(); |
68 } else { | 73 } else { |
69 // If no current tab exists, create a menu without the "broken page" | 74 // If no current tab exists, create a menu without the "broken page" |
70 // options, with page URL and title empty, and screenshot disabled. | 75 // options, with page URL and title empty, and screenshot disabled. |
71 [self setSendScreenshot:NO]; | 76 [self setSendScreenshot:NO]; |
72 [self setDisableScreenshotCheckbox:YES]; | 77 [self setDisableScreenshotCheckbox:YES]; |
73 } | 78 } |
74 | |
75 pngHeight_ = 0; | |
76 pngWidth_ = 0; | |
77 } | 79 } |
78 return self; | 80 return self; |
79 } | 81 } |
80 | 82 |
81 - (void)dealloc { | 83 - (void)dealloc { |
82 [pageURL_ release]; | 84 [pageURL_ release]; |
83 [pageTitle_ release]; | 85 [pageTitle_ release]; |
84 [bugDescription_ release]; | 86 [bugDescription_ release]; |
85 [bugTypeList_ release]; | 87 [bugTypeList_ release]; |
86 [bugTypeDictionary_ release]; | 88 [bugTypeDictionary_ release]; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 + (NSSet*)keyPathsForValuesAffectingValueForKey:(NSString*)key { | 223 + (NSSet*)keyPathsForValuesAffectingValueForKey:(NSString*)key { |
222 NSSet* paths = [super keyPathsForValuesAffectingValueForKey:key]; | 224 NSSet* paths = [super keyPathsForValuesAffectingValueForKey:key]; |
223 if ([key isEqualToString:@"isPhishingReport"]) { | 225 if ([key isEqualToString:@"isPhishingReport"]) { |
224 paths = [paths setByAddingObject:@"bugTypeIndex"]; | 226 paths = [paths setByAddingObject:@"bugTypeIndex"]; |
225 } | 227 } |
226 return paths; | 228 return paths; |
227 } | 229 } |
228 | 230 |
229 @end | 231 @end |
230 | 232 |
OLD | NEW |