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 #include "chrome/browser/profiles/profile_impl.h" | 5 #include "chrome/browser/profiles/profile_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/environment.h" | 8 #include "base/environment.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "chrome/browser/appcache/chrome_appcache_service.h" | 16 #include "chrome/browser/appcache/chrome_appcache_service.h" |
17 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 17 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
18 #include "chrome/browser/autofill/personal_data_manager.h" | 18 #include "chrome/browser/autofill/personal_data_manager.h" |
19 #include "chrome/browser/background_contents_service.h" | 19 #include "chrome/browser/background_contents_service.h" |
20 #include "chrome/browser/background_mode_manager.h" | 20 #include "chrome/browser/background_mode_manager.h" |
21 #include "chrome/browser/bookmarks/bookmark_model.h" | 21 #include "chrome/browser/bookmarks/bookmark_model.h" |
22 #include "chrome/browser/browser_list.h" | 22 #include "chrome/browser/browser_list.h" |
23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
24 #include "chrome/browser/browser_signin.h" | 24 #include "chrome/browser/browser_signin.h" |
25 #include "chrome/browser/browser_thread.h" | 25 #include "chrome/browser/browser_thread.h" |
26 #include "chrome/browser/chrome_blob_storage_context.h" | 26 #include "chrome/browser/chrome_blob_storage_context.h" |
27 #include "chrome/browser/content_settings/host_content_settings_map.h" | 27 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 28 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
28 #include "chrome/browser/defaults.h" | 29 #include "chrome/browser/defaults.h" |
29 #include "chrome/browser/dom_ui/ntp_resource_cache.h" | 30 #include "chrome/browser/dom_ui/ntp_resource_cache.h" |
30 #include "chrome/browser/download/download_manager.h" | 31 #include "chrome/browser/download/download_manager.h" |
31 #include "chrome/browser/extensions/default_apps.h" | 32 #include "chrome/browser/extensions/default_apps.h" |
32 #include "chrome/browser/extensions/extension_devtools_manager.h" | 33 #include "chrome/browser/extensions/extension_devtools_manager.h" |
33 #include "chrome/browser/extensions/extension_error_reporter.h" | 34 #include "chrome/browser/extensions/extension_error_reporter.h" |
34 #include "chrome/browser/extensions/extension_event_router.h" | 35 #include "chrome/browser/extensions/extension_event_router.h" |
35 #include "chrome/browser/extensions/extension_info_map.h" | 36 #include "chrome/browser/extensions/extension_info_map.h" |
36 #include "chrome/browser/extensions/extension_io_event_router.h" | 37 #include "chrome/browser/extensions/extension_io_event_router.h" |
37 #include "chrome/browser/extensions/extension_message_service.h" | 38 #include "chrome/browser/extensions/extension_message_service.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 #endif | 331 #endif |
331 | 332 |
332 background_contents_service_.reset( | 333 background_contents_service_.reset( |
333 new BackgroundContentsService(this, CommandLine::ForCurrentProcess())); | 334 new BackgroundContentsService(this, CommandLine::ForCurrentProcess())); |
334 | 335 |
335 extension_io_event_router_ = new ExtensionIOEventRouter(this); | 336 extension_io_event_router_ = new ExtensionIOEventRouter(this); |
336 extension_info_map_ = new ExtensionInfoMap(); | 337 extension_info_map_ = new ExtensionInfoMap(); |
337 | 338 |
338 GetPolicyContext()->Initialize(); | 339 GetPolicyContext()->Initialize(); |
339 | 340 |
| 341 InitRegisteredProtocolHandlers(); |
| 342 |
340 clear_local_state_on_exit_ = prefs->GetBoolean(prefs::kClearSiteDataOnExit); | 343 clear_local_state_on_exit_ = prefs->GetBoolean(prefs::kClearSiteDataOnExit); |
341 | 344 |
342 // Log the profile size after a reasonable startup delay. | 345 // Log the profile size after a reasonable startup delay. |
343 BrowserThread::PostDelayedTask(BrowserThread::FILE, FROM_HERE, | 346 BrowserThread::PostDelayedTask(BrowserThread::FILE, FROM_HERE, |
344 new ProfileSizeTask(path_), 112000); | 347 new ProfileSizeTask(path_), 112000); |
345 | 348 |
346 InstantController::RecordMetrics(this); | 349 InstantController::RecordMetrics(this); |
347 } | 350 } |
348 | 351 |
349 void ProfileImpl::InitExtensions() { | 352 void ProfileImpl::InitExtensions() { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 } | 482 } |
480 | 483 |
481 void ProfileImpl::InitWebResources() { | 484 void ProfileImpl::InitWebResources() { |
482 if (web_resource_service_) | 485 if (web_resource_service_) |
483 return; | 486 return; |
484 | 487 |
485 web_resource_service_ = new WebResourceService(this); | 488 web_resource_service_ = new WebResourceService(this); |
486 web_resource_service_->StartAfterDelay(); | 489 web_resource_service_->StartAfterDelay(); |
487 } | 490 } |
488 | 491 |
| 492 void ProfileImpl::InitRegisteredProtocolHandlers() { |
| 493 if (protocol_handler_registry_) |
| 494 return; |
| 495 protocol_handler_registry_ = new ProtocolHandlerRegistry(this); |
| 496 protocol_handler_registry_->Load(); |
| 497 } |
| 498 |
489 NTPResourceCache* ProfileImpl::GetNTPResourceCache() { | 499 NTPResourceCache* ProfileImpl::GetNTPResourceCache() { |
490 if (!ntp_resource_cache_.get()) | 500 if (!ntp_resource_cache_.get()) |
491 ntp_resource_cache_.reset(new NTPResourceCache(this)); | 501 ntp_resource_cache_.reset(new NTPResourceCache(this)); |
492 return ntp_resource_cache_.get(); | 502 return ntp_resource_cache_.get(); |
493 } | 503 } |
494 | 504 |
495 FilePath ProfileImpl::last_selected_directory() { | 505 FilePath ProfileImpl::last_selected_directory() { |
496 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); | 506 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); |
497 } | 507 } |
498 | 508 |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 } | 1145 } |
1136 | 1146 |
1137 BookmarkModel* ProfileImpl::GetBookmarkModel() { | 1147 BookmarkModel* ProfileImpl::GetBookmarkModel() { |
1138 if (!bookmark_bar_model_.get()) { | 1148 if (!bookmark_bar_model_.get()) { |
1139 bookmark_bar_model_.reset(new BookmarkModel(this)); | 1149 bookmark_bar_model_.reset(new BookmarkModel(this)); |
1140 bookmark_bar_model_->Load(); | 1150 bookmark_bar_model_->Load(); |
1141 } | 1151 } |
1142 return bookmark_bar_model_.get(); | 1152 return bookmark_bar_model_.get(); |
1143 } | 1153 } |
1144 | 1154 |
| 1155 ProtocolHandlerRegistry* ProfileImpl::GetProtocolHandlerRegistry() { |
| 1156 return protocol_handler_registry_.get(); |
| 1157 } |
| 1158 |
1145 bool ProfileImpl::IsSameProfile(Profile* profile) { | 1159 bool ProfileImpl::IsSameProfile(Profile* profile) { |
1146 if (profile == static_cast<Profile*>(this)) | 1160 if (profile == static_cast<Profile*>(this)) |
1147 return true; | 1161 return true; |
1148 Profile* otr_profile = off_the_record_profile_.get(); | 1162 Profile* otr_profile = off_the_record_profile_.get(); |
1149 return otr_profile && profile == otr_profile; | 1163 return otr_profile && profile == otr_profile; |
1150 } | 1164 } |
1151 | 1165 |
1152 Time ProfileImpl::GetStartTime() const { | 1166 Time ProfileImpl::GetStartTime() const { |
1153 return start_time_; | 1167 return start_time_; |
1154 } | 1168 } |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1491 } | 1505 } |
1492 | 1506 |
1493 PrerenderManager* ProfileImpl::GetPrerenderManager() { | 1507 PrerenderManager* ProfileImpl::GetPrerenderManager() { |
1494 CommandLine* cl = CommandLine::ForCurrentProcess(); | 1508 CommandLine* cl = CommandLine::ForCurrentProcess(); |
1495 if (!cl->HasSwitch(switches::kEnablePagePrerender)) | 1509 if (!cl->HasSwitch(switches::kEnablePagePrerender)) |
1496 return NULL; | 1510 return NULL; |
1497 if (!prerender_manager_) | 1511 if (!prerender_manager_) |
1498 prerender_manager_ = new PrerenderManager(this); | 1512 prerender_manager_ = new PrerenderManager(this); |
1499 return prerender_manager_; | 1513 return prerender_manager_; |
1500 } | 1514 } |
OLD | NEW |