OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This class gathers state related to a single user profile. | 5 // This class gathers state related to a single user profile. |
6 | 6 |
7 #ifndef CHROME_BROWSER_PROFILES_PROFILE_H_ | 7 #ifndef CHROME_BROWSER_PROFILES_PROFILE_H_ |
8 #define CHROME_BROWSER_PROFILES_PROFILE_H_ | 8 #define CHROME_BROWSER_PROFILES_PROFILE_H_ |
9 #pragma once | 9 #pragma once |
10 | 10 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 class VisitedLinkEventListener; | 95 class VisitedLinkEventListener; |
96 class VisitedLinkMaster; | 96 class VisitedLinkMaster; |
97 class WebDataService; | 97 class WebDataService; |
98 class WebKitContext; | 98 class WebKitContext; |
99 class PromoResourceService; | 99 class PromoResourceService; |
100 | 100 |
101 namespace net { | 101 namespace net { |
102 class URLRequestContextGetter; | 102 class URLRequestContextGetter; |
103 } | 103 } |
104 | 104 |
105 typedef intptr_t ProfileId; | |
106 | |
107 class Profile { | 105 class Profile { |
108 public: | 106 public: |
109 // Profile services are accessed with the following parameter. This parameter | 107 // Profile services are accessed with the following parameter. This parameter |
110 // defines what the caller plans to do with the service. | 108 // defines what the caller plans to do with the service. |
111 // The caller is responsible for not performing any operation that would | 109 // The caller is responsible for not performing any operation that would |
112 // result in persistent implicit records while using an OffTheRecord profile. | 110 // result in persistent implicit records while using an OffTheRecord profile. |
113 // This flag allows the profile to perform an additional check. | 111 // This flag allows the profile to perform an additional check. |
114 // | 112 // |
115 // It also gives us an opportunity to perform further checks in the future. We | 113 // It also gives us an opportunity to perform further checks in the future. We |
116 // could, for example, return an history service that only allow some specific | 114 // could, for example, return an history service that only allow some specific |
(...skipping 16 matching lines...) Expand all Loading... |
133 | 131 |
134 class Delegate { | 132 class Delegate { |
135 public: | 133 public: |
136 // Called when creation of the profile is finished. | 134 // Called when creation of the profile is finished. |
137 virtual void OnProfileCreated(Profile* profile, bool success) = 0; | 135 virtual void OnProfileCreated(Profile* profile, bool success) = 0; |
138 }; | 136 }; |
139 | 137 |
140 // Key used to bind profile to the widget with which it is associated. | 138 // Key used to bind profile to the widget with which it is associated. |
141 static const char* kProfileKey; | 139 static const char* kProfileKey; |
142 | 140 |
143 // Value that represents no profile Id. | |
144 static const ProfileId kInvalidProfileId; | |
145 | |
146 Profile(); | 141 Profile(); |
147 virtual ~Profile() {} | 142 virtual ~Profile() {} |
148 | 143 |
149 // Profile prefs are registered as soon as the prefs are loaded for the first | 144 // Profile prefs are registered as soon as the prefs are loaded for the first |
150 // time. | 145 // time. |
151 static void RegisterUserPrefs(PrefService* prefs); | 146 static void RegisterUserPrefs(PrefService* prefs); |
152 | 147 |
153 // Create a new profile given a path. | 148 // Create a new profile given a path. |
154 static Profile* CreateProfile(const FilePath& path); | 149 static Profile* CreateProfile(const FilePath& path); |
155 | 150 |
156 // Same as above, but uses async initialization. | 151 // Same as above, but uses async initialization. |
157 static Profile* CreateProfileAsync(const FilePath& path, | 152 static Profile* CreateProfileAsync(const FilePath& path, |
158 Delegate* delegate); | 153 Delegate* delegate); |
159 | 154 |
160 // Returns the request context for the "default" profile. This may be called | 155 // Returns the request context for the "default" profile. This may be called |
161 // from any thread. This CAN return NULL if a first request context has not | 156 // from any thread. This CAN return NULL if a first request context has not |
162 // yet been created. If necessary, listen on the UI thread for | 157 // yet been created. If necessary, listen on the UI thread for |
163 // NOTIFY_DEFAULT_REQUEST_CONTEXT_AVAILABLE. | 158 // NOTIFY_DEFAULT_REQUEST_CONTEXT_AVAILABLE. |
164 static net::URLRequestContextGetter* GetDefaultRequestContext(); | 159 static net::URLRequestContextGetter* GetDefaultRequestContext(); |
165 | 160 |
166 // Returns the name associated with this profile. This name is displayed in | 161 // Returns the name associated with this profile. This name is displayed in |
167 // the browser frame. | 162 // the browser frame. |
168 virtual std::string GetProfileName() = 0; | 163 virtual std::string GetProfileName() = 0; |
169 | 164 |
170 // Returns a unique Id that can be used to identify this profile at runtime. | |
171 // This Id is not persistent and will not survive a restart of the browser. | |
172 virtual ProfileId GetRuntimeId() = 0; | |
173 | |
174 // Returns the path of the directory where this profile's data is stored. | 165 // Returns the path of the directory where this profile's data is stored. |
175 virtual FilePath GetPath() = 0; | 166 virtual FilePath GetPath() = 0; |
176 | 167 |
177 // Return whether this profile is incognito. Default is false. | 168 // Return whether this profile is incognito. Default is false. |
178 virtual bool IsOffTheRecord() = 0; | 169 virtual bool IsOffTheRecord() = 0; |
179 | 170 |
180 // Return the incognito version of this profile. The returned pointer | 171 // Return the incognito version of this profile. The returned pointer |
181 // is owned by the receiving profile. If the receiving profile is off the | 172 // is owned by the receiving profile. If the receiving profile is off the |
182 // record, the same profile is returned. | 173 // record, the same profile is returned. |
183 virtual Profile* GetOffTheRecordProfile() = 0; | 174 virtual Profile* GetOffTheRecordProfile() = 0; |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 private: | 557 private: |
567 bool restored_last_session_; | 558 bool restored_last_session_; |
568 | 559 |
569 // Accessibility events will only be propagated when the pause | 560 // Accessibility events will only be propagated when the pause |
570 // level is zero. PauseAccessibilityEvents and ResumeAccessibilityEvents | 561 // level is zero. PauseAccessibilityEvents and ResumeAccessibilityEvents |
571 // increment and decrement the level, respectively, rather than set it to | 562 // increment and decrement the level, respectively, rather than set it to |
572 // true or false, so that calls can be nested. | 563 // true or false, so that calls can be nested. |
573 int accessibility_pause_level_; | 564 int accessibility_pause_level_; |
574 }; | 565 }; |
575 | 566 |
| 567 #if defined(COMPILER_GCC) |
| 568 namespace __gnu_cxx { |
| 569 |
| 570 template<> |
| 571 struct hash<Profile*> { |
| 572 std::size_t operator()(Profile* const& p) const { |
| 573 return reinterpret_cast<std::size_t>(p); |
| 574 } |
| 575 }; |
| 576 |
| 577 } // namespace __gnu_cxx |
| 578 #endif |
| 579 |
576 #endif // CHROME_BROWSER_PROFILES_PROFILE_H_ | 580 #endif // CHROME_BROWSER_PROFILES_PROFILE_H_ |
OLD | NEW |