Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/browser/ui/webui/settings/site_settings_handler.h

Issue 2298283002: Site Settings Desktop: Support adding exceptions for incognito mode. (Closed)
Patch Set: Fix test Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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_SETTINGS_SITE_SETTINGS_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_SITE_SETTINGS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_SITE_SETTINGS_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_SITE_SETTINGS_HANDLER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/scoped_observer.h" 10 #include "base/scoped_observer.h"
11 #include "chrome/browser/storage/storage_info_fetcher.h" 11 #include "chrome/browser/storage/storage_info_fetcher.h"
12 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" 12 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
13 #include "components/content_settings/core/browser/content_settings_observer.h" 13 #include "components/content_settings/core/browser/content_settings_observer.h"
14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h"
14 16
15 class HostContentSettingsMap; 17 class HostContentSettingsMap;
16 class Profile; 18 class Profile;
17 19
18 namespace base { 20 namespace base {
19 class ListValue; 21 class ListValue;
20 } 22 }
21 23
22 namespace settings { 24 namespace settings {
23 25
24 // Chrome "ContentSettings" settings page UI handler. 26 // Chrome "ContentSettings" settings page UI handler.
25 class SiteSettingsHandler : public SettingsPageUIHandler, 27 class SiteSettingsHandler : public SettingsPageUIHandler,
26 public content_settings::Observer { 28 public content_settings::Observer,
29 public content::NotificationObserver {
27 public: 30 public:
28 explicit SiteSettingsHandler(Profile* profile); 31 explicit SiteSettingsHandler(Profile* profile);
29 ~SiteSettingsHandler() override; 32 ~SiteSettingsHandler() override;
30 33
31 // SettingsPageUIHandler: 34 // SettingsPageUIHandler:
32 void RegisterMessages() override; 35 void RegisterMessages() override;
33 void OnJavascriptAllowed() override; 36 void OnJavascriptAllowed() override;
34 void OnJavascriptDisallowed() override; 37 void OnJavascriptDisallowed() override;
35 38
36 // Usage info. 39 // Usage info.
37 void OnGetUsageInfo(const storage::UsageInfoEntries& entries); 40 void OnGetUsageInfo(const storage::UsageInfoEntries& entries);
38 void OnUsageInfoCleared(storage::QuotaStatusCode code); 41 void OnUsageInfoCleared(storage::QuotaStatusCode code);
39 42
40 // content_settings::Observer: 43 // content_settings::Observer:
41 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, 44 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern,
42 const ContentSettingsPattern& secondary_pattern, 45 const ContentSettingsPattern& secondary_pattern,
43 ContentSettingsType content_type, 46 ContentSettingsType content_type,
44 std::string resource_identifier) override; 47 std::string resource_identifier) override;
48
49 // content::NotificationObserver:
50 void Observe(int type,
51 const content::NotificationSource& source,
52 const content::NotificationDetails& details) override;
53
45 private: 54 private:
46 friend class SiteSettingsHandlerTest; 55 friend class SiteSettingsHandlerTest;
47 FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, GetAndSetDefault); 56 FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, GetAndSetDefault);
48 FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, Origins); 57 FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, Origins);
49 FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, Patterns); 58 FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, Patterns);
59 FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, Incognito);
50 60
51 // Asynchronously fetches the usage for a given origin. Replies back with 61 // Asynchronously fetches the usage for a given origin. Replies back with
52 // OnGetUsageInfo above. 62 // OnGetUsageInfo above.
53 void HandleFetchUsageTotal(const base::ListValue* args); 63 void HandleFetchUsageTotal(const base::ListValue* args);
54 64
55 // Deletes the storage being used for a given host. 65 // Deletes the storage being used for a given host.
56 void HandleClearUsage(const base::ListValue* args); 66 void HandleClearUsage(const base::ListValue* args);
57 67
58 // Handles the request for a list of all USB devices. 68 // Handles the request for a list of all USB devices.
59 void HandleFetchUsbDevices(const base::ListValue* args); 69 void HandleFetchUsbDevices(const base::ListValue* args);
60 70
61 // Removes a particular USB device permission. 71 // Removes a particular USB device permission.
62 void HandleRemoveUsbDevice(const base::ListValue* args); 72 void HandleRemoveUsbDevice(const base::ListValue* args);
63 73
64 // Gets and sets the default value for a particular content settings type. 74 // Gets and sets the default value for a particular content settings type.
65 void HandleSetDefaultValueForContentType(const base::ListValue* args); 75 void HandleSetDefaultValueForContentType(const base::ListValue* args);
66 void HandleGetDefaultValueForContentType(const base::ListValue* args); 76 void HandleGetDefaultValueForContentType(const base::ListValue* args);
67 77
68 // Returns the list of site exceptions for a given content settings type. 78 // Returns the list of site exceptions for a given content settings type.
69 void HandleGetExceptionList(const base::ListValue* args); 79 void HandleGetExceptionList(const base::ListValue* args);
70 80
71 // Handles setting and resetting of an origin permission. 81 // Handles setting and resetting of an origin permission.
72 void HandleResetCategoryPermissionForOrigin(const base::ListValue* args); 82 void HandleResetCategoryPermissionForOrigin(const base::ListValue* args);
73 void HandleSetCategoryPermissionForOrigin(const base::ListValue* args); 83 void HandleSetCategoryPermissionForOrigin(const base::ListValue* args);
74 84
75 // Returns whether a given pattern is valid. 85 // Returns whether a given pattern is valid.
76 void HandleIsPatternValid(const base::ListValue* args); 86 void HandleIsPatternValid(const base::ListValue* args);
77 87
88 // Looks up whether an incognito session is active.
89 void HandleUpdateIncognitoStatus(const base::ListValue* args);
90
91 // Notifies the JS side whether incognito is enabled.
92 void SendIncognitoStatus(Profile* profile, bool was_destroyed);
93
78 Profile* profile_; 94 Profile* profile_;
79 95
96 content::NotificationRegistrar notification_registrar_;
97
80 // The host for which to fetch usage. 98 // The host for which to fetch usage.
81 std::string usage_host_; 99 std::string usage_host_;
82 100
83 // The origin for which to clear usage. 101 // The origin for which to clear usage.
84 std::string clearing_origin_; 102 std::string clearing_origin_;
85 103
86 // Change observer for content settings. 104 // Change observer for content settings.
87 ScopedObserver<HostContentSettingsMap, content_settings::Observer> observer_; 105 ScopedObserver<HostContentSettingsMap, content_settings::Observer> observer_;
88 106
89 DISALLOW_COPY_AND_ASSIGN(SiteSettingsHandler); 107 DISALLOW_COPY_AND_ASSIGN(SiteSettingsHandler);
90 }; 108 };
91 109
92 } // namespace settings 110 } // namespace settings
93 111
94 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SITE_SETTINGS_HANDLER_H_ 112 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SITE_SETTINGS_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698