Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: chrome/browser/extensions/api/commands/commands.cc

Issue 11820041: Remove profile-keyed factory boilerplates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/commands.h" 5 #include "chrome/browser/extensions/api/commands/commands.h"
6 6
7 #include "chrome/browser/extensions/api/commands/command_service.h" 7 #include "chrome/browser/extensions/api/commands/command_service.h"
8 #include "chrome/browser/extensions/api/commands/command_service_factory.h"
9 8
10 namespace { 9 namespace {
11 10
12 base::DictionaryValue* CreateCommandValue( 11 base::DictionaryValue* CreateCommandValue(
13 const extensions::Command& command, bool active) { 12 const extensions::Command& command, bool active) {
14 DictionaryValue* result = new DictionaryValue(); 13 DictionaryValue* result = new DictionaryValue();
15 result->SetString("name", command.command_name()); 14 result->SetString("name", command.command_name());
16 result->SetString("description", command.description()); 15 result->SetString("description", command.description());
17 result->SetString("shortcut", 16 result->SetString("shortcut",
18 active ? command.accelerator().GetShortcutText() : 17 active ? command.accelerator().GetShortcutText() :
19 string16()); 18 string16());
20 return result; 19 return result;
21 } 20 }
22 21
23 } // namespace 22 } // namespace
24 23
25 bool GetAllCommandsFunction::RunImpl() { 24 bool GetAllCommandsFunction::RunImpl() {
26 ListValue* command_list = new ListValue(); 25 ListValue* command_list = new ListValue();
27 26
28 extensions::CommandService* command_service = 27 extensions::CommandService* command_service =
29 extensions::CommandServiceFactory::GetForProfile(profile_); 28 extensions::CommandService::Get(profile_);
30 29
31 extensions::Command browser_action; 30 extensions::Command browser_action;
32 bool active = false; 31 bool active = false;
33 if (command_service->GetBrowserActionCommand(extension_->id(), 32 if (command_service->GetBrowserActionCommand(extension_->id(),
34 extensions::CommandService::ALL, 33 extensions::CommandService::ALL,
35 &browser_action, 34 &browser_action,
36 &active)) { 35 &active)) {
37 command_list->Append(CreateCommandValue(browser_action, active)); 36 command_list->Append(CreateCommandValue(browser_action, active));
38 } 37 }
39 38
(...skipping 24 matching lines...) Expand all
64 command_service->FindShortcutForCommand( 63 command_service->FindShortcutForCommand(
65 extension_->id(), iter->second.command_name()); 64 extension_->id(), iter->second.command_name());
66 active = (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN); 65 active = (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN);
67 66
68 command_list->Append(CreateCommandValue(iter->second, active)); 67 command_list->Append(CreateCommandValue(iter->second, active));
69 } 68 }
70 69
71 SetResult(command_list); 70 SetResult(command_list);
72 return true; 71 return true;
73 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698