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_
11 #include "chrome/common/content_settings.h"
12 #include "chrome/common/content_settings_types.h"
18 struct LoadCommittedDetails
;
21 // This class manages a content setting state per tab for a given
22 // |ContentSettingsType|, and provides information and presentation data about
23 // the content setting usage.
24 class ContentSettingsUsagesState
{
26 ContentSettingsUsagesState(Profile
* profile
, ContentSettingsType type
);
27 virtual ~ContentSettingsUsagesState();
29 typedef std::map
<GURL
, ContentSetting
> StateMap
;
30 const StateMap
& state_map() const {
34 // Sets the state for |requesting_origin|.
35 void OnPermissionSet(const GURL
& requesting_origin
, bool allowed
);
37 // Delegated by WebContents to indicate a navigation has happened and we
38 // may need to clear our settings.
39 void DidNavigate(const content::LoadCommittedDetails
& details
);
45 // There's at least one entry with non-default setting.
46 TABSTATE_HAS_EXCEPTION
= 1 << 1,
47 // There's at least one entry with a non-ASK setting.
48 TABSTATE_HAS_ANY_ICON
= 1 << 2,
49 // There's at least one entry with ALLOWED setting.
50 TABSTATE_HAS_ANY_ALLOWED
= 1 << 3,
51 // There's at least one entry that doesn't match the saved setting.
52 TABSTATE_HAS_CHANGED
= 1 << 4,
55 // Maps ContentSetting to a set of hosts formatted for presentation.
56 typedef std::map
<ContentSetting
, std::set
<std::string
> >
57 FormattedHostsPerState
;
59 // Returns an (optional) |formatted_hosts_per_state| and a mask of TabState.
60 void GetDetailedInfo(FormattedHostsPerState
* formatted_hosts_per_state
,
61 unsigned int* tab_state_flags
) const;
64 std::string
GURLToFormattedHost(const GURL
& url
) const;
67 ContentSettingsType type_
;
71 DISALLOW_COPY_AND_ASSIGN(ContentSettingsUsagesState
);
74 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_USAGES_STATE_H_