OLD | NEW |
1 // Copyright (c) 2011 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/wrench_menu/wrench_menu_controller.h" | 5 #import "chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.h" |
6 | 6 |
7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
9 #import "chrome/browser/app_controller_mac.h" | 9 #import "chrome/browser/app_controller_mac.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
12 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" | 12 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" |
13 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 13 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
14 #import "chrome/browser/ui/cocoa/wrench_menu/menu_tracked_root_view.h" | 14 #import "chrome/browser/ui/cocoa/wrench_menu/menu_tracked_root_view.h" |
15 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 15 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
16 #include "content/browser/user_metrics.h" | 16 #include "content/browser/user_metrics.h" |
| 17 #include "content/common/content_notification_types.h" |
17 #include "content/common/notification_observer.h" | 18 #include "content/common/notification_observer.h" |
18 #include "content/common/notification_service.h" | 19 #include "content/common/notification_service.h" |
19 #include "content/common/notification_source.h" | 20 #include "content/common/notification_source.h" |
20 #include "content/common/notification_type.h" | |
21 #include "grit/chromium_strings.h" | 21 #include "grit/chromium_strings.h" |
22 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
24 #include "ui/base/models/menu_model.h" | 24 #include "ui/base/models/menu_model.h" |
25 | 25 |
26 @interface WrenchMenuController (Private) | 26 @interface WrenchMenuController (Private) |
27 - (void)adjustPositioning; | 27 - (void)adjustPositioning; |
28 - (void)performCommandDispatch:(NSNumber*)tag; | 28 - (void)performCommandDispatch:(NSNumber*)tag; |
29 - (NSButton*)zoomDisplay; | 29 - (NSButton*)zoomDisplay; |
30 @end | 30 @end |
31 | 31 |
32 namespace WrenchMenuControllerInternal { | 32 namespace WrenchMenuControllerInternal { |
33 | 33 |
34 class ZoomLevelObserver : public NotificationObserver { | 34 class ZoomLevelObserver : public NotificationObserver { |
35 public: | 35 public: |
36 explicit ZoomLevelObserver(WrenchMenuController* controller) | 36 explicit ZoomLevelObserver(WrenchMenuController* controller) |
37 : controller_(controller) { | 37 : controller_(controller) { |
38 registrar_.Add(this, NotificationType::ZOOM_LEVEL_CHANGED, | 38 registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED, |
39 NotificationService::AllSources()); | 39 NotificationService::AllSources()); |
40 } | 40 } |
41 | 41 |
42 void Observe(NotificationType type, | 42 void Observe(int type, |
43 const NotificationSource& source, | 43 const NotificationSource& source, |
44 const NotificationDetails& details) { | 44 const NotificationDetails& details) { |
45 DCHECK_EQ(type.value, NotificationType::ZOOM_LEVEL_CHANGED); | 45 DCHECK_EQ(type, content::NOTIFICATION_ZOOM_LEVEL_CHANGED); |
46 WrenchMenuModel* wrenchMenuModel = [controller_ wrenchMenuModel]; | 46 WrenchMenuModel* wrenchMenuModel = [controller_ wrenchMenuModel]; |
47 wrenchMenuModel->UpdateZoomControls(); | 47 wrenchMenuModel->UpdateZoomControls(); |
48 const string16 level = | 48 const string16 level = |
49 wrenchMenuModel->GetLabelForCommandId(IDC_ZOOM_PERCENT_DISPLAY); | 49 wrenchMenuModel->GetLabelForCommandId(IDC_ZOOM_PERCENT_DISPLAY); |
50 [[controller_ zoomDisplay] setTitle:SysUTF16ToNSString(level)]; | 50 [[controller_ zoomDisplay] setTitle:SysUTF16ToNSString(level)]; |
51 } | 51 } |
52 | 52 |
53 private: | 53 private: |
54 NotificationRegistrar registrar_; | 54 NotificationRegistrar registrar_; |
55 WrenchMenuController* controller_; // Weak; owns this. | 55 WrenchMenuController* controller_; // Weak; owns this. |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 parentFrame.size.width += delta; | 224 parentFrame.size.width += delta; |
225 parentFrame.origin.x -= delta; | 225 parentFrame.origin.x -= delta; |
226 [[editCut_ superview] setFrame:parentFrame]; | 226 [[editCut_ superview] setFrame:parentFrame]; |
227 } | 227 } |
228 | 228 |
229 - (NSButton*)zoomDisplay { | 229 - (NSButton*)zoomDisplay { |
230 return zoomDisplay_; | 230 return zoomDisplay_; |
231 } | 231 } |
232 | 232 |
233 @end // @implementation WrenchMenuController | 233 @end // @implementation WrenchMenuController |
OLD | NEW |