Don't include hidden windows in IsAppWindowRegisteredInAnyProfile.
[chromium-blink-merge.git] / chrome / browser / content_settings / content_settings_usages_state.h
blob7c31b20002faddcec6476ccab937cfe876a6502a
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.
5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_USAGES_STATE_H_
6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_USAGES_STATE_H_
8 #include <map>
9 #include <set>
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"
15 class HostContentSettingsMap;
16 class PrefService;
18 namespace content {
19 struct LoadCommittedDetails;
22 // This class manages a content setting state per tab for a given
23 // |ContentSettingsType|, and provides information and presentation data about
24 // the content setting usage.
25 class ContentSettingsUsagesState {
26 public:
27 ContentSettingsUsagesState(
28 HostContentSettingsMap* host_content_settings_map,
29 PrefService* pref_service,
30 ContentSettingsType type);
31 virtual ~ContentSettingsUsagesState();
33 typedef std::map<GURL, ContentSetting> StateMap;
34 const StateMap& state_map() const {
35 return state_map_;
38 // Sets the state for |requesting_origin|.
39 void OnPermissionSet(const GURL& requesting_origin, bool allowed);
41 // Delegated by WebContents to indicate a navigation has happened and we
42 // may need to clear our settings.
43 void DidNavigate(const content::LoadCommittedDetails& details);
45 void ClearStateMap();
47 enum TabState {
48 TABSTATE_NONE = 0,
49 // There's at least one entry with non-default setting.
50 TABSTATE_HAS_EXCEPTION = 1 << 1,
51 // There's at least one entry with a non-ASK setting.
52 TABSTATE_HAS_ANY_ICON = 1 << 2,
53 // There's at least one entry with ALLOWED setting.
54 TABSTATE_HAS_ANY_ALLOWED = 1 << 3,
55 // There's at least one entry that doesn't match the saved setting.
56 TABSTATE_HAS_CHANGED = 1 << 4,
59 // Maps ContentSetting to a set of hosts formatted for presentation.
60 typedef std::map<ContentSetting, std::set<std::string> >
61 FormattedHostsPerState;
63 // Returns an (optional) |formatted_hosts_per_state| and a mask of TabState.
64 void GetDetailedInfo(FormattedHostsPerState* formatted_hosts_per_state,
65 unsigned int* tab_state_flags) const;
67 private:
68 std::string GURLToFormattedHost(const GURL& url) const;
70 HostContentSettingsMap* const host_content_settings_map_;
71 PrefService* const pref_service_;
72 ContentSettingsType type_;
73 StateMap state_map_;
74 GURL embedder_url_;
76 DISALLOW_COPY_AND_ASSIGN(ContentSettingsUsagesState);
79 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_USAGES_STATE_H_