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

Unified 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: Addressing comments. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/plugins/plugins_handler.h
diff --git a/chrome/browser/ui/webui/plugins/plugins_handler.h b/chrome/browser/ui/webui/plugins/plugins_handler.h
index 2fba979650f42a596a4c8743d7b7df06d3601cc7..977f4ab0190b374d8f0bb60f487ae0b9388aed9e 100644
--- a/chrome/browser/ui/webui/plugins/plugins_handler.h
+++ b/chrome/browser/ui/webui/plugins/plugins_handler.h
@@ -8,20 +8,33 @@
#include "base/memory/weak_ptr.h"
#include "base/prefs/pref_member.h"
#include "base/values.h"
+#include "chrome/browser/ui/webui/mojo_web_ui_handler.h"
+#include "chrome/browser/ui/webui/plugins/plugins.mojom.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/web_ui_message_handler.h"
#include "content/public/common/webplugininfo.h"
+#include "mojo/public/cpp/bindings/binding.h"
-class PluginsHandler : public content::WebUIMessageHandler,
+class PluginsHandler : public MojoWebUIHandler,
+ public PluginsHandlerMojo,
public content::NotificationObserver {
public:
- PluginsHandler();
+ PluginsHandler(content::WebUI* web_ui,
+ mojo::InterfaceRequest<PluginsHandlerMojo> request);
~PluginsHandler() override;
- // content::WebUIMessageHandler implementation.
- void RegisterMessages() override;
+ // PluginsHandlerMojo overrides:
+ void GetPluginsData(const GetPluginsDataCallback& callback) override;
+ void GetShowDetails(const GetShowDetailsCallback& callback) override;
+ void SaveShowDetailsToPrefs(bool details_mode) override;
+ void SetPluginAlwaysAllowed(const mojo::String& plugin,
+ bool allowed) override;
+ void SetPluginEnabled(const mojo::String& plugin_path, bool enable) override;
+ void SetPluginGroupEnabled(const mojo::String& group_name,
+ bool enable) override;
+ void SetClientPage(PluginsPageMojoPtr page) override;
// content::NotificationObserver implementation.
void Observe(int type,
@@ -29,25 +42,12 @@ class PluginsHandler : public content::WebUIMessageHandler,
const content::NotificationDetails& details) override;
private:
- // Callback for the "requestPluginsData" message.
- void HandleRequestPluginsData(const base::ListValue* args);
+ mojo::Array<PluginDataPtr> GeneratePluginsData(
+ const std::vector<content::WebPluginInfo>& plugins);
- // Callback for the "enablePlugin" message.
- void HandleEnablePluginMessage(const base::ListValue* args);
-
- // Callback for the "saveShowDetailsToPrefs" message.
- void HandleSaveShowDetailsToPrefs(const base::ListValue* args);
-
- // Calback for the "getShowDetails" message.
- void HandleGetShowDetails(const base::ListValue* args);
-
- // Callback for the "setPluginAlwaysAllowed" message.
- void HandleSetPluginAlwaysAllowed(const base::ListValue* args);
-
- void LoadPlugins();
-
- // Called on the UI thread when the plugin information is ready.
- void PluginsLoaded(const std::vector<content::WebPluginInfo>& plugins);
+ PluginFilePtr GeneratePluginFile(const content::WebPluginInfo& plugin,
+ const base::string16& group_name,
+ bool plugin_enabled) const;
// Detect a plugin's enabled mode (one of enabledByUser, disabledByUser,
// enabledByPolicy, disabledByPolicy).
@@ -57,8 +57,20 @@ class PluginsHandler : public content::WebUIMessageHandler,
// Detect a plugin group's enabled mode (one of enabledByUser, disabledByUser,
// enabledByPolicy, disabledByPolicy, managedByPolicy).
- std::string GetPluginGroupEnabledMode(const base::ListValue& plugin_files,
- bool group_enabled) const;
+ std::string GetPluginGroupEnabledMode(
+ const mojo::Array<PluginFilePtr>& plugin_files,
+ bool group_enabled) const;
+
+ // Called on the UI thread when the plugin info requested fom GetPluginsData
+ // is ready.
+ void RespondWithPluginsData(
+ const GetPluginsDataCallback& callback,
+ const std::vector<content::WebPluginInfo>& plugins);
+
+ // Called on the UI thread when the plugin info has changed and calls the page
+ // to update it.
+ void NotifyWithPluginsData(
+ const std::vector<content::WebPluginInfo>& plugins);
content::NotificationRegistrar registrar_;
@@ -66,9 +78,17 @@ class PluginsHandler : public content::WebUIMessageHandler,
// not.
BooleanPrefMember show_details_;
+ // Owned by RenderFrameHostImpl.
+ content::WebUI* web_ui_;
+
+ mojo::Binding<PluginsHandlerMojo> binding_;
+
+ // Handle back to the page by which JS methods can be called.
+ PluginsPageMojoPtr page_;
+
base::WeakPtrFactory<PluginsHandler> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(PluginsHandler);
};
-#endif // CHROME_BROWSER_UI_WEBUI_PLUGINS_PLUGINS_HANDLER_H_
+#endif // CHROME_BROWSER_UI_WEBUI_PLUGINS_PLUGINS_HANDLER_H_

Powered by Google App Engine
This is Rietveld 408576698