| 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 #include "chrome/browser/ui/views/browser_actions_container.h" | 5 #include "chrome/browser/ui/views/browser_actions_container.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/extensions/extension_browser_event_router.h" | 11 #include "chrome/browser/extensions/extension_browser_event_router.h" |
| 12 #include "chrome/browser/extensions/extension_command_service.h" |
| 13 #include "chrome/browser/extensions/extension_command_service_factory.h" |
| 12 #include "chrome/browser/extensions/extension_context_menu_model.h" | 14 #include "chrome/browser/extensions/extension_context_menu_model.h" |
| 13 #include "chrome/browser/extensions/extension_host.h" | 15 #include "chrome/browser/extensions/extension_host.h" |
| 14 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 15 #include "chrome/browser/extensions/extension_tabs_module.h" | 17 #include "chrome/browser/extensions/extension_tabs_module.h" |
| 16 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/sessions/restore_tab_helper.h" | 20 #include "chrome/browser/sessions/restore_tab_helper.h" |
| 19 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
| 21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 23 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 gfx::Size(Extension::kBrowserActionIconMaxSize, | 113 gfx::Size(Extension::kBrowserActionIconMaxSize, |
| 112 Extension::kBrowserActionIconMaxSize), | 114 Extension::kBrowserActionIconMaxSize), |
| 113 ImageLoadingTracker::DONT_CACHE); | 115 ImageLoadingTracker::DONT_CACHE); |
| 114 } else { | 116 } else { |
| 115 // Set the icon to be the default extensions icon. | 117 // Set the icon to be the default extensions icon. |
| 116 default_icon_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 118 default_icon_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 117 IDR_EXTENSIONS_FAVICON).ToSkBitmap(); | 119 IDR_EXTENSIONS_FAVICON).ToSkBitmap(); |
| 118 UpdateState(); | 120 UpdateState(); |
| 119 } | 121 } |
| 120 | 122 |
| 123 ExtensionCommandService* command_service = |
| 124 ExtensionCommandServiceFactory::GetForProfile( |
| 125 panel_->browser()->profile()); |
| 121 const Extension::ExtensionKeybinding* browser_action_command = | 126 const Extension::ExtensionKeybinding* browser_action_command = |
| 122 extension_->browser_action_command(); | 127 command_service->GetActiveBrowserActionCommand(extension_->id()); |
| 123 if (browser_action_command) { | 128 if (browser_action_command) { |
| 124 keybinding_.reset(new ui::Accelerator( | 129 keybinding_.reset(new ui::Accelerator( |
| 125 browser_action_command->accelerator())); | 130 browser_action_command->accelerator())); |
| 126 panel_->GetFocusManager()->RegisterAccelerator( | 131 panel_->GetFocusManager()->RegisterAccelerator( |
| 127 *keybinding_.get(), ui::AcceleratorManager::kHighPriority, this); | 132 *keybinding_.get(), ui::AcceleratorManager::kHighPriority, this); |
| 128 } | 133 } |
| 129 } | 134 } |
| 130 | 135 |
| 131 MenuButton::ViewHierarchyChanged(is_add, parent, child); | 136 MenuButton::ViewHierarchyChanged(is_add, parent, child); |
| 132 } | 137 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 } | 306 } |
| 302 | 307 |
| 303 void BrowserActionButton::SetButtonNotPushed() { | 308 void BrowserActionButton::SetButtonNotPushed() { |
| 304 SetState(views::CustomButton::BS_NORMAL); | 309 SetState(views::CustomButton::BS_NORMAL); |
| 305 menu_visible_ = false; | 310 menu_visible_ = false; |
| 306 } | 311 } |
| 307 | 312 |
| 308 BrowserActionButton::~BrowserActionButton() { | 313 BrowserActionButton::~BrowserActionButton() { |
| 309 } | 314 } |
| 310 | 315 |
| 311 | |
| 312 //////////////////////////////////////////////////////////////////////////////// | 316 //////////////////////////////////////////////////////////////////////////////// |
| 313 // BrowserActionView | 317 // BrowserActionView |
| 314 | 318 |
| 315 BrowserActionView::BrowserActionView(const Extension* extension, | 319 BrowserActionView::BrowserActionView(const Extension* extension, |
| 316 BrowserActionsContainer* panel) | 320 BrowserActionsContainer* panel) |
| 317 : panel_(panel) { | 321 : panel_(panel) { |
| 318 button_ = new BrowserActionButton(extension, panel); | 322 button_ = new BrowserActionButton(extension, panel); |
| 319 button_->set_drag_controller(panel_); | 323 button_->set_drag_controller(panel_); |
| 320 AddChildView(button_); | 324 AddChildView(button_); |
| 321 button_->UpdateState(); | 325 button_->UpdateState(); |
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 } | 1124 } |
| 1121 } | 1125 } |
| 1122 | 1126 |
| 1123 bool BrowserActionsContainer::ShouldDisplayBrowserAction( | 1127 bool BrowserActionsContainer::ShouldDisplayBrowserAction( |
| 1124 const Extension* extension) { | 1128 const Extension* extension) { |
| 1125 // Only display incognito-enabled extensions while in incognito mode. | 1129 // Only display incognito-enabled extensions while in incognito mode. |
| 1126 return | 1130 return |
| 1127 (!profile_->IsOffTheRecord() || | 1131 (!profile_->IsOffTheRecord() || |
| 1128 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id())); | 1132 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id())); |
| 1129 } | 1133 } |
| OLD | NEW |