Chromium Code Reviews| 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" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 gfx::Size(Extension::kBrowserActionIconMaxSize, | 109 gfx::Size(Extension::kBrowserActionIconMaxSize, |
| 110 Extension::kBrowserActionIconMaxSize), | 110 Extension::kBrowserActionIconMaxSize), |
| 111 ImageLoadingTracker::DONT_CACHE); | 111 ImageLoadingTracker::DONT_CACHE); |
| 112 } else { | 112 } else { |
| 113 // Set the icon to be the default extensions icon. | 113 // Set the icon to be the default extensions icon. |
| 114 default_icon_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 114 default_icon_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 115 IDR_EXTENSIONS_FAVICON).ToSkBitmap(); | 115 IDR_EXTENSIONS_FAVICON).ToSkBitmap(); |
| 116 UpdateState(); | 116 UpdateState(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 // Iterate through all the keybindings and see if one is assigned to the | 119 std::vector<Extension::ExtensionKeybinding> browser_action_command; |
| 120 // browserAction. | 120 extension_->GetCommandByType(Extension::ExtensionKeybinding::BROWSER_ACTION, |
|
Aaron Boodman
2012/03/21 21:05:04
Can you change Extension to store these commands i
| |
| 121 const std::vector<Extension::ExtensionKeybinding>& commands = | 121 &browser_action_command); |
| 122 extension_->keybindings(); | 122 if (!browser_action_command.empty()) { |
| 123 for (size_t i = 0; i < commands.size(); ++i) { | 123 Extension::ExtensionKeybinding* command = &browser_action_command[0]; |
| 124 if (commands[i].command_name() == | 124 keybinding_.reset(new ui::Accelerator(command->accelerator())); |
| 125 extension_manifest_values::kBrowserActionKeybindingEvent) { | 125 panel_->GetFocusManager()->RegisterAccelerator( |
| 126 keybinding_.reset(new ui::Accelerator(commands[i].accelerator())); | 126 *keybinding_.get(), ui::AcceleratorManager::kHighPriority, this); |
| 127 panel_->GetFocusManager()->RegisterAccelerator( | |
| 128 *keybinding_.get(), ui::AcceleratorManager::kHighPriority, this); | |
| 129 break; | |
| 130 } | |
| 131 } | 127 } |
| 132 } | 128 } |
| 133 | 129 |
| 134 MenuButton::ViewHierarchyChanged(is_add, parent, child); | 130 MenuButton::ViewHierarchyChanged(is_add, parent, child); |
| 135 } | 131 } |
| 136 | 132 |
| 137 void BrowserActionButton::ButtonPressed(views::Button* sender, | 133 void BrowserActionButton::ButtonPressed(views::Button* sender, |
| 138 const views::Event& event) { | 134 const views::Event& event) { |
| 139 panel_->OnBrowserActionExecuted(this, false); | 135 panel_->OnBrowserActionExecuted(this, false); |
| 140 } | 136 } |
| (...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1130 } | 1126 } |
| 1131 } | 1127 } |
| 1132 | 1128 |
| 1133 bool BrowserActionsContainer::ShouldDisplayBrowserAction( | 1129 bool BrowserActionsContainer::ShouldDisplayBrowserAction( |
| 1134 const Extension* extension) { | 1130 const Extension* extension) { |
| 1135 // Only display incognito-enabled extensions while in incognito mode. | 1131 // Only display incognito-enabled extensions while in incognito mode. |
| 1136 return | 1132 return |
| 1137 (!profile_->IsOffTheRecord() || | 1133 (!profile_->IsOffTheRecord() || |
| 1138 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id())); | 1134 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id())); |
| 1139 } | 1135 } |
| OLD | NEW |