| 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/extensions/api/commands/command_service.h" | 5 #include "chrome/browser/extensions/api/commands/command_service.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/extension_keybinding_registry.h" | 9 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 std::pair<const std::string, const std::string> >(&details)); | 286 std::pair<const std::string, const std::string> >(&details)); |
| 287 } | 287 } |
| 288 } | 288 } |
| 289 | 289 |
| 290 bool CommandService::GetExtensionActionCommand( | 290 bool CommandService::GetExtensionActionCommand( |
| 291 const std::string& extension_id, | 291 const std::string& extension_id, |
| 292 QueryType query_type, | 292 QueryType query_type, |
| 293 extensions::Command* command, | 293 extensions::Command* command, |
| 294 bool* active, | 294 bool* active, |
| 295 ExtensionActionType action_type) { | 295 ExtensionActionType action_type) { |
| 296 const ExtensionSet* extensions = | 296 ExtensionService* service = |
| 297 ExtensionSystem::Get(profile_)->extension_service()->extensions(); | 297 ExtensionSystem::Get(profile_)->extension_service(); |
| 298 if (!service) |
| 299 return false; // Can happen in tests. |
| 300 const ExtensionSet* extensions = service->extensions(); |
| 298 const Extension* extension = extensions->GetByID(extension_id); | 301 const Extension* extension = extensions->GetByID(extension_id); |
| 299 CHECK(extension); | 302 CHECK(extension); |
| 300 | 303 |
| 301 if (active) | 304 if (active) |
| 302 *active = false; | 305 *active = false; |
| 303 | 306 |
| 304 const extensions::Command* requested_command = NULL; | 307 const extensions::Command* requested_command = NULL; |
| 305 switch (action_type) { | 308 switch (action_type) { |
| 306 case BROWSER_ACTION: | 309 case BROWSER_ACTION: |
| 307 requested_command = extension->browser_action_command(); | 310 requested_command = extension->browser_action_command(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 327 return false; | 330 return false; |
| 328 | 331 |
| 329 *command = *requested_command; | 332 *command = *requested_command; |
| 330 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN) | 333 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN) |
| 331 command->set_accelerator(shortcut_assigned); | 334 command->set_accelerator(shortcut_assigned); |
| 332 | 335 |
| 333 return true; | 336 return true; |
| 334 } | 337 } |
| 335 | 338 |
| 336 } // namespace extensions | 339 } // namespace extensions |
| OLD | NEW |