Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / extensions / command_handler.h
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_WEBUI_EXTENSIONS_COMMAND_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_COMMAND_HANDLER_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/scoped_observer.h"
10 #include "content/public/browser/web_ui_message_handler.h"
11 #include "extensions/browser/extension_registry_observer.h"
12
13 class Profile;
14
15 namespace base {
16 class DictionaryValue;
17 class ListValue;
18 }
19
20 namespace content {
21 class WebUIDataSource;
22 }
23
24 namespace extensions {
25 class Command;
26 class CommandService;
27 class Extension;
28 class ExtensionRegistry;
29
30 // The handler page for the Extension Commands UI overlay.
31 class CommandHandler : public content::WebUIMessageHandler,
32                        public ExtensionRegistryObserver {
33  public:
34   explicit CommandHandler(Profile* profile);
35   ~CommandHandler() override;
36
37   // Fetches the localized values for the page and deposits them into |source|.
38   void GetLocalizedValues(content::WebUIDataSource* source);
39
40   // WebUIMessageHandler implementation.
41   void RegisterMessages() override;
42
43  private:
44   // ExtensionRegistryObserver implementation.
45   void OnExtensionLoaded(content::BrowserContext* browser_context,
46                          const Extension* extension) override;
47   void OnExtensionUnloaded(content::BrowserContext* browser_context,
48                            const Extension* extension,
49                            UnloadedExtensionInfo::Reason reason) override;
50
51    // Update the list of extension commands in the config UI.
52   void UpdateCommandDataOnPage();
53
54   // Handles requests from javascript to fetch the extensions data, including
55   // the commands it contains.
56   // Replies back through: ExtensionCommandsOverlay.returnExtensionsData.
57   void HandleRequestExtensionsData(const base::ListValue* args);
58
59   // Handles requests from javascript to set a particular keyboard shortcut
60   // for a given extension command.
61   void HandleSetExtensionCommandShortcut(const base::ListValue* args);
62
63   // Handles requests from javascript to change the scope of a particular
64   // keyboard shortcut for a given extension command.
65   void HandleSetCommandScope(const base::ListValue* args);
66
67   // Handles requests from javascript to temporarily disable general Chrome
68   // shortcut handling while the web page is capturing which shortcut to use.
69   void HandleSetShortcutHandlingSuspended(const base::ListValue* args);
70
71   // Fetches all known commands, active and inactive and returns them through
72   // |commands|.
73   void GetAllCommands(base::DictionaryValue* commands);
74
75   Profile* profile_;
76
77   ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
78       extension_registry_observer_;
79
80   DISALLOW_COPY_AND_ASSIGN(CommandHandler);
81 };
82
83 }  // namespace extensions
84
85 #endif  // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_COMMAND_HANDLER_H_