OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_OPTIONS_WEBSITE_SETTINGS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_WEBSITE_SETTINGS_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_WEBSITE_SETTINGS_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_WEBSITE_SETTINGS_HANDLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/scoped_observer.h" | 12 #include "base/scoped_observer.h" |
13 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 13 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
14 #include "chrome/browser/content_settings/content_settings_observer.h" | 14 #include "chrome/browser/content_settings/content_settings_observer.h" |
15 #include "chrome/browser/content_settings/host_content_settings_map.h" | 15 #include "chrome/browser/content_settings/host_content_settings_map.h" |
16 #include "chrome/browser/content_settings/local_shared_objects_container.h" | 16 #include "chrome/browser/content_settings/local_shared_objects_container.h" |
17 #include "chrome/browser/ui/webui/options/options_ui.h" | 17 #include "chrome/browser/ui/webui/options/options_ui.h" |
| 18 #include "components/power/origin_power_map.h" |
| 19 #include "components/power/origin_power_map_observer.h" |
18 | 20 |
19 namespace options { | 21 namespace options { |
20 | 22 |
21 class WebsiteSettingsHandler : public content_settings::Observer, | 23 class WebsiteSettingsHandler : public content_settings::Observer, |
| 24 public power::OriginPowerMapObserver, |
22 public OptionsPageUIHandler { | 25 public OptionsPageUIHandler { |
23 public: | 26 public: |
24 WebsiteSettingsHandler(); | 27 WebsiteSettingsHandler(); |
25 virtual ~WebsiteSettingsHandler(); | 28 virtual ~WebsiteSettingsHandler(); |
26 | 29 |
27 typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> | 30 typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> |
28 LocalStorageList; | 31 LocalStorageList; |
29 | 32 |
30 // OptionsPageUIHandler implementation. | 33 // OptionsPageUIHandler implementation. |
31 virtual void GetLocalizedValues( | 34 virtual void GetLocalizedValues( |
32 base::DictionaryValue* localized_strings) OVERRIDE; | 35 base::DictionaryValue* localized_strings) OVERRIDE; |
33 virtual void InitializeHandler() OVERRIDE; | 36 virtual void InitializeHandler() OVERRIDE; |
34 virtual void RegisterMessages() OVERRIDE; | 37 virtual void RegisterMessages() OVERRIDE; |
35 | 38 |
36 // content_settings::Observer implementation. | 39 // content_settings::Observer implementation. |
37 virtual void OnContentSettingChanged( | 40 virtual void OnContentSettingChanged( |
38 const ContentSettingsPattern& primary_pattern, | 41 const ContentSettingsPattern& primary_pattern, |
39 const ContentSettingsPattern& secondary_pattern, | 42 const ContentSettingsPattern& secondary_pattern, |
40 ContentSettingsType content_type, | 43 ContentSettingsType content_type, |
41 std::string resource_identifier) OVERRIDE; | 44 std::string resource_identifier) OVERRIDE; |
42 virtual void OnContentSettingUsed( | 45 virtual void OnContentSettingUsed( |
43 const ContentSettingsPattern& primary_pattern, | 46 const ContentSettingsPattern& primary_pattern, |
44 const ContentSettingsPattern& secondary_pattern, | 47 const ContentSettingsPattern& secondary_pattern, |
45 ContentSettingsType content_type) OVERRIDE; | 48 ContentSettingsType content_type) OVERRIDE; |
46 | 49 |
| 50 // power::OriginPowerMapObserver implementation. |
| 51 virtual void OnPowerConsumptionUpdated() OVERRIDE; |
| 52 |
47 private: | 53 private: |
48 // Update the page with all origins for a given content setting. | 54 // Update the page with all origins for a given content setting. |
49 // |args| is the string name of the content setting. | 55 // |args| is the string name of the content setting. |
50 void HandleUpdateOrigins(const base::ListValue* args); | 56 void HandleUpdateOrigins(const base::ListValue* args); |
51 | 57 |
52 // Update the page with all origins given a filter string. | 58 // Update the page with all origins given a filter string. |
53 // |args| is the filter string. | 59 // |args| is the filter string. |
54 void HandleUpdateSearchResults(const base::ListValue* args); | 60 void HandleUpdateSearchResults(const base::ListValue* args); |
55 | 61 |
56 // Update the single site edit view with the permission values for a given | 62 // Update the single site edit view with the permission values for a given |
(...skipping 28 matching lines...) Expand all Loading... |
85 void OnLocalStorageFetched(const LocalStorageList& storage); | 91 void OnLocalStorageFetched(const LocalStorageList& storage); |
86 | 92 |
87 // Get all origins with Content Settings for the last given content setting, | 93 // Get all origins with Content Settings for the last given content setting, |
88 // filter them by |last_filter_|, and update the page. | 94 // filter them by |last_filter_|, and update the page. |
89 void UpdateOrigins(); | 95 void UpdateOrigins(); |
90 | 96 |
91 // Get all origins with local storage usage, filter them by |last_filter_|, | 97 // Get all origins with local storage usage, filter them by |last_filter_|, |
92 // and update the page. | 98 // and update the page. |
93 void UpdateLocalStorage(); | 99 void UpdateLocalStorage(); |
94 | 100 |
| 101 // Get all origins with power consumption, filter them by |last_filter_|, |
| 102 // and update the page. |
| 103 void UpdateBatteryUsage(); |
| 104 |
95 // Kill all tabs and app windows which have the same origin as |site_url|. | 105 // Kill all tabs and app windows which have the same origin as |site_url|. |
96 void StopOrigin(const GURL& site_url); | 106 void StopOrigin(const GURL& site_url); |
97 | 107 |
98 // Delete all of the local storage for the |site_url|. | 108 // Delete all of the local storage for the |site_url|. |
99 void DeleteLocalStorage(const GURL& site_url); | 109 void DeleteLocalStorage(const GURL& site_url); |
100 | 110 |
101 // Populates the single site edit view with the permissions and local storage | 111 // Populates the single site edit view with the permissions and local storage |
102 // usage for a given |site_url|. If |show_page| is true, it raises a new | 112 // usage for a given |site_url|. If |show_page| is true, it raises a new |
103 // single site edit view. | 113 // single site edit view. |
104 void GetInfoForOrigin(const GURL& site_url, bool show_page); | 114 void GetInfoForOrigin(const GURL& site_url, bool show_page); |
105 | 115 |
106 // Updates the page with the last settings used. | 116 // Updates the page with the last settings used. |
107 void Update(); | 117 void Update(); |
108 | 118 |
109 // Returns the base URL for websites, or the app name for Chrome App URLs. | 119 // Returns the base URL for websites, or the app name for Chrome App URLs. |
110 const std::string& GetReadableName(const GURL& site_url); | 120 const std::string& GetReadableName(const GURL& site_url); |
111 | 121 |
112 std::string last_setting_; | 122 std::string last_setting_; |
113 std::string last_filter_; | 123 std::string last_filter_; |
114 GURL last_site_; | 124 GURL last_site_; |
115 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_; | 125 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_; |
116 LocalStorageList local_storage_list_; | 126 LocalStorageList local_storage_list_; |
117 | 127 |
118 // Observer to watch for content settings changes. | 128 // Observer to watch for content settings changes. |
119 ScopedObserver<HostContentSettingsMap, content_settings::Observer> observer_; | 129 ScopedObserver<HostContentSettingsMap, content_settings::Observer> observer_; |
120 | 130 |
| 131 // Observer to watch for power consumption changes. |
| 132 ScopedObserver<power::OriginPowerMap, OriginPowerMapObserver> power_observer_; |
| 133 |
121 base::WeakPtrFactory<WebsiteSettingsHandler> weak_ptr_factory_; | 134 base::WeakPtrFactory<WebsiteSettingsHandler> weak_ptr_factory_; |
122 | 135 |
123 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsHandler); | 136 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsHandler); |
124 }; | 137 }; |
125 | 138 |
126 } // namespace options | 139 } // namespace options |
127 | 140 |
128 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_WEBSITE_SETTINGS_HANDLER_H_ | 141 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_WEBSITE_SETTINGS_HANDLER_H_ |
OLD | NEW |