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

Side by Side Diff: chrome/browser/ui/webui/plugins/plugins_handler.h

Issue 1576183003: chrome://plugins Mojo-ification part 2/2, populating the page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@plugins_mojo1
Patch Set: More work Created 4 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_UI_WEBUI_PLUGINS_PLUGINS_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_PLUGINS_PLUGINS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_PLUGINS_PLUGINS_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_PLUGINS_PLUGINS_HANDLER_H_
7 7
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/prefs/pref_member.h" 9 #include "base/prefs/pref_member.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/ui/webui/mojo_web_ui_handler.h"
12 #include "chrome/browser/ui/webui/plugins/plugins.mojom.h"
11 #include "content/public/browser/notification_observer.h" 13 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h" 14 #include "content/public/browser/notification_registrar.h"
13 #include "content/public/browser/notification_source.h" 15 #include "content/public/browser/notification_source.h"
14 #include "content/public/browser/web_ui_message_handler.h" 16 #include "content/public/browser/web_ui_message_handler.h"
15 #include "content/public/common/webplugininfo.h" 17 #include "content/public/common/webplugininfo.h"
18 #include "mojo/public/cpp/bindings/binding.h"
16 19
17 class PluginsHandler : public content::WebUIMessageHandler, 20 class PluginsHandler :
18 public content::NotificationObserver { 21 public MojoWebUIHandler, public PluginsHandlerMojo,
22 public content::NotificationObserver {
19 public: 23 public:
20 PluginsHandler(); 24 PluginsHandler(content::WebUI* web_ui,
25 mojo::InterfaceRequest<PluginsHandlerMojo> request);
21 ~PluginsHandler() override; 26 ~PluginsHandler() override;
22 27
23 // content::WebUIMessageHandler implementation. 28 // PluginsHandlerMojo overrides:
24 void RegisterMessages() override; 29 void GetPluginsData(const GetPluginsDataCallback& callback) override;
30 void GetShowDetails(const GetShowDetailsCallback& callback) override;
31 void SaveShowDetailsToPrefs(bool details_mode) override;
32 void SetPluginAlwaysAllowed(
33 const mojo::String& plugin, bool allowed) override;
34 void SetPluginEnabled(const mojo::String& plugin_path, bool enable) override;
35 void SetPluginGroupEnabled(const mojo::String& group_name, bool enable)
36 override;
25 37
26 // content::NotificationObserver implementation. 38 // content::NotificationObserver implementation.
27 void Observe(int type, 39 void Observe(int type,
28 const content::NotificationSource& source, 40 const content::NotificationSource& source,
29 const content::NotificationDetails& details) override; 41 const content::NotificationDetails& details) override;
30 42
31 private: 43 private:
32 // Callback for the "requestPluginsData" message. 44 // Callback for the "requestPluginsData" message.
33 void HandleRequestPluginsData(const base::ListValue* args); 45 void HandleRequestPluginsData(const base::ListValue* args);
34 46
35 // Callback for the "enablePlugin" message. 47 // Callback for the "enablePlugin" message.
36 void HandleEnablePluginMessage(const base::ListValue* args); 48 void HandleEnablePluginMessage(const base::ListValue* args);
37 49
38 // Callback for the "saveShowDetailsToPrefs" message. 50 // Callback for the "saveShowDetailsToPrefs" message.
39 void HandleSaveShowDetailsToPrefs(const base::ListValue* args); 51 void HandleSaveShowDetailsToPrefs(const base::ListValue* args);
40 52
41 // Calback for the "getShowDetails" message. 53 // Calback for the "getShowDetails" message.
42 void HandleGetShowDetails(const base::ListValue* args); 54 void HandleGetShowDetails(const base::ListValue* args);
43 55
44 // Callback for the "setPluginAlwaysAllowed" message. 56 // Callback for the "setPluginAlwaysAllowed" message.
45 void HandleSetPluginAlwaysAllowed(const base::ListValue* args); 57 void HandleSetPluginAlwaysAllowed(const base::ListValue* args);
46 58
47 void LoadPlugins(); 59 void LoadPlugins();
48 60
49 // Called on the UI thread when the plugin information is ready. 61 // Called on the UI thread when the plugin information is ready.
50 void PluginsLoaded(const std::vector<content::WebPluginInfo>& plugins); 62 void PluginsLoaded(
63 const GetPluginsDataCallback& callback,
64 const std::vector<content::WebPluginInfo>& plugins);
51 65
52 // Detect a plugin's enabled mode (one of enabledByUser, disabledByUser, 66 // Detect a plugin's enabled mode (one of enabledByUser, disabledByUser,
53 // enabledByPolicy, disabledByPolicy). 67 // enabledByPolicy, disabledByPolicy).
54 std::string GetPluginEnabledMode(const base::string16& plugin_name, 68 std::string GetPluginEnabledMode(const base::string16& plugin_name,
55 const base::string16& group_name, 69 const base::string16& group_name,
56 bool plugin_enabled) const; 70 bool plugin_enabled) const;
57 71
58 // Detect a plugin group's enabled mode (one of enabledByUser, disabledByUser, 72 // Detect a plugin group's enabled mode (one of enabledByUser, disabledByUser,
59 // enabledByPolicy, disabledByPolicy, managedByPolicy). 73 // enabledByPolicy, disabledByPolicy, managedByPolicy).
60 std::string GetPluginGroupEnabledMode(const base::ListValue& plugin_files, 74 std::string GetPluginGroupEnabledMode(
61 bool group_enabled) const; 75 const mojo::Array<PluginFilePtr>& plugin_files,
76 bool group_enabled) const;
77
78 PluginFilePtr GetPluginFile(const content::WebPluginInfo& plugin,
79 const base::string16& group_name,
80 bool plugin_enabled) const;
62 81
63 content::NotificationRegistrar registrar_; 82 content::NotificationRegistrar registrar_;
64 83
65 // This pref guards the value whether about:plugins is in the details mode or 84 // This pref guards the value whether about:plugins is in the details mode or
66 // not. 85 // not.
67 BooleanPrefMember show_details_; 86 BooleanPrefMember show_details_;
68 87
88 content::WebUI* web_ui_;
89 mojo::Binding<PluginsHandlerMojo> binding_;
90
69 base::WeakPtrFactory<PluginsHandler> weak_ptr_factory_; 91 base::WeakPtrFactory<PluginsHandler> weak_ptr_factory_;
70 92
71 DISALLOW_COPY_AND_ASSIGN(PluginsHandler); 93 DISALLOW_COPY_AND_ASSIGN(PluginsHandler);
72 }; 94 };
73 95
74 #endif // CHROME_BROWSER_UI_WEBUI_PLUGINS_PLUGINS_HANDLER_H_ 96 #endif // CHROME_BROWSER_UI_WEBUI_PLUGINS_PLUGINS_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698