| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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_GEOLOCATION_GEOLOCATION_SETTINGS_STATE_H_ | |
| 6 #define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_SETTINGS_STATE_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <set> | |
| 10 | |
| 11 #include "chrome/common/content_settings.h" | |
| 12 #include "url/gurl.h" | |
| 13 | |
| 14 class Profile; | |
| 15 | |
| 16 namespace content { | |
| 17 struct LoadCommittedDetails; | |
| 18 } | |
| 19 | |
| 20 // This class manages the geolocation state per tab, and provides information | |
| 21 // and presentation data about the geolocation usage. | |
| 22 class GeolocationSettingsState { | |
| 23 public: | |
| 24 explicit GeolocationSettingsState(Profile* profile); | |
| 25 virtual ~GeolocationSettingsState(); | |
| 26 | |
| 27 typedef std::map<GURL, ContentSetting> StateMap; | |
| 28 const StateMap& state_map() const { | |
| 29 return state_map_; | |
| 30 } | |
| 31 | |
| 32 // Sets the state for |requesting_origin|. | |
| 33 void OnGeolocationPermissionSet(const GURL& requesting_origin, bool allowed); | |
| 34 | |
| 35 // Delegated by WebContents to indicate a navigation has happened and we | |
| 36 // may need to clear our settings. | |
| 37 void DidNavigate(const content::LoadCommittedDetails& details); | |
| 38 | |
| 39 void ClearStateMap(); | |
| 40 | |
| 41 enum TabState { | |
| 42 TABSTATE_NONE = 0, | |
| 43 // There's at least one entry with non-default setting. | |
| 44 TABSTATE_HAS_EXCEPTION = 1 << 1, | |
| 45 // There's at least one entry with a non-ASK setting. | |
| 46 TABSTATE_HAS_ANY_ICON = 1 << 2, | |
| 47 // There's at least one entry with ALLOWED setting. | |
| 48 TABSTATE_HAS_ANY_ALLOWED = 1 << 3, | |
| 49 // There's at least one entry that doesn't match the saved setting. | |
| 50 TABSTATE_HAS_CHANGED = 1 << 4, | |
| 51 }; | |
| 52 | |
| 53 // Maps ContentSetting to a set of hosts formatted for presentation. | |
| 54 typedef std::map<ContentSetting, std::set<std::string> > | |
| 55 FormattedHostsPerState; | |
| 56 | |
| 57 // Returns an (optional) |formatted_hosts_per_state| and a mask of TabState. | |
| 58 void GetDetailedInfo(FormattedHostsPerState* formatted_hosts_per_state, | |
| 59 unsigned int* tab_state_flags) const; | |
| 60 | |
| 61 private: | |
| 62 std::string GURLToFormattedHost(const GURL& url) const; | |
| 63 | |
| 64 Profile* profile_; | |
| 65 StateMap state_map_; | |
| 66 GURL embedder_url_; | |
| 67 | |
| 68 DISALLOW_COPY_AND_ASSIGN(GeolocationSettingsState); | |
| 69 }; | |
| 70 | |
| 71 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_SETTINGS_STATE_H_ | |
| OLD | NEW |