| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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 // This class gathers state related to a single user profile. | |
| 6 | |
| 7 #ifndef CHROME_BROWSER_PROFILE_IMPL_H_ | |
| 8 #define CHROME_BROWSER_PROFILE_IMPL_H_ | |
| 9 #pragma once | |
| 10 | |
| 11 #include "base/file_path.h" | |
| 12 #include "base/ref_counted.h" | |
| 13 #include "base/scoped_ptr.h" | |
| 14 #include "base/timer.h" | |
| 15 #include "chrome/browser/profile.h" | |
| 16 #include "chrome/browser/prefs/pref_change_registrar.h" | |
| 17 #include "chrome/browser/spellcheck_host_observer.h" | |
| 18 #include "chrome/common/notification_observer.h" | |
| 19 #include "chrome/common/notification_registrar.h" | |
| 20 | |
| 21 class PrefService; | |
| 22 | |
| 23 #if defined(OS_CHROMEOS) | |
| 24 namespace chromeos { | |
| 25 class Preferences; | |
| 26 } | |
| 27 #endif | |
| 28 | |
| 29 class NetPrefObserver; | |
| 30 | |
| 31 // The default profile implementation. | |
| 32 class ProfileImpl : public Profile, | |
| 33 public SpellCheckHostObserver, | |
| 34 public NotificationObserver { | |
| 35 public: | |
| 36 virtual ~ProfileImpl(); | |
| 37 | |
| 38 static void RegisterUserPrefs(PrefService* prefs); | |
| 39 | |
| 40 // Profile implementation. | |
| 41 virtual ProfileId GetRuntimeId(); | |
| 42 virtual FilePath GetPath(); | |
| 43 virtual bool IsOffTheRecord(); | |
| 44 virtual Profile* GetOffTheRecordProfile(); | |
| 45 virtual void DestroyOffTheRecordProfile(); | |
| 46 virtual bool HasOffTheRecordProfile(); | |
| 47 virtual Profile* GetOriginalProfile(); | |
| 48 virtual ChromeAppCacheService* GetAppCacheService(); | |
| 49 virtual webkit_database::DatabaseTracker* GetDatabaseTracker(); | |
| 50 virtual history::TopSites* GetTopSites(); | |
| 51 virtual history::TopSites* GetTopSitesWithoutCreating(); | |
| 52 virtual VisitedLinkMaster* GetVisitedLinkMaster(); | |
| 53 virtual UserScriptMaster* GetUserScriptMaster(); | |
| 54 virtual SSLHostState* GetSSLHostState(); | |
| 55 virtual net::TransportSecurityState* GetTransportSecurityState(); | |
| 56 virtual ExtensionsService* GetExtensionsService(); | |
| 57 virtual ExtensionDevToolsManager* GetExtensionDevToolsManager(); | |
| 58 virtual ExtensionProcessManager* GetExtensionProcessManager(); | |
| 59 virtual ExtensionMessageService* GetExtensionMessageService(); | |
| 60 virtual ExtensionEventRouter* GetExtensionEventRouter(); | |
| 61 virtual FaviconService* GetFaviconService(ServiceAccessType sat); | |
| 62 virtual HistoryService* GetHistoryService(ServiceAccessType sat); | |
| 63 virtual HistoryService* GetHistoryServiceWithoutCreating(); | |
| 64 virtual AutocompleteClassifier* GetAutocompleteClassifier(); | |
| 65 virtual WebDataService* GetWebDataService(ServiceAccessType sat); | |
| 66 virtual WebDataService* GetWebDataServiceWithoutCreating(); | |
| 67 virtual PasswordStore* GetPasswordStore(ServiceAccessType sat); | |
| 68 virtual PrefService* GetPrefs(); | |
| 69 virtual TemplateURLModel* GetTemplateURLModel(); | |
| 70 virtual TemplateURLFetcher* GetTemplateURLFetcher(); | |
| 71 virtual DownloadManager* GetDownloadManager(); | |
| 72 virtual PersonalDataManager* GetPersonalDataManager(); | |
| 73 virtual BrowserFileSystemContext* GetFileSystemContext(); | |
| 74 virtual void InitThemes(); | |
| 75 virtual void SetTheme(const Extension* extension); | |
| 76 virtual void SetNativeTheme(); | |
| 77 virtual void ClearTheme(); | |
| 78 virtual const Extension* GetTheme(); | |
| 79 virtual BrowserThemeProvider* GetThemeProvider(); | |
| 80 virtual bool HasCreatedDownloadManager() const; | |
| 81 virtual URLRequestContextGetter* GetRequestContext(); | |
| 82 virtual URLRequestContextGetter* GetRequestContextForMedia(); | |
| 83 virtual URLRequestContextGetter* GetRequestContextForExtensions(); | |
| 84 virtual void RegisterExtensionWithRequestContexts(const Extension* extension); | |
| 85 virtual void UnregisterExtensionWithRequestContexts( | |
| 86 const Extension* extension); | |
| 87 virtual net::SSLConfigService* GetSSLConfigService(); | |
| 88 virtual HostContentSettingsMap* GetHostContentSettingsMap(); | |
| 89 virtual HostZoomMap* GetHostZoomMap(); | |
| 90 virtual GeolocationContentSettingsMap* GetGeolocationContentSettingsMap(); | |
| 91 virtual GeolocationPermissionContext* GetGeolocationPermissionContext(); | |
| 92 virtual UserStyleSheetWatcher* GetUserStyleSheetWatcher(); | |
| 93 virtual FindBarState* GetFindBarState(); | |
| 94 virtual SessionService* GetSessionService(); | |
| 95 virtual void ShutdownSessionService(); | |
| 96 virtual bool HasSessionService() const; | |
| 97 virtual bool HasProfileSyncService() const; | |
| 98 virtual bool DidLastSessionExitCleanly(); | |
| 99 virtual BookmarkModel* GetBookmarkModel(); | |
| 100 virtual bool IsSameProfile(Profile* profile); | |
| 101 virtual base::Time GetStartTime() const; | |
| 102 virtual TabRestoreService* GetTabRestoreService(); | |
| 103 virtual void ResetTabRestoreService(); | |
| 104 virtual SpellCheckHost* GetSpellCheckHost(); | |
| 105 virtual void ReinitializeSpellCheckHost(bool force); | |
| 106 virtual WebKitContext* GetWebKitContext(); | |
| 107 virtual DesktopNotificationService* GetDesktopNotificationService(); | |
| 108 virtual BackgroundContentsService* GetBackgroundContentsService() const; | |
| 109 virtual StatusTray* GetStatusTray(); | |
| 110 virtual void MarkAsCleanShutdown(); | |
| 111 virtual void InitExtensions(); | |
| 112 virtual void InitWebResources(); | |
| 113 virtual NTPResourceCache* GetNTPResourceCache(); | |
| 114 virtual FilePath last_selected_directory(); | |
| 115 virtual void set_last_selected_directory(const FilePath& path); | |
| 116 virtual ProfileSyncService* GetProfileSyncService(); | |
| 117 virtual ProfileSyncService* GetProfileSyncService( | |
| 118 const std::string& cros_user); | |
| 119 virtual TokenService* GetTokenService(); | |
| 120 void InitSyncService(const std::string& cros_user); | |
| 121 virtual CloudPrintProxyService* GetCloudPrintProxyService(); | |
| 122 void InitCloudPrintProxyService(); | |
| 123 virtual ChromeBlobStorageContext* GetBlobStorageContext(); | |
| 124 virtual ExtensionInfoMap* GetExtensionInfoMap(); | |
| 125 virtual PromoCounter* GetInstantPromoCounter(); | |
| 126 virtual BrowserSignin* GetBrowserSignin(); | |
| 127 virtual policy::ProfilePolicyContext* GetPolicyContext(); | |
| 128 | |
| 129 #if defined(OS_CHROMEOS) | |
| 130 virtual chromeos::ProxyConfigServiceImpl* GetChromeOSProxyConfigServiceImpl(); | |
| 131 virtual void SetupChromeOSEnterpriseExtensionObserver(); | |
| 132 #endif // defined(OS_CHROMEOS) | |
| 133 | |
| 134 virtual PrefProxyConfigTracker* GetProxyConfigTracker(); | |
| 135 | |
| 136 // NotificationObserver implementation. | |
| 137 virtual void Observe(NotificationType type, | |
| 138 const NotificationSource& source, | |
| 139 const NotificationDetails& details); | |
| 140 | |
| 141 // SpellCheckHostObserver implementation. | |
| 142 virtual void SpellCheckHostInitialized(); | |
| 143 | |
| 144 private: | |
| 145 friend class Profile; | |
| 146 | |
| 147 explicit ProfileImpl(const FilePath& path); | |
| 148 | |
| 149 void CreateWebDataService(); | |
| 150 FilePath GetPrefFilePath(); | |
| 151 | |
| 152 void CreatePasswordStore(); | |
| 153 | |
| 154 void StopCreateSessionServiceTimer(); | |
| 155 | |
| 156 void EnsureRequestContextCreated() { | |
| 157 GetRequestContext(); | |
| 158 } | |
| 159 | |
| 160 void EnsureSessionServiceCreated() { | |
| 161 GetSessionService(); | |
| 162 } | |
| 163 | |
| 164 void RegisterComponentExtensions(); | |
| 165 void InstallDefaultApps(); | |
| 166 | |
| 167 NotificationRegistrar registrar_; | |
| 168 PrefChangeRegistrar pref_change_registrar_; | |
| 169 | |
| 170 FilePath path_; | |
| 171 FilePath base_cache_path_; | |
| 172 scoped_ptr<VisitedLinkEventListener> visited_link_event_listener_; | |
| 173 scoped_ptr<VisitedLinkMaster> visited_link_master_; | |
| 174 scoped_refptr<ExtensionsService> extensions_service_; | |
| 175 scoped_refptr<UserScriptMaster> user_script_master_; | |
| 176 scoped_refptr<ExtensionDevToolsManager> extension_devtools_manager_; | |
| 177 scoped_ptr<ExtensionProcessManager> extension_process_manager_; | |
| 178 scoped_refptr<ExtensionMessageService> extension_message_service_; | |
| 179 scoped_ptr<ExtensionEventRouter> extension_event_router_; | |
| 180 scoped_ptr<SSLHostState> ssl_host_state_; | |
| 181 scoped_refptr<net::TransportSecurityState> | |
| 182 transport_security_state_; | |
| 183 scoped_refptr<TransportSecurityPersister> | |
| 184 transport_security_persister_; | |
| 185 scoped_ptr<policy::ProfilePolicyContext> profile_policy_context_; | |
| 186 scoped_ptr<PrefService> prefs_; | |
| 187 scoped_ptr<NetPrefObserver> net_pref_observer_; | |
| 188 scoped_ptr<TemplateURLFetcher> template_url_fetcher_; | |
| 189 scoped_ptr<TemplateURLModel> template_url_model_; | |
| 190 scoped_ptr<BookmarkModel> bookmark_bar_model_; | |
| 191 scoped_refptr<WebResourceService> web_resource_service_; | |
| 192 scoped_ptr<NTPResourceCache> ntp_resource_cache_; | |
| 193 | |
| 194 scoped_ptr<TokenService> token_service_; | |
| 195 scoped_ptr<ProfileSyncFactory> profile_sync_factory_; | |
| 196 scoped_ptr<ProfileSyncService> sync_service_; | |
| 197 scoped_refptr<CloudPrintProxyService> cloud_print_proxy_service_; | |
| 198 | |
| 199 scoped_refptr<ChromeURLRequestContextGetter> request_context_; | |
| 200 | |
| 201 scoped_refptr<ChromeURLRequestContextGetter> media_request_context_; | |
| 202 | |
| 203 scoped_refptr<ChromeURLRequestContextGetter> extensions_request_context_; | |
| 204 | |
| 205 scoped_ptr<SSLConfigServiceManager> ssl_config_service_manager_; | |
| 206 | |
| 207 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; | |
| 208 scoped_refptr<HostZoomMap> host_zoom_map_; | |
| 209 scoped_refptr<GeolocationContentSettingsMap> | |
| 210 geolocation_content_settings_map_; | |
| 211 scoped_refptr<GeolocationPermissionContext> | |
| 212 geolocation_permission_context_; | |
| 213 scoped_refptr<UserStyleSheetWatcher> user_style_sheet_watcher_; | |
| 214 scoped_ptr<FindBarState> find_bar_state_; | |
| 215 scoped_refptr<DownloadManager> download_manager_; | |
| 216 scoped_refptr<HistoryService> history_service_; | |
| 217 scoped_refptr<FaviconService> favicon_service_; | |
| 218 scoped_ptr<AutocompleteClassifier> autocomplete_classifier_; | |
| 219 scoped_refptr<WebDataService> web_data_service_; | |
| 220 scoped_refptr<PasswordStore> password_store_; | |
| 221 scoped_refptr<SessionService> session_service_; | |
| 222 scoped_ptr<BrowserThemeProvider> theme_provider_; | |
| 223 scoped_refptr<WebKitContext> webkit_context_; | |
| 224 scoped_ptr<DesktopNotificationService> desktop_notification_service_; | |
| 225 scoped_ptr<BackgroundContentsService> background_contents_service_; | |
| 226 scoped_ptr<BackgroundModeManager> background_mode_manager_; | |
| 227 scoped_ptr<StatusTray> status_tray_; | |
| 228 scoped_refptr<PersonalDataManager> personal_data_manager_; | |
| 229 scoped_ptr<PinnedTabService> pinned_tab_service_; | |
| 230 scoped_refptr<BrowserFileSystemContext> browser_file_system_context_; | |
| 231 scoped_ptr<BrowserSignin> browser_signin_; | |
| 232 bool history_service_created_; | |
| 233 bool favicon_service_created_; | |
| 234 bool created_web_data_service_; | |
| 235 bool created_password_store_; | |
| 236 bool created_download_manager_; | |
| 237 bool created_theme_provider_; | |
| 238 bool clear_local_state_on_exit_; | |
| 239 // Whether or not the last session exited cleanly. This is set only once. | |
| 240 bool last_session_exited_cleanly_; | |
| 241 | |
| 242 base::OneShotTimer<ProfileImpl> create_session_service_timer_; | |
| 243 | |
| 244 scoped_ptr<Profile> off_the_record_profile_; | |
| 245 | |
| 246 // See GetStartTime for details. | |
| 247 base::Time start_time_; | |
| 248 | |
| 249 scoped_refptr<TabRestoreService> tab_restore_service_; | |
| 250 | |
| 251 scoped_refptr<SpellCheckHost> spellcheck_host_; | |
| 252 | |
| 253 // Indicates whether |spellcheck_host_| has told us initialization is | |
| 254 // finished. | |
| 255 bool spellcheck_host_ready_; | |
| 256 | |
| 257 #if defined(OS_WIN) | |
| 258 bool checked_instant_promo_; | |
| 259 scoped_ptr<PromoCounter> instant_promo_counter_; | |
| 260 #endif | |
| 261 | |
| 262 // Set to true when ShutdownSessionService is invoked. If true | |
| 263 // GetSessionService won't recreate the SessionService. | |
| 264 bool shutdown_session_service_; | |
| 265 | |
| 266 // The AppCacheService for this profile, shared by all requests contexts | |
| 267 // associated with this profile. Should only be used on the IO thread. | |
| 268 scoped_refptr<ChromeAppCacheService> appcache_service_; | |
| 269 | |
| 270 // The main database tracker for this profile. | |
| 271 // Should be used only on the file thread. | |
| 272 scoped_refptr<webkit_database::DatabaseTracker> db_tracker_; | |
| 273 | |
| 274 scoped_refptr<history::TopSites> top_sites_; // For history and thumbnails. | |
| 275 | |
| 276 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; | |
| 277 | |
| 278 scoped_refptr<ExtensionInfoMap> extension_info_map_; | |
| 279 | |
| 280 #if defined(OS_CHROMEOS) | |
| 281 scoped_ptr<chromeos::Preferences> chromeos_preferences_; | |
| 282 | |
| 283 scoped_refptr<chromeos::ProxyConfigServiceImpl> | |
| 284 chromeos_proxy_config_service_impl_; | |
| 285 | |
| 286 scoped_ptr<chromeos::EnterpriseExtensionObserver> | |
| 287 chromeos_enterprise_extension_observer_; | |
| 288 #endif | |
| 289 | |
| 290 scoped_refptr<PrefProxyConfigTracker> pref_proxy_config_tracker_; | |
| 291 | |
| 292 DISALLOW_COPY_AND_ASSIGN(ProfileImpl); | |
| 293 }; | |
| 294 | |
| 295 #endif // CHROME_BROWSER_PROFILE_IMPL_H_ | |
| OLD | NEW |