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

Side by Side Diff: chrome/browser/ui/webui/extensions/command_handler.cc

Issue 10870068: Make sure the Commands list correctly reflects the status of extensions right after install/uninsta… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
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" 10 #include "chrome/browser/extensions/api/commands/command_service_factory.h"
11 #include "chrome/browser/extensions/extension_keybinding_registry.h" 11 #include "chrome/browser/extensions/extension_keybinding_registry.h"
12 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/extension_system.h" 13 #include "chrome/browser/extensions/extension_system.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.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/extensions/extension_set.h" 17 #include "chrome/common/extensions/extension_set.h"
17 #include "content/public/browser/web_ui.h" 18 #include "content/public/browser/web_ui.h"
18 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
19 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
20 21
21 namespace extensions { 22 namespace extensions {
22 23
23 CommandHandler::CommandHandler() { 24 CommandHandler::CommandHandler(Profile* profile) : profile_(profile) {
24 } 25 }
25 26
26 CommandHandler::~CommandHandler() { 27 CommandHandler::~CommandHandler() {
27 } 28 }
28 29
29 void CommandHandler::GetLocalizedValues(DictionaryValue* localized_strings) { 30 void CommandHandler::GetLocalizedValues(DictionaryValue* localized_strings) {
30 DCHECK(localized_strings); 31 DCHECK(localized_strings);
31 localized_strings->SetString("extensionCommandsOverlay", 32 localized_strings->SetString("extensionCommandsOverlay",
32 l10n_util::GetStringUTF16(IDS_EXTENSION_COMMANDS_DIALOG_TITLE)); 33 l10n_util::GetStringUTF16(IDS_EXTENSION_COMMANDS_DIALOG_TITLE));
33 localized_strings->SetString("extensionCommandsEmpty", 34 localized_strings->SetString("extensionCommandsEmpty",
34 l10n_util::GetStringUTF16(IDS_EXTENSION_COMMANDS_EMPTY)); 35 l10n_util::GetStringUTF16(IDS_EXTENSION_COMMANDS_EMPTY));
35 localized_strings->SetString("extensionCommandsInactive", 36 localized_strings->SetString("extensionCommandsInactive",
36 l10n_util::GetStringUTF16(IDS_EXTENSION_COMMANDS_INACTIVE)); 37 l10n_util::GetStringUTF16(IDS_EXTENSION_COMMANDS_INACTIVE));
37 localized_strings->SetString("extensionCommandsStartTyping", 38 localized_strings->SetString("extensionCommandsStartTyping",
38 l10n_util::GetStringUTF16(IDS_EXTENSION_TYPE_SHORTCUT)); 39 l10n_util::GetStringUTF16(IDS_EXTENSION_TYPE_SHORTCUT));
39 localized_strings->SetString("ok", l10n_util::GetStringUTF16(IDS_OK)); 40 localized_strings->SetString("ok", l10n_util::GetStringUTF16(IDS_OK));
40 } 41 }
41 42
42 void CommandHandler::RegisterMessages() { 43 void CommandHandler::RegisterMessages() {
44 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
45 content::Source<Profile>(profile_));
46 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
47 content::Source<Profile>(profile_));
48
43 web_ui()->RegisterMessageCallback("extensionCommandsRequestExtensionsData", 49 web_ui()->RegisterMessageCallback("extensionCommandsRequestExtensionsData",
44 base::Bind(&CommandHandler::HandleRequestExtensionsData, 50 base::Bind(&CommandHandler::HandleRequestExtensionsData,
45 base::Unretained(this))); 51 base::Unretained(this)));
46 web_ui()->RegisterMessageCallback("setShortcutHandlingSuspended", 52 web_ui()->RegisterMessageCallback("setShortcutHandlingSuspended",
47 base::Bind(&CommandHandler::HandleSetShortcutHandlingSuspended, 53 base::Bind(&CommandHandler::HandleSetShortcutHandlingSuspended,
48 base::Unretained(this))); 54 base::Unretained(this)));
49 web_ui()->RegisterMessageCallback("setExtensionCommandShortcut", 55 web_ui()->RegisterMessageCallback("setExtensionCommandShortcut",
50 base::Bind(&CommandHandler::HandleSetExtensionCommandShortcut, 56 base::Bind(&CommandHandler::HandleSetExtensionCommandShortcut,
51 base::Unretained(this))); 57 base::Unretained(this)));
52 } 58 }
53 59
60 void CommandHandler::Observe(
61 int type,
62 const content::NotificationSource& source,
63 const content::NotificationDetails& details) {
64 DCHECK(type == chrome::NOTIFICATION_EXTENSION_LOADED ||
65 type == chrome::NOTIFICATION_EXTENSION_UNLOADED);
66 UpdateCommandDataOnPage();
67 }
68
54 void CommandHandler::UpdateCommandDataOnPage() { 69 void CommandHandler::UpdateCommandDataOnPage() {
55 DictionaryValue results; 70 DictionaryValue results;
56 GetAllCommands(&results); 71 GetAllCommands(&results);
57 web_ui()->CallJavascriptFunction( 72 web_ui()->CallJavascriptFunction(
58 "ExtensionCommandsOverlay.returnExtensionsData", results); 73 "ExtensionCommandsOverlay.returnExtensionsData", results);
59 } 74 }
60 75
61 void CommandHandler::HandleRequestExtensionsData(const ListValue* args) { 76 void CommandHandler::HandleRequestExtensionsData(const ListValue* args) {
62 UpdateCommandDataOnPage(); 77 UpdateCommandDataOnPage();
63 } 78 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 if (!extensions_list->empty()) { 165 if (!extensions_list->empty()) {
151 extension_dict->Set("commands", extensions_list.release()); 166 extension_dict->Set("commands", extensions_list.release());
152 results->Append(extension_dict.release()); 167 results->Append(extension_dict.release());
153 } 168 }
154 } 169 }
155 170
156 commands->Set("commands", results); 171 commands->Set("commands", results);
157 } 172 }
158 173
159 } // namespace extensions 174 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/extensions/command_handler.h ('k') | chrome/browser/ui/webui/extensions/extensions_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698