OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/browser_actions_controller.h" | 5 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 virtual void ToolbarExtensionMoved(const Extension* extension, | 235 virtual void ToolbarExtensionMoved(const Extension* extension, |
236 int index) OVERRIDE { | 236 int index) OVERRIDE { |
237 } | 237 } |
238 | 238 |
239 virtual void ToolbarExtensionUpdated(const Extension* extension) OVERRIDE { | 239 virtual void ToolbarExtensionUpdated(const Extension* extension) OVERRIDE { |
240 BrowserActionButton* button = [owner_ buttonForExtension:extension]; | 240 BrowserActionButton* button = [owner_ buttonForExtension:extension]; |
241 if (button) | 241 if (button) |
242 [button updateState]; | 242 [button updateState]; |
243 } | 243 } |
244 | 244 |
245 virtual bool ShowExtensionActionPopup(const Extension* extension) OVERRIDE { | 245 virtual bool ShowExtensionActionPopup(const Extension* extension, |
| 246 bool grant_active_tab) OVERRIDE { |
246 // Do not override other popups and only show in active window. | 247 // Do not override other popups and only show in active window. |
247 ExtensionPopupController* popup = [ExtensionPopupController popup]; | 248 ExtensionPopupController* popup = [ExtensionPopupController popup]; |
248 if (popup || !browser_->window()->IsActive()) | 249 if (popup || !browser_->window()->IsActive()) |
249 return false; | 250 return false; |
250 | 251 |
251 BrowserActionButton* button = [owner_ buttonForExtension:extension]; | 252 BrowserActionButton* button = [owner_ buttonForExtension:extension]; |
252 return button && [owner_ browserActionClicked:button | 253 return button && [owner_ browserActionClicked:button |
253 shouldGrant:NO]; | 254 shouldGrant:grant_active_tab]; |
254 } | 255 } |
255 | 256 |
256 virtual void ToolbarVisibleCountChanged() OVERRIDE { | 257 virtual void ToolbarVisibleCountChanged() OVERRIDE { |
257 } | 258 } |
258 | 259 |
259 virtual void ToolbarHighlightModeChanged(bool is_highlighting) OVERRIDE { | 260 virtual void ToolbarHighlightModeChanged(bool is_highlighting) OVERRIDE { |
260 } | 261 } |
261 | 262 |
| 263 virtual Browser* GetBrowser() OVERRIDE { |
| 264 return browser_; |
| 265 } |
| 266 |
262 private: | 267 private: |
263 // The object we need to inform when we get a notification. Weak. Owns us. | 268 // The object we need to inform when we get a notification. Weak. Owns us. |
264 BrowserActionsController* owner_; | 269 BrowserActionsController* owner_; |
265 | 270 |
266 // The browser we listen for events from. Weak. | 271 // The browser we listen for events from. Weak. |
267 Browser* browser_; | 272 Browser* browser_; |
268 | 273 |
269 // Used for registering to receive notifications and automatic clean up. | 274 // Used for registering to receive notifications and automatic clean up. |
270 content::NotificationRegistrar registrar_; | 275 content::NotificationRegistrar registrar_; |
271 | 276 |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 const extensions::ExtensionList& toolbar_items = | 892 const extensions::ExtensionList& toolbar_items = |
888 toolbarModel_->toolbar_items(); | 893 toolbarModel_->toolbar_items(); |
889 if (index < toolbar_items.size()) { | 894 if (index < toolbar_items.size()) { |
890 const Extension* extension = toolbar_items[index].get(); | 895 const Extension* extension = toolbar_items[index].get(); |
891 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())]; | 896 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())]; |
892 } | 897 } |
893 return nil; | 898 return nil; |
894 } | 899 } |
895 | 900 |
896 @end | 901 @end |
OLD | NEW |