website_settings_handler.h revision 6e8cce623b6e4fe0c9e4af605d675dd9d0338c38
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 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_WEBSITE_SETTINGS_HANDLER_H_ 6#define CHROME_BROWSER_UI_WEBUI_OPTIONS_WEBSITE_SETTINGS_HANDLER_H_ 7 8#include <string> 9 10#include "base/basictypes.h" 11#include "base/macros.h" 12#include "base/scoped_observer.h" 13#include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" 14#include "chrome/browser/content_settings/content_settings_observer.h" 15#include "chrome/browser/content_settings/host_content_settings_map.h" 16#include "chrome/browser/content_settings/local_shared_objects_container.h" 17#include "chrome/browser/ui/webui/options/options_ui.h" 18 19namespace options { 20 21class WebsiteSettingsHandler : public content_settings::Observer, 22 public OptionsPageUIHandler { 23 public: 24 WebsiteSettingsHandler(); 25 virtual ~WebsiteSettingsHandler(); 26 27 typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> 28 LocalStorageList; 29 30 // OptionsPageUIHandler implementation. 31 virtual void GetLocalizedValues( 32 base::DictionaryValue* localized_strings) OVERRIDE; 33 virtual void InitializeHandler() OVERRIDE; 34 virtual void RegisterMessages() OVERRIDE; 35 36 // content_settings::Observer implementation. 37 virtual void OnContentSettingChanged( 38 const ContentSettingsPattern& primary_pattern, 39 const ContentSettingsPattern& secondary_pattern, 40 ContentSettingsType content_type, 41 std::string resource_identifier) OVERRIDE; 42 43 private: 44 // Update the page with all origins for a given content setting. 45 // |args| is the string name of the content setting. 46 void HandleUpdateOrigins(const base::ListValue* args); 47 48 // Update the page with all origins given a filter string. 49 // |args| is the filter string. 50 void HandleUpdateSearchResults(const base::ListValue* args); 51 52 // Update the page with all origins that are using local storage. 53 void HandleUpdateLocalStorage(const base::ListValue* args); 54 55 // Callback method to be invoked when fetching the data is complete. 56 void OnLocalStorageFetched(const LocalStorageList& storage); 57 58 // Get all origins with Content Settings for the last given content setting, 59 // filter them by |last_filter_|, and update the page. 60 void UpdateOrigins(); 61 62 // Get all origins with local storage usage, filter them by |last_filter_|, 63 // and update the page. 64 void UpdateLocalStorage(); 65 66 // Updates the page with the last settings used. 67 void Update(); 68 69 std::string last_setting_; 70 std::string last_filter_; 71 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_; 72 LocalStorageList local_storage_list_; 73 74 // Observer to watch for content settings changes. 75 ScopedObserver<HostContentSettingsMap, content_settings::Observer> observer_; 76 77 base::WeakPtrFactory<WebsiteSettingsHandler> weak_ptr_factory_; 78 79 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsHandler); 80}; 81 82} // namespace options 83 84#endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_WEBSITE_SETTINGS_HANDLER_H_ 85