Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / content_settings / content_settings_usages_state.h
blobe137620183b5ea92b82114c358e1464aee7bb969
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 "chrome/common/content_settings.h"
12 #include "chrome/common/content_settings_types.h"
13 #include "url/gurl.h"
15 class Profile;
17 namespace content {
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 {
25 public:
26 ContentSettingsUsagesState(Profile* profile, ContentSettingsType type);
27 virtual ~ContentSettingsUsagesState();
29 typedef std::map<GURL, ContentSetting> StateMap;
30 const StateMap& state_map() const {
31 return state_map_;
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);
41 void ClearStateMap();
43 enum TabState {
44 TABSTATE_NONE = 0,
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;
63 private:
64 std::string GURLToFormattedHost(const GURL& url) const;
66 Profile* profile_;
67 ContentSettingsType type_;
68 StateMap state_map_;
69 GURL embedder_url_;
71 DISALLOW_COPY_AND_ASSIGN(ContentSettingsUsagesState);
74 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_USAGES_STATE_H_