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

Side by Side Diff: chrome/browser/content_settings/content_settings_usages_state.h

Issue 815643004: Move ContentSettingsUsagesState to the component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « no previous file | chrome/browser/content_settings/content_settings_usages_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 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_CONTENT_SETTINGS_CONTENT_SETTINGS_USAGES_STATE_H_
6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_USAGES_STATE_H_
7
8 #include <map>
9 #include <set>
10
11 #include "components/content_settings/core/common/content_settings.h"
12 #include "components/content_settings/core/common/content_settings_types.h"
13 #include "url/gurl.h"
14
15 class HostContentSettingsMap;
16 class PrefService;
17
18 // This class manages a content setting state per tab for a given
19 // |ContentSettingsType|, and provides information and presentation data about
20 // the content setting usage.
21 class ContentSettingsUsagesState {
22 public:
23 // Information about navigation.
24 struct CommittedDetails {
25 CommittedDetails();
26 ~CommittedDetails();
27
28 bool current_url_valid;
29 GURL current_url;
30 GURL previous_url;
31 };
32
33 ContentSettingsUsagesState(
34 HostContentSettingsMap* host_content_settings_map,
35 ContentSettingsType type,
36 const std::string& accept_language_pref,
37 PrefService* prefs);
38 ~ContentSettingsUsagesState();
39
40 typedef std::map<GURL, ContentSetting> StateMap;
41 const StateMap& state_map() const {
42 return state_map_;
43 }
44
45 // Sets the state for |requesting_origin|.
46 void OnPermissionSet(const GURL& requesting_origin, bool allowed);
47
48 // Delegated by WebContents to indicate a navigation has happened and we
49 // may need to clear our settings.
50 void DidNavigate(const CommittedDetails& details);
51
52 void ClearStateMap();
53
54 enum TabState {
55 TABSTATE_NONE = 0,
56 // There's at least one entry with non-default setting.
57 TABSTATE_HAS_EXCEPTION = 1 << 1,
58 // There's at least one entry with a non-ASK setting.
59 TABSTATE_HAS_ANY_ICON = 1 << 2,
60 // There's at least one entry with ALLOWED setting.
61 TABSTATE_HAS_ANY_ALLOWED = 1 << 3,
62 // There's at least one entry that doesn't match the saved setting.
63 TABSTATE_HAS_CHANGED = 1 << 4,
64 };
65
66 // Maps ContentSetting to a set of hosts formatted for presentation.
67 typedef std::map<ContentSetting, std::set<std::string> >
68 FormattedHostsPerState;
69
70 void GetDetailedInfo(FormattedHostsPerState* formatted_hosts_per_state,
71 unsigned int* tab_state_flags) const;
72
73 private:
74 std::string GURLToFormattedHost(const GURL& url) const;
75
76 HostContentSettingsMap* const host_content_settings_map_;
77 PrefService* const pref_service_;
78 std::string accept_language_pref_;
79 ContentSettingsType type_;
80 StateMap state_map_;
81 GURL embedder_url_;
82
83 DISALLOW_COPY_AND_ASSIGN(ContentSettingsUsagesState);
84 };
85
86 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_USAGES_STATE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/content_settings/content_settings_usages_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698