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

Side by Side Diff: chrome/browser/extensions/api/commands/command_service.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/command_service.h" 5 #include "chrome/browser/extensions/api/commands/command_service.h"
6 6
7 #include "base/lazy_instance.h"
7 #include "base/string_util.h" 8 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/extensions/extension_keybinding_registry.h" 10 #include "chrome/browser/extensions/extension_keybinding_registry.h"
10 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_system.h" 12 #include "chrome/browser/extensions/extension_system.h"
12 #include "chrome/browser/prefs/scoped_user_pref_update.h" 13 #include "chrome/browser/prefs/scoped_user_pref_update.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/common/chrome_notification_types.h" 15 #include "chrome/common/chrome_notification_types.h"
15 #include "chrome/common/extensions/extension_manifest_constants.h" 16 #include "chrome/common/extensions/extension_manifest_constants.h"
16 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
(...skipping 27 matching lines...) Expand all
44 : profile_(profile) { 45 : profile_(profile) {
45 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, 46 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED,
46 content::Source<Profile>(profile)); 47 content::Source<Profile>(profile));
47 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, 48 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
48 content::Source<Profile>(profile)); 49 content::Source<Profile>(profile));
49 } 50 }
50 51
51 CommandService::~CommandService() { 52 CommandService::~CommandService() {
52 } 53 }
53 54
55 static base::LazyInstance<ProfileKeyedAPIFactory<CommandService> >
56 g_factory = LAZY_INSTANCE_INITIALIZER;
57
58 // static
59 ProfileKeyedAPIFactory<CommandService>* CommandService::GetFactoryInstance() {
60 return &g_factory.Get();
61 }
62
63 // static
64 CommandService* CommandService::Get(Profile* profile) {
65 return ProfileKeyedAPIFactory<CommandService>::GetForProfile(profile);
66 }
67
54 bool CommandService::GetBrowserActionCommand( 68 bool CommandService::GetBrowserActionCommand(
55 const std::string& extension_id, 69 const std::string& extension_id,
56 QueryType type, 70 QueryType type,
57 extensions::Command* command, 71 extensions::Command* command,
58 bool* active) { 72 bool* active) {
59 return GetExtensionActionCommand( 73 return GetExtensionActionCommand(
60 extension_id, type, command, active, BROWSER_ACTION); 74 extension_id, type, command, active, BROWSER_ACTION);
61 } 75 }
62 76
63 bool CommandService::GetPageActionCommand( 77 bool CommandService::GetPageActionCommand(
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 return false; 343 return false;
330 344
331 *command = *requested_command; 345 *command = *requested_command;
332 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN) 346 if (shortcut_assigned.key_code() != ui::VKEY_UNKNOWN)
333 command->set_accelerator(shortcut_assigned); 347 command->set_accelerator(shortcut_assigned);
334 348
335 return true; 349 return true;
336 } 350 }
337 351
338 } // namespace extensions 352 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698