| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_DOM_UI_OPTIONS_CONTENT_SETTINGS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_DOM_UI_OPTIONS_CONTENT_SETTINGS_HANDLER_H_ |
| 6 #define CHROME_BROWSER_DOM_UI_OPTIONS_CONTENT_SETTINGS_HANDLER_H_ | 6 #define CHROME_BROWSER_DOM_UI_OPTIONS_CONTENT_SETTINGS_HANDLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/dom_ui/options/options_ui.h" | 9 #include "chrome/browser/webui/options/content_settings_handler.h" |
| 10 #include "chrome/browser/plugin_data_remover_helper.h" | 10 // TODO(tfarina): remove this file once all includes have been updated. |
| 11 #include "chrome/browser/prefs/pref_change_registrar.h" | |
| 12 #include "chrome/common/content_settings_types.h" | |
| 13 #include "chrome/common/notification_observer.h" | |
| 14 #include "chrome/common/notification_registrar.h" | |
| 15 | |
| 16 class HostContentSettingsMap; | |
| 17 | |
| 18 class ContentSettingsHandler : public OptionsPageUIHandler { | |
| 19 public: | |
| 20 ContentSettingsHandler(); | |
| 21 virtual ~ContentSettingsHandler(); | |
| 22 | |
| 23 // OptionsUIHandler implementation. | |
| 24 virtual void GetLocalizedValues(DictionaryValue* localized_strings); | |
| 25 | |
| 26 virtual void Initialize(); | |
| 27 | |
| 28 virtual void RegisterMessages(); | |
| 29 | |
| 30 // NotificationObserver implementation. | |
| 31 virtual void Observe(NotificationType type, | |
| 32 const NotificationSource& source, | |
| 33 const NotificationDetails& details); | |
| 34 | |
| 35 // Gets a string identifier for the group name, for use in HTML. | |
| 36 static std::string ContentSettingsTypeToGroupName(ContentSettingsType type); | |
| 37 | |
| 38 private: | |
| 39 // Functions that call into the page ----------------------------------------- | |
| 40 | |
| 41 // Updates the page with the default settings (allow, ask, block, etc.) | |
| 42 void UpdateSettingDefaultFromModel(ContentSettingsType type); | |
| 43 // Updates the state of the "Clear plugin LSO data on exit" checkbox. | |
| 44 void UpdateClearPluginLSOData(); | |
| 45 | |
| 46 // Clobbers and rebuilds the specific content setting type exceptions table. | |
| 47 void UpdateExceptionsViewFromModel(ContentSettingsType type); | |
| 48 // Clobbers and rebuilds all the exceptions tables in the page (both normal | |
| 49 // and OTR tables). | |
| 50 void UpdateAllExceptionsViewsFromModel(); | |
| 51 // As above, but only OTR tables. | |
| 52 void UpdateAllOTRExceptionsViewsFromModel(); | |
| 53 // Clobbers and rebuilds just the geolocation exception table. | |
| 54 void UpdateGeolocationExceptionsView(); | |
| 55 // Clobbers and rebuilds just the desktop notification exception table. | |
| 56 void UpdateNotificationExceptionsView(); | |
| 57 // Clobbers and rebuilds an exception table that's managed by the host content | |
| 58 // settings map. | |
| 59 void UpdateExceptionsViewFromHostContentSettingsMap(ContentSettingsType type); | |
| 60 // As above, but acts on the OTR table for the content setting type. | |
| 61 void UpdateExceptionsViewFromOTRHostContentSettingsMap( | |
| 62 ContentSettingsType type); | |
| 63 | |
| 64 // Callbacks used by the page ------------------------------------------------ | |
| 65 | |
| 66 // Sets the default value for a specific content type. |args| includes the | |
| 67 // content type and a string describing the new default the user has | |
| 68 // chosen. | |
| 69 void SetContentFilter(const ListValue* args); | |
| 70 | |
| 71 // Removes the given row from the table. The first entry in |args| is the | |
| 72 // content type, and the rest of the arguments depend on the content type | |
| 73 // to be removed. | |
| 74 void RemoveException(const ListValue* args); | |
| 75 | |
| 76 // Changes the value of an exception. Called after the user is done editing an | |
| 77 // exception. | |
| 78 void SetException(const ListValue* args); | |
| 79 | |
| 80 // Called to decide whether a given pattern is valid, or if it should be | |
| 81 // rejected. Called while the user is editing an exception pattern. | |
| 82 void CheckExceptionPatternValidity(const ListValue* args); | |
| 83 | |
| 84 // Sets the global 3rd party cookies pref. | |
| 85 void SetAllowThirdPartyCookies(const ListValue* args); | |
| 86 | |
| 87 // Utility functions --------------------------------------------------------- | |
| 88 | |
| 89 // Gets the HostContentSettingsMap for the normal profile. | |
| 90 HostContentSettingsMap* GetContentSettingsMap(); | |
| 91 | |
| 92 // Gets the HostContentSettingsMap for the incognito profile, or NULL if there | |
| 93 // is no active incognito session. | |
| 94 HostContentSettingsMap* GetOTRContentSettingsMap(); | |
| 95 | |
| 96 // Gets the default setting in string form. | |
| 97 std::string GetSettingDefaultFromModel(ContentSettingsType type); | |
| 98 | |
| 99 // Returns true if the default setting for the given content settings type | |
| 100 // |type| is managed. | |
| 101 bool GetDefaultSettingManagedFromModel(ContentSettingsType type); | |
| 102 | |
| 103 // Member variables --------------------------------------------------------- | |
| 104 | |
| 105 NotificationRegistrar notification_registrar_; | |
| 106 PrefChangeRegistrar pref_change_registrar_; | |
| 107 PluginDataRemoverHelper clear_plugin_lso_data_enabled_; | |
| 108 | |
| 109 DISALLOW_COPY_AND_ASSIGN(ContentSettingsHandler); | |
| 110 }; | |
| 111 | 11 |
| 112 #endif // CHROME_BROWSER_DOM_UI_OPTIONS_CONTENT_SETTINGS_HANDLER_H_ | 12 #endif // CHROME_BROWSER_DOM_UI_OPTIONS_CONTENT_SETTINGS_HANDLER_H_ |
| OLD | NEW |