OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_controller.h" | 5 #import "chrome/browser/ui/cocoa/wrench_menu_controller.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/menus/menu_model.h" | 8 #include "app/menus/menu_model.h" |
9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| 11 #include "chrome/browser/background_page_tracker.h" |
11 #import "chrome/browser/ui/cocoa/menu_tracked_root_view.h" | 12 #import "chrome/browser/ui/cocoa/menu_tracked_root_view.h" |
12 #import "chrome/browser/ui/cocoa/toolbar_controller.h" | 13 #import "chrome/browser/ui/cocoa/toolbar_controller.h" |
13 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
15 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 16 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
16 #include "chrome/common/notification_observer.h" | 17 #include "chrome/common/notification_observer.h" |
17 #include "chrome/common/notification_service.h" | 18 #include "chrome/common/notification_service.h" |
18 #include "chrome/common/notification_source.h" | 19 #include "chrome/common/notification_source.h" |
19 #include "chrome/common/notification_type.h" | 20 #include "chrome/common/notification_type.h" |
20 #include "grit/chromium_strings.h" | 21 #include "grit/chromium_strings.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 NSString* title = base::SysUTF16ToNSString( | 115 NSString* title = base::SysUTF16ToNSString( |
115 [self wrenchMenuModel]->GetLabelForCommandId(IDC_ZOOM_PERCENT_DISPLAY)); | 116 [self wrenchMenuModel]->GetLabelForCommandId(IDC_ZOOM_PERCENT_DISPLAY)); |
116 [[zoomItem_ viewWithTag:IDC_ZOOM_PERCENT_DISPLAY] setTitle:title]; | 117 [[zoomItem_ viewWithTag:IDC_ZOOM_PERCENT_DISPLAY] setTitle:title]; |
117 | 118 |
118 NSImage* icon = [self wrenchMenuModel]->browser()->window()->IsFullscreen() ? | 119 NSImage* icon = [self wrenchMenuModel]->browser()->window()->IsFullscreen() ? |
119 [NSImage imageNamed:NSImageNameExitFullScreenTemplate] : | 120 [NSImage imageNamed:NSImageNameExitFullScreenTemplate] : |
120 [NSImage imageNamed:NSImageNameEnterFullScreenTemplate]; | 121 [NSImage imageNamed:NSImageNameEnterFullScreenTemplate]; |
121 [zoomFullScreen_ setImage:icon]; | 122 [zoomFullScreen_ setImage:icon]; |
122 } | 123 } |
123 | 124 |
| 125 - (void)menuDidClose:(NSMenu*)menu { |
| 126 // When the menu is closed, acknowledge the background pages so the badges go |
| 127 // away. |
| 128 BackgroundPageTracker::GetInstance()->AcknowledgeBackgroundPages(); |
| 129 } |
| 130 |
124 // Used to dispatch commands from the Wrench menu. The custom items within the | 131 // Used to dispatch commands from the Wrench menu. The custom items within the |
125 // menu cannot be hooked up directly to First Responder because the window in | 132 // menu cannot be hooked up directly to First Responder because the window in |
126 // which the controls reside is not the BrowserWindowController, but a | 133 // which the controls reside is not the BrowserWindowController, but a |
127 // NSCarbonMenuWindow; this screws up the typical |-commandDispatch:| system. | 134 // NSCarbonMenuWindow; this screws up the typical |-commandDispatch:| system. |
128 - (IBAction)dispatchWrenchMenuCommand:(id)sender { | 135 - (IBAction)dispatchWrenchMenuCommand:(id)sender { |
129 NSInteger tag = [sender tag]; | 136 NSInteger tag = [sender tag]; |
130 if (sender == zoomPlus_ || sender == zoomMinus_) { | 137 if (sender == zoomPlus_ || sender == zoomMinus_) { |
131 // Do a direct dispatch rather than scheduling on the outermost run loop, | 138 // Do a direct dispatch rather than scheduling on the outermost run loop, |
132 // which would not get hit until after the menu had closed. | 139 // which would not get hit until after the menu had closed. |
133 [self performCommandDispatch:[NSNumber numberWithInt:tag]]; | 140 [self performCommandDispatch:[NSNumber numberWithInt:tag]]; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 parentFrame.size.width += delta; | 211 parentFrame.size.width += delta; |
205 parentFrame.origin.x -= delta; | 212 parentFrame.origin.x -= delta; |
206 [[editCut_ superview] setFrame:parentFrame]; | 213 [[editCut_ superview] setFrame:parentFrame]; |
207 } | 214 } |
208 | 215 |
209 - (NSButton*)zoomDisplay { | 216 - (NSButton*)zoomDisplay { |
210 return zoomDisplay_; | 217 return zoomDisplay_; |
211 } | 218 } |
212 | 219 |
213 @end // @implementation WrenchMenuController | 220 @end // @implementation WrenchMenuController |
OLD | NEW |