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

Side by Side Diff: chrome/browser/ui/webui/extensions/command_handler.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/ui/webui/extensions/command_handler.h" 5 #include "chrome/browser/ui/webui/extensions/command_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/extensions/api/commands/command_service.h" 9 #include "chrome/browser/extensions/api/commands/command_service.h"
10 #include "chrome/browser/extensions/api/commands/command_service_factory.h"
11 #include "chrome/browser/extensions/extension_keybinding_registry.h" 10 #include "chrome/browser/extensions/extension_keybinding_registry.h"
12 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/extension_system.h" 12 #include "chrome/browser/extensions/extension_system.h"
14 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/common/chrome_notification_types.h" 14 #include "chrome/common/chrome_notification_types.h"
16 #include "chrome/common/extensions/extension_manifest_constants.h" 15 #include "chrome/common/extensions/extension_manifest_constants.h"
17 #include "chrome/common/extensions/extension_set.h" 16 #include "chrome/common/extensions/extension_set.h"
18 #include "content/public/browser/web_ui.h" 17 #include "content/public/browser/web_ui.h"
19 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
20 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 std::string command_name; 84 std::string command_name;
86 std::string keystroke; 85 std::string keystroke;
87 if (!args->GetString(0, &extension_id) || 86 if (!args->GetString(0, &extension_id) ||
88 !args->GetString(1, &command_name) || 87 !args->GetString(1, &command_name) ||
89 !args->GetString(2, &keystroke)) { 88 !args->GetString(2, &keystroke)) {
90 NOTREACHED(); 89 NOTREACHED();
91 return; 90 return;
92 } 91 }
93 92
94 Profile* profile = Profile::FromWebUI(web_ui()); 93 Profile* profile = Profile::FromWebUI(web_ui());
95 CommandService* command_service = 94 CommandService* command_service = CommandService::Get(profile);
96 CommandServiceFactory::GetForProfile(profile);
97 command_service->UpdateKeybindingPrefs(extension_id, command_name, keystroke); 95 command_service->UpdateKeybindingPrefs(extension_id, command_name, keystroke);
98 96
99 UpdateCommandDataOnPage(); 97 UpdateCommandDataOnPage();
100 } 98 }
101 99
102 void CommandHandler::HandleSetShortcutHandlingSuspended(const ListValue* args) { 100 void CommandHandler::HandleSetShortcutHandlingSuspended(const ListValue* args) {
103 bool suspended; 101 bool suspended;
104 if (args->GetBoolean(0, &suspended)) 102 if (args->GetBoolean(0, &suspended))
105 ExtensionKeybindingRegistry::SetShortcutHandlingSuspended(suspended); 103 ExtensionKeybindingRegistry::SetShortcutHandlingSuspended(suspended);
106 } 104 }
107 105
108 void CommandHandler::GetAllCommands(base::DictionaryValue* commands) { 106 void CommandHandler::GetAllCommands(base::DictionaryValue* commands) {
109 ListValue* results = new ListValue; 107 ListValue* results = new ListValue;
110 108
111 Profile* profile = Profile::FromWebUI(web_ui()); 109 Profile* profile = Profile::FromWebUI(web_ui());
112 CommandService* command_service = 110 CommandService* command_service = CommandService::Get(profile);
113 CommandServiceFactory::GetForProfile(profile);
114 111
115 const ExtensionSet* extensions = extensions::ExtensionSystem::Get(profile)-> 112 const ExtensionSet* extensions = extensions::ExtensionSystem::Get(profile)->
116 extension_service()->extensions(); 113 extension_service()->extensions();
117 for (ExtensionSet::const_iterator extension = extensions->begin(); 114 for (ExtensionSet::const_iterator extension = extensions->begin();
118 extension != extensions->end(); ++extension) { 115 extension != extensions->end(); ++extension) {
119 scoped_ptr<DictionaryValue> extension_dict(new DictionaryValue); 116 scoped_ptr<DictionaryValue> extension_dict(new DictionaryValue);
120 extension_dict->SetString("name", (*extension)->name()); 117 extension_dict->SetString("name", (*extension)->name());
121 extension_dict->SetString("id", (*extension)->id()); 118 extension_dict->SetString("id", (*extension)->id());
122 119
123 // Add the keybindings to a list structure. 120 // Add the keybindings to a list structure.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 if (!extensions_list->empty()) { 164 if (!extensions_list->empty()) {
168 extension_dict->Set("commands", extensions_list.release()); 165 extension_dict->Set("commands", extensions_list.release());
169 results->Append(extension_dict.release()); 166 results->Append(extension_dict.release());
170 } 167 }
171 } 168 }
172 169
173 commands->Set("commands", results); 170 commands->Set("commands", results);
174 } 171 }
175 172
176 } // namespace extensions 173 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/page_action_image_view.cc ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698