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" |
18 | 19 |
19 namespace options { | 20 namespace options { |
20 | 21 |
21 class WebsiteSettingsHandler : public content_settings::Observer, | 22 class WebsiteSettingsHandler : public content_settings::Observer, |
22 public OptionsPageUIHandler { | 23 public OptionsPageUIHandler { |
23 public: | 24 public: |
24 WebsiteSettingsHandler(); | 25 WebsiteSettingsHandler(); |
25 virtual ~WebsiteSettingsHandler(); | 26 virtual ~WebsiteSettingsHandler(); |
26 | 27 |
27 typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> | 28 typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 void OnLocalStorageFetched(const LocalStorageList& storage); | 86 void OnLocalStorageFetched(const LocalStorageList& storage); |
86 | 87 |
87 // Get all origins with Content Settings for the last given content setting, | 88 // Get all origins with Content Settings for the last given content setting, |
88 // filter them by |last_filter_|, and update the page. | 89 // filter them by |last_filter_|, and update the page. |
89 void UpdateOrigins(); | 90 void UpdateOrigins(); |
90 | 91 |
91 // Get all origins with local storage usage, filter them by |last_filter_|, | 92 // Get all origins with local storage usage, filter them by |last_filter_|, |
92 // and update the page. | 93 // and update the page. |
93 void UpdateLocalStorage(); | 94 void UpdateLocalStorage(); |
94 | 95 |
| 96 // Get all origins with power consumption, filter them by |last_filter_|, |
| 97 // and update the page. |
| 98 void UpdateBatteryUsage(); |
| 99 |
95 // Kill all tabs and app windows which have the same origin as |site_url|. | 100 // Kill all tabs and app windows which have the same origin as |site_url|. |
96 void StopOrigin(const GURL& site_url); | 101 void StopOrigin(const GURL& site_url); |
97 | 102 |
98 // Delete all of the local storage for the |site_url|. | 103 // Delete all of the local storage for the |site_url|. |
99 void DeleteLocalStorage(const GURL& site_url); | 104 void DeleteLocalStorage(const GURL& site_url); |
100 | 105 |
101 // Populates the single site edit view with the permissions and local storage | 106 // 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 | 107 // usage for a given |site_url|. If |show_page| is true, it raises a new |
103 // single site edit view. | 108 // single site edit view. |
104 void GetInfoForOrigin(const GURL& site_url, bool show_page); | 109 void GetInfoForOrigin(const GURL& site_url, bool show_page); |
105 | 110 |
106 // Updates the page with the last settings used. | 111 // Updates the page with the last settings used. |
107 void Update(); | 112 void Update(); |
108 | 113 |
109 // Returns the base URL for websites, or the app name for Chrome App URLs. | 114 // Returns the base URL for websites, or the app name for Chrome App URLs. |
110 const std::string& GetReadableName(const GURL& site_url); | 115 const std::string& GetReadableName(const GURL& site_url); |
111 | 116 |
112 std::string last_setting_; | 117 std::string last_setting_; |
113 std::string last_filter_; | 118 std::string last_filter_; |
114 GURL last_site_; | 119 GURL last_site_; |
115 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_; | 120 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_; |
116 LocalStorageList local_storage_list_; | 121 LocalStorageList local_storage_list_; |
117 | 122 |
118 // Observer to watch for content settings changes. | 123 // Observer to watch for content settings changes. |
119 ScopedObserver<HostContentSettingsMap, content_settings::Observer> observer_; | 124 ScopedObserver<HostContentSettingsMap, content_settings::Observer> observer_; |
120 | 125 |
| 126 // Subscription to watch for power consumption updates. |
| 127 scoped_ptr<power::OriginPowerMap::Subscription> subscription_; |
| 128 |
121 base::WeakPtrFactory<WebsiteSettingsHandler> weak_ptr_factory_; | 129 base::WeakPtrFactory<WebsiteSettingsHandler> weak_ptr_factory_; |
122 | 130 |
123 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsHandler); | 131 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsHandler); |
124 }; | 132 }; |
125 | 133 |
126 } // namespace options | 134 } // namespace options |
127 | 135 |
128 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_WEBSITE_SETTINGS_HANDLER_H_ | 136 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_WEBSITE_SETTINGS_HANDLER_H_ |
OLD | NEW |