| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_PROFILE_H_ | 7 #ifndef CHROME_BROWSER_PROFILE_H_ |
| 8 #define CHROME_BROWSER_PROFILE_H_ | 8 #define CHROME_BROWSER_PROFILE_H_ |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 15 #include "base/scoped_ptr.h" | 15 #include "base/scoped_ptr.h" |
| 16 #include "base/timer.h" | 16 #include "base/timer.h" |
| 17 #include "chrome/browser/web_resource/web_resource_service.h" | 17 #include "chrome/browser/web_resource/web_resource_service.h" |
| 18 #include "chrome/common/notification_registrar.h" | 18 #include "chrome/common/notification_registrar.h" |
| 19 | 19 |
| 20 #if defined(OS_CHROMEOS) | 20 #if defined(OS_CHROMEOS) |
| 21 #include "chrome/browser/chromeos/preferences.h" | 21 #include "chrome/browser/chromeos/preferences.h" |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 namespace net { | 24 namespace net { |
| 25 class StrictTransportSecurityState; | 25 class StrictTransportSecurityState; |
| 26 class SSLConfigService; | 26 class SSLConfigService; |
| 27 } | 27 } |
| 28 |
| 28 class Blacklist; | 29 class Blacklist; |
| 29 class BookmarkModel; | 30 class BookmarkModel; |
| 30 class BrowserThemeProvider; | 31 class BrowserThemeProvider; |
| 31 class ChromeAppCacheService; | 32 class ChromeURLRequestContextGetter; |
| 32 class ChromeURLRequestContext; | |
| 33 class DesktopNotificationService; | 33 class DesktopNotificationService; |
| 34 class DownloadManager; | 34 class DownloadManager; |
| 35 class Extension; | 35 class Extension; |
| 36 class ExtensionDevToolsManager; | 36 class ExtensionDevToolsManager; |
| 37 class ExtensionProcessManager; | 37 class ExtensionProcessManager; |
| 38 class ExtensionMessageService; | 38 class ExtensionMessageService; |
| 39 class ExtensionsService; | 39 class ExtensionsService; |
| 40 class FaviconService; | 40 class FaviconService; |
| 41 class HistoryService; | 41 class HistoryService; |
| 42 class NavigationController; | 42 class NavigationController; |
| 43 class PasswordStore; | 43 class PasswordStore; |
| 44 class PrefService; | 44 class PrefService; |
| 45 class ProfileSyncService; | 45 class ProfileSyncService; |
| 46 class SessionService; | 46 class SessionService; |
| 47 class SpellChecker; | 47 class SpellChecker; |
| 48 class SSLConfigServiceManager; | 48 class SSLConfigServiceManager; |
| 49 class SSLHostState; | 49 class SSLHostState; |
| 50 class StrictTransportSecurityPersister; | 50 class StrictTransportSecurityPersister; |
| 51 class SQLitePersistentCookieStore; | 51 class SQLitePersistentCookieStore; |
| 52 class TabRestoreService; | 52 class TabRestoreService; |
| 53 class TemplateURLFetcher; | 53 class TemplateURLFetcher; |
| 54 class TemplateURLModel; | 54 class TemplateURLModel; |
| 55 class ThemeProvider; | 55 class ThemeProvider; |
| 56 class ThumbnailStore; | 56 class ThumbnailStore; |
| 57 class URLRequestContext; | 57 class URLRequestContextGetter; |
| 58 class UserScriptMaster; | 58 class UserScriptMaster; |
| 59 class VisitedLinkMaster; | 59 class VisitedLinkMaster; |
| 60 class VisitedLinkEventListener; | 60 class VisitedLinkEventListener; |
| 61 class WebDataService; | 61 class WebDataService; |
| 62 class WebKitContext; | 62 class WebKitContext; |
| 63 | 63 |
| 64 typedef intptr_t ProfileId; | 64 typedef intptr_t ProfileId; |
| 65 | 65 |
| 66 class Profile { | 66 class Profile { |
| 67 public: | 67 public: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 // Create a new profile given a path. | 103 // Create a new profile given a path. |
| 104 static Profile* CreateProfile(const FilePath& path); | 104 static Profile* CreateProfile(const FilePath& path); |
| 105 | 105 |
| 106 // Returns the request context for the "default" profile. This may be called | 106 // Returns the request context for the "default" profile. This may be called |
| 107 // from any thread. This CAN return NULL if a first request context has not | 107 // from any thread. This CAN return NULL if a first request context has not |
| 108 // yet been created. If necessary, listen on the UI thread for | 108 // yet been created. If necessary, listen on the UI thread for |
| 109 // NOTIFY_DEFAULT_REQUEST_CONTEXT_AVAILABLE. | 109 // NOTIFY_DEFAULT_REQUEST_CONTEXT_AVAILABLE. |
| 110 // | 110 // |
| 111 // The returned object is ref'd by the profile. Callers who AddRef() it (to | 111 // The returned object is ref'd by the profile. Callers who AddRef() it (to |
| 112 // keep it alive longer than the profile) must Release() it on the I/O thread. | 112 // keep it alive longer than the profile) must Release() it on the I/O thread. |
| 113 static URLRequestContext* GetDefaultRequestContext(); | 113 static URLRequestContextGetter* GetDefaultRequestContext(); |
| 114 | 114 |
| 115 // Returns a unique Id that can be used to identify this profile at runtime. | 115 // Returns a unique Id that can be used to identify this profile at runtime. |
| 116 // This Id is not persistent and will not survive a restart of the browser. | 116 // This Id is not persistent and will not survive a restart of the browser. |
| 117 virtual ProfileId GetRuntimeId() = 0; | 117 virtual ProfileId GetRuntimeId() = 0; |
| 118 | 118 |
| 119 // Returns the path of the directory where this profile's data is stored. | 119 // Returns the path of the directory where this profile's data is stored. |
| 120 virtual FilePath GetPath() = 0; | 120 virtual FilePath GetPath() = 0; |
| 121 | 121 |
| 122 // Return whether this profile is off the record. Default is false. | 122 // Return whether this profile is off the record. Default is false. |
| 123 virtual bool IsOffTheRecord() = 0; | 123 virtual bool IsOffTheRecord() = 0; |
| 124 | 124 |
| 125 // Return the off the record version of this profile. The returned pointer | 125 // Return the off the record version of this profile. The returned pointer |
| 126 // is owned by the receiving profile. If the receiving profile is off the | 126 // is owned by the receiving profile. If the receiving profile is off the |
| 127 // record, the same profile is returned. | 127 // record, the same profile is returned. |
| 128 virtual Profile* GetOffTheRecordProfile() = 0; | 128 virtual Profile* GetOffTheRecordProfile() = 0; |
| 129 | 129 |
| 130 // Destroys the off the record profile. | 130 // Destroys the off the record profile. |
| 131 virtual void DestroyOffTheRecordProfile() = 0; | 131 virtual void DestroyOffTheRecordProfile() = 0; |
| 132 | 132 |
| 133 // Return the original "recording" profile. This method returns this if the | 133 // Return the original "recording" profile. This method returns this if the |
| 134 // profile is not off the record. | 134 // profile is not off the record. |
| 135 virtual Profile* GetOriginalProfile() = 0; | 135 virtual Profile* GetOriginalProfile() = 0; |
| 136 | 136 |
| 137 // Retrieves a pointer to the AppCacheService for this profile. | |
| 138 // Chrome request contexts associated with this profile also have | |
| 139 // a reference to this instance. | |
| 140 virtual ChromeAppCacheService* GetAppCacheService() = 0; | |
| 141 | |
| 142 // Retrieves a pointer to the VisitedLinkMaster associated with this | 137 // Retrieves a pointer to the VisitedLinkMaster associated with this |
| 143 // profile. The VisitedLinkMaster is lazily created the first time | 138 // profile. The VisitedLinkMaster is lazily created the first time |
| 144 // that this method is called. | 139 // that this method is called. |
| 145 virtual VisitedLinkMaster* GetVisitedLinkMaster() = 0; | 140 virtual VisitedLinkMaster* GetVisitedLinkMaster() = 0; |
| 146 | 141 |
| 147 // Retrieves a pointer to the ExtensionsService associated with this | 142 // Retrieves a pointer to the ExtensionsService associated with this |
| 148 // profile. The ExtensionsService is created at startup. | 143 // profile. The ExtensionsService is created at startup. |
| 149 virtual ExtensionsService* GetExtensionsService() = 0; | 144 virtual ExtensionsService* GetExtensionsService() = 0; |
| 150 | 145 |
| 151 // Retrieves a pointer to the UserScriptMaster associated with this | 146 // Retrieves a pointer to the UserScriptMaster associated with this |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 virtual ThemeProvider* GetThemeProvider() = 0; | 249 virtual ThemeProvider* GetThemeProvider() = 0; |
| 255 | 250 |
| 256 virtual ThumbnailStore* GetThumbnailStore() = 0; | 251 virtual ThumbnailStore* GetThumbnailStore() = 0; |
| 257 | 252 |
| 258 // Returns the request context information associated with this profile. Call | 253 // Returns the request context information associated with this profile. Call |
| 259 // this only on the UI thread, since it can send notifications that should | 254 // this only on the UI thread, since it can send notifications that should |
| 260 // happen on the UI thread. | 255 // happen on the UI thread. |
| 261 // | 256 // |
| 262 // The returned object is ref'd by the profile. Callers who AddRef() it (to | 257 // The returned object is ref'd by the profile. Callers who AddRef() it (to |
| 263 // keep it alive longer than the profile) must Release() it on the I/O thread. | 258 // keep it alive longer than the profile) must Release() it on the I/O thread. |
| 264 virtual URLRequestContext* GetRequestContext() = 0; | 259 virtual URLRequestContextGetter* GetRequestContext() = 0; |
| 265 | 260 |
| 266 // Returns the request context for media resources asociated with this | 261 // Returns the request context for media resources asociated with this |
| 267 // profile. | 262 // profile. |
| 268 virtual URLRequestContext* GetRequestContextForMedia() = 0; | 263 virtual URLRequestContextGetter* GetRequestContextForMedia() = 0; |
| 269 | 264 |
| 270 // Returns the request context used for extension-related requests. This | 265 // Returns the request context used for extension-related requests. This |
| 271 // is only used for a separate cookie store currently. | 266 // is only used for a separate cookie store currently. |
| 272 virtual URLRequestContext* GetRequestContextForExtensions() = 0; | 267 virtual URLRequestContextGetter* GetRequestContextForExtensions() = 0; |
| 273 | 268 |
| 274 // Returns the SSLConfigService for this profile. | 269 // Returns the SSLConfigService for this profile. |
| 275 virtual net::SSLConfigService* GetSSLConfigService() = 0; | 270 virtual net::SSLConfigService* GetSSLConfigService() = 0; |
| 276 | 271 |
| 277 // Returns the Privacy Blaclist for this profile. | 272 // Returns the Privacy Blaclist for this profile. |
| 278 virtual Blacklist* GetBlacklist() = 0; | 273 virtual Blacklist* GetBlacklist() = 0; |
| 279 | 274 |
| 280 // Returns the session service for this profile. This may return NULL. If | 275 // Returns the session service for this profile. This may return NULL. If |
| 281 // this profile supports a session service (it isn't off the record), and | 276 // this profile supports a session service (it isn't off the record), and |
| 282 // the session service hasn't yet been created, this forces creation of | 277 // the session service hasn't yet been created, this forces creation of |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 // that it can be invoked when the user logs out/powers down (WM_ENDSESSION). | 348 // that it can be invoked when the user logs out/powers down (WM_ENDSESSION). |
| 354 virtual void MarkAsCleanShutdown() = 0; | 349 virtual void MarkAsCleanShutdown() = 0; |
| 355 | 350 |
| 356 virtual void InitExtensions() = 0; | 351 virtual void InitExtensions() = 0; |
| 357 | 352 |
| 358 // Start up service that gathers data from web resource feeds. | 353 // Start up service that gathers data from web resource feeds. |
| 359 virtual void InitWebResources() = 0; | 354 virtual void InitWebResources() = 0; |
| 360 | 355 |
| 361 #ifdef UNIT_TEST | 356 #ifdef UNIT_TEST |
| 362 // Use with caution. GetDefaultRequestContext may be called on any thread! | 357 // Use with caution. GetDefaultRequestContext may be called on any thread! |
| 363 static void set_default_request_context(URLRequestContext* c) { | 358 static void set_default_request_context(URLRequestContextGetter* c) { |
| 364 default_request_context_ = c; | 359 default_request_context_ = c; |
| 365 } | 360 } |
| 366 #endif | 361 #endif |
| 367 | 362 |
| 368 // Did the user restore the last session? This is set by SessionRestore. | 363 // Did the user restore the last session? This is set by SessionRestore. |
| 369 void set_restored_last_session(bool restored_last_session) { | 364 void set_restored_last_session(bool restored_last_session) { |
| 370 restored_last_session_ = restored_last_session; | 365 restored_last_session_ = restored_last_session; |
| 371 } | 366 } |
| 372 bool restored_last_session() const { | 367 bool restored_last_session() const { |
| 373 return restored_last_session_; | 368 return restored_last_session_; |
| 374 } | 369 } |
| 375 | 370 |
| 376 protected: | 371 protected: |
| 377 static URLRequestContext* default_request_context_; | 372 static URLRequestContextGetter* default_request_context_; |
| 378 | 373 |
| 379 private: | 374 private: |
| 380 bool restored_last_session_; | 375 bool restored_last_session_; |
| 381 }; | 376 }; |
| 382 | 377 |
| 383 class OffTheRecordProfileImpl; | 378 class OffTheRecordProfileImpl; |
| 384 | 379 |
| 385 // The default profile implementation. | 380 // The default profile implementation. |
| 386 class ProfileImpl : public Profile, | 381 class ProfileImpl : public Profile, |
| 387 public NotificationObserver { | 382 public NotificationObserver { |
| 388 public: | 383 public: |
| 389 virtual ~ProfileImpl(); | 384 virtual ~ProfileImpl(); |
| 390 | 385 |
| 391 // Profile implementation. | 386 // Profile implementation. |
| 392 virtual ProfileId GetRuntimeId(); | 387 virtual ProfileId GetRuntimeId(); |
| 393 virtual FilePath GetPath(); | 388 virtual FilePath GetPath(); |
| 394 virtual bool IsOffTheRecord(); | 389 virtual bool IsOffTheRecord(); |
| 395 virtual Profile* GetOffTheRecordProfile(); | 390 virtual Profile* GetOffTheRecordProfile(); |
| 396 virtual void DestroyOffTheRecordProfile(); | 391 virtual void DestroyOffTheRecordProfile(); |
| 397 virtual Profile* GetOriginalProfile(); | 392 virtual Profile* GetOriginalProfile(); |
| 398 virtual ChromeAppCacheService* GetAppCacheService(); | |
| 399 virtual VisitedLinkMaster* GetVisitedLinkMaster(); | 393 virtual VisitedLinkMaster* GetVisitedLinkMaster(); |
| 400 virtual UserScriptMaster* GetUserScriptMaster(); | 394 virtual UserScriptMaster* GetUserScriptMaster(); |
| 401 virtual SSLHostState* GetSSLHostState(); | 395 virtual SSLHostState* GetSSLHostState(); |
| 402 virtual net::StrictTransportSecurityState* GetStrictTransportSecurityState(); | 396 virtual net::StrictTransportSecurityState* GetStrictTransportSecurityState(); |
| 403 virtual ExtensionsService* GetExtensionsService(); | 397 virtual ExtensionsService* GetExtensionsService(); |
| 404 virtual ExtensionDevToolsManager* GetExtensionDevToolsManager(); | 398 virtual ExtensionDevToolsManager* GetExtensionDevToolsManager(); |
| 405 virtual ExtensionProcessManager* GetExtensionProcessManager(); | 399 virtual ExtensionProcessManager* GetExtensionProcessManager(); |
| 406 virtual ExtensionMessageService* GetExtensionMessageService(); | 400 virtual ExtensionMessageService* GetExtensionMessageService(); |
| 407 virtual FaviconService* GetFaviconService(ServiceAccessType sat); | 401 virtual FaviconService* GetFaviconService(ServiceAccessType sat); |
| 408 virtual HistoryService* GetHistoryService(ServiceAccessType sat); | 402 virtual HistoryService* GetHistoryService(ServiceAccessType sat); |
| 409 virtual HistoryService* GetHistoryServiceWithoutCreating(); | 403 virtual HistoryService* GetHistoryServiceWithoutCreating(); |
| 410 virtual WebDataService* GetWebDataService(ServiceAccessType sat); | 404 virtual WebDataService* GetWebDataService(ServiceAccessType sat); |
| 411 virtual PasswordStore* GetPasswordStore(ServiceAccessType sat); | 405 virtual PasswordStore* GetPasswordStore(ServiceAccessType sat); |
| 412 virtual PrefService* GetPrefs(); | 406 virtual PrefService* GetPrefs(); |
| 413 virtual TemplateURLModel* GetTemplateURLModel(); | 407 virtual TemplateURLModel* GetTemplateURLModel(); |
| 414 virtual TemplateURLFetcher* GetTemplateURLFetcher(); | 408 virtual TemplateURLFetcher* GetTemplateURLFetcher(); |
| 415 virtual DownloadManager* GetDownloadManager(); | 409 virtual DownloadManager* GetDownloadManager(); |
| 416 virtual void InitThemes(); | 410 virtual void InitThemes(); |
| 417 virtual void SetTheme(Extension* extension); | 411 virtual void SetTheme(Extension* extension); |
| 418 virtual void SetNativeTheme(); | 412 virtual void SetNativeTheme(); |
| 419 virtual void ClearTheme(); | 413 virtual void ClearTheme(); |
| 420 virtual Extension* GetTheme(); | 414 virtual Extension* GetTheme(); |
| 421 virtual ThemeProvider* GetThemeProvider(); | 415 virtual ThemeProvider* GetThemeProvider(); |
| 422 virtual ThumbnailStore* GetThumbnailStore(); | 416 virtual ThumbnailStore* GetThumbnailStore(); |
| 423 virtual bool HasCreatedDownloadManager() const; | 417 virtual bool HasCreatedDownloadManager() const; |
| 424 virtual URLRequestContext* GetRequestContext(); | 418 virtual URLRequestContextGetter* GetRequestContext(); |
| 425 virtual URLRequestContext* GetRequestContextForMedia(); | 419 virtual URLRequestContextGetter* GetRequestContextForMedia(); |
| 426 virtual URLRequestContext* GetRequestContextForExtensions(); | 420 virtual URLRequestContextGetter* GetRequestContextForExtensions(); |
| 427 virtual net::SSLConfigService* GetSSLConfigService(); | 421 virtual net::SSLConfigService* GetSSLConfigService(); |
| 428 virtual Blacklist* GetBlacklist(); | 422 virtual Blacklist* GetBlacklist(); |
| 429 virtual SessionService* GetSessionService(); | 423 virtual SessionService* GetSessionService(); |
| 430 virtual void ShutdownSessionService(); | 424 virtual void ShutdownSessionService(); |
| 431 virtual bool HasSessionService() const; | 425 virtual bool HasSessionService() const; |
| 432 virtual std::wstring GetName(); | 426 virtual std::wstring GetName(); |
| 433 virtual void SetName(const std::wstring& name); | 427 virtual void SetName(const std::wstring& name); |
| 434 virtual std::wstring GetID(); | 428 virtual std::wstring GetID(); |
| 435 virtual void SetID(const std::wstring& id); | 429 virtual void SetID(const std::wstring& id); |
| 436 virtual bool DidLastSessionExitCleanly(); | 430 virtual bool DidLastSessionExitCleanly(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 scoped_refptr<ThumbnailStore> thumbnail_store_; | 492 scoped_refptr<ThumbnailStore> thumbnail_store_; |
| 499 scoped_ptr<TemplateURLFetcher> template_url_fetcher_; | 493 scoped_ptr<TemplateURLFetcher> template_url_fetcher_; |
| 500 scoped_ptr<TemplateURLModel> template_url_model_; | 494 scoped_ptr<TemplateURLModel> template_url_model_; |
| 501 scoped_ptr<BookmarkModel> bookmark_bar_model_; | 495 scoped_ptr<BookmarkModel> bookmark_bar_model_; |
| 502 scoped_refptr<WebResourceService> web_resource_service_; | 496 scoped_refptr<WebResourceService> web_resource_service_; |
| 503 | 497 |
| 504 #if defined(BROWSER_SYNC) | 498 #if defined(BROWSER_SYNC) |
| 505 scoped_ptr<ProfileSyncService> sync_service_; | 499 scoped_ptr<ProfileSyncService> sync_service_; |
| 506 #endif | 500 #endif |
| 507 | 501 |
| 508 ChromeAppCacheService* appcache_service_; | 502 ChromeURLRequestContextGetter* request_context_; |
| 509 | 503 |
| 510 ChromeURLRequestContext* request_context_; | 504 ChromeURLRequestContextGetter* media_request_context_; |
| 511 | 505 |
| 512 ChromeURLRequestContext* media_request_context_; | 506 ChromeURLRequestContextGetter* extensions_request_context_; |
| 513 | |
| 514 ChromeURLRequestContext* extensions_request_context_; | |
| 515 | 507 |
| 516 scoped_ptr<SSLConfigServiceManager> ssl_config_service_manager_; | 508 scoped_ptr<SSLConfigServiceManager> ssl_config_service_manager_; |
| 517 | 509 |
| 518 Blacklist* blacklist_; | 510 Blacklist* blacklist_; |
| 519 | 511 |
| 520 scoped_refptr<DownloadManager> download_manager_; | 512 scoped_refptr<DownloadManager> download_manager_; |
| 521 scoped_refptr<HistoryService> history_service_; | 513 scoped_refptr<HistoryService> history_service_; |
| 522 scoped_refptr<FaviconService> favicon_service_; | 514 scoped_refptr<FaviconService> favicon_service_; |
| 523 scoped_refptr<WebDataService> web_data_service_; | 515 scoped_refptr<WebDataService> web_data_service_; |
| 524 scoped_refptr<PasswordStore> password_store_; | 516 scoped_refptr<PasswordStore> password_store_; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 }; | 552 }; |
| 561 | 553 |
| 562 // This struct is used to pass the spellchecker object through the notification | 554 // This struct is used to pass the spellchecker object through the notification |
| 563 // SPELLCHECKER_REINITIALIZED. This is used as the details for the notification | 555 // SPELLCHECKER_REINITIALIZED. This is used as the details for the notification |
| 564 // service. | 556 // service. |
| 565 struct SpellcheckerReinitializedDetails { | 557 struct SpellcheckerReinitializedDetails { |
| 566 scoped_refptr<SpellChecker> spellchecker; | 558 scoped_refptr<SpellChecker> spellchecker; |
| 567 }; | 559 }; |
| 568 | 560 |
| 569 #endif // CHROME_BROWSER_PROFILE_H_ | 561 #endif // CHROME_BROWSER_PROFILE_H_ |
| OLD | NEW |