| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_WEBUI_PLUGINS_PLUGINS_HANDLER_H_ | |
| 6 #define CHROME_BROWSER_UI_WEBUI_PLUGINS_PLUGINS_HANDLER_H_ | |
| 7 | |
| 8 #include "base/memory/weak_ptr.h" | |
| 9 #include "base/values.h" | |
| 10 #include "chrome/browser/ui/webui/mojo_web_ui_handler.h" | |
| 11 #include "chrome/browser/ui/webui/plugins/plugins.mojom.h" | |
| 12 #include "components/prefs/pref_member.h" | |
| 13 #include "content/public/browser/notification_observer.h" | |
| 14 #include "content/public/browser/notification_registrar.h" | |
| 15 #include "content/public/browser/notification_source.h" | |
| 16 #include "content/public/browser/web_ui_message_handler.h" | |
| 17 #include "content/public/common/webplugininfo.h" | |
| 18 #include "mojo/public/cpp/bindings/binding.h" | |
| 19 | |
| 20 class PluginsPageHandler : public MojoWebUIHandler, | |
| 21 public mojom::PluginsPageHandler, | |
| 22 public content::NotificationObserver { | |
| 23 public: | |
| 24 PluginsPageHandler(content::WebUI* web_ui, | |
| 25 mojo::InterfaceRequest<mojom::PluginsPageHandler> request); | |
| 26 ~PluginsPageHandler() override; | |
| 27 | |
| 28 // mojom::PluginsPageHandler overrides: | |
| 29 void GetPluginsData(const GetPluginsDataCallback& callback) override; | |
| 30 void GetShowDetails(const GetShowDetailsCallback& callback) override; | |
| 31 void SaveShowDetailsToPrefs(bool details_mode) override; | |
| 32 void SetPluginAlwaysAllowed(const std::string& plugin, bool allowed) override; | |
| 33 void SetClientPage(mojom::PluginsPagePtr page) override; | |
| 34 | |
| 35 // content::NotificationObserver implementation. | |
| 36 void Observe(int type, | |
| 37 const content::NotificationSource& source, | |
| 38 const content::NotificationDetails& details) override; | |
| 39 | |
| 40 private: | |
| 41 std::vector<mojom::PluginDataPtr> GeneratePluginsData( | |
| 42 const std::vector<content::WebPluginInfo>& plugins); | |
| 43 | |
| 44 mojom::PluginFilePtr GeneratePluginFile(const content::WebPluginInfo& plugin, | |
| 45 const base::string16& group_name, | |
| 46 bool plugin_enabled) const; | |
| 47 | |
| 48 // Detect a plugin's enabled mode (one of enabledByUser, disabledByUser, | |
| 49 // enabledByPolicy, disabledByPolicy). | |
| 50 std::string GetPluginEnabledMode(const base::string16& plugin_name, | |
| 51 const base::string16& group_name, | |
| 52 bool plugin_enabled) const; | |
| 53 | |
| 54 // Returns whether the policy for the current profile is "Click To Play" i.e. | |
| 55 // DefaultPluginsSetting is 3 (ASK). | |
| 56 bool GetClickToPlayPolicyEnabled() const; | |
| 57 | |
| 58 // Detect a plugin group's enabled mode (one of enabledByUser, disabledByUser, | |
| 59 // enabledByPolicy, disabledByPolicy, managedByPolicy). | |
| 60 std::string GetPluginGroupEnabledMode( | |
| 61 const std::vector<mojom::PluginFilePtr>& plugin_files, | |
| 62 bool group_enabled) const; | |
| 63 | |
| 64 // Called on the UI thread when the plugin info requested fom GetPluginsData | |
| 65 // is ready. | |
| 66 void RespondWithPluginsData( | |
| 67 const GetPluginsDataCallback& callback, | |
| 68 const std::vector<content::WebPluginInfo>& plugins); | |
| 69 | |
| 70 // Called on the UI thread when the plugin info has changed and calls the page | |
| 71 // to update it. | |
| 72 void NotifyWithPluginsData( | |
| 73 const std::vector<content::WebPluginInfo>& plugins); | |
| 74 | |
| 75 content::NotificationRegistrar registrar_; | |
| 76 | |
| 77 // This pref guards the value whether about:plugins is in the details mode or | |
| 78 // not. | |
| 79 BooleanPrefMember show_details_; | |
| 80 | |
| 81 // Owned by RenderFrameHostImpl. | |
| 82 content::WebUI* web_ui_; | |
| 83 | |
| 84 mojo::Binding<mojom::PluginsPageHandler> binding_; | |
| 85 | |
| 86 // Handle back to the page by which JS methods can be called. | |
| 87 mojom::PluginsPagePtr page_; | |
| 88 | |
| 89 base::WeakPtrFactory<PluginsPageHandler> weak_ptr_factory_; | |
| 90 | |
| 91 DISALLOW_COPY_AND_ASSIGN(PluginsPageHandler); | |
| 92 }; | |
| 93 | |
| 94 #endif // CHROME_BROWSER_UI_WEBUI_PLUGINS_PLUGINS_HANDLER_H_ | |
| OLD | NEW |