Chromium Code Reviews| 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/test/base/testing_profile.h" | 5 #include "chrome/test/base/testing_profile.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 return new DesktopNotificationService(profile, NULL); | 125 return new DesktopNotificationService(profile, NULL); |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace | 128 } // namespace |
| 129 | 129 |
| 130 TestingProfile::TestingProfile() | 130 TestingProfile::TestingProfile() |
| 131 : start_time_(Time::Now()), | 131 : start_time_(Time::Now()), |
| 132 testing_prefs_(NULL), | 132 testing_prefs_(NULL), |
| 133 incognito_(false), | 133 incognito_(false), |
| 134 last_session_exited_cleanly_(true), | 134 last_session_exited_cleanly_(true), |
| 135 profile_dependency_manager_(ProfileDependencyManager::GetInstance()) { | 135 enable_lazy_service_initialization_(false), |
| 136 profile_dependency_manager_(ProfileDependencyManager::GetInstance()), | |
| 137 delegate_(NULL) { | |
| 136 if (!temp_dir_.CreateUniqueTempDir()) { | 138 if (!temp_dir_.CreateUniqueTempDir()) { |
| 137 LOG(ERROR) << "Failed to create unique temporary directory."; | 139 LOG(ERROR) << "Failed to create unique temporary directory."; |
| 138 | 140 |
| 139 // Fallback logic in case we fail to create unique temporary directory. | 141 // Fallback logic in case we fail to create unique temporary directory. |
| 140 FilePath system_tmp_dir; | 142 FilePath system_tmp_dir; |
| 141 bool success = PathService::Get(base::DIR_TEMP, &system_tmp_dir); | 143 bool success = PathService::Get(base::DIR_TEMP, &system_tmp_dir); |
| 142 | 144 |
| 143 // We're severly screwed if we can't get the system temporary | 145 // We're severly screwed if we can't get the system temporary |
| 144 // directory. Die now to avoid writing to the filesystem root | 146 // directory. Die now to avoid writing to the filesystem root |
| 145 // or other bad places. | 147 // or other bad places. |
| 146 CHECK(success); | 148 CHECK(success); |
| 147 | 149 |
| 148 FilePath fallback_dir(system_tmp_dir.AppendASCII("TestingProfilePath")); | 150 FilePath fallback_dir(system_tmp_dir.AppendASCII("TestingProfilePath")); |
| 149 file_util::Delete(fallback_dir, true); | 151 file_util::Delete(fallback_dir, true); |
| 150 file_util::CreateDirectory(fallback_dir); | 152 file_util::CreateDirectory(fallback_dir); |
| 151 if (!temp_dir_.Set(fallback_dir)) { | 153 if (!temp_dir_.Set(fallback_dir)) { |
| 152 // That shouldn't happen, but if it does, try to recover. | 154 // That shouldn't happen, but if it does, try to recover. |
| 153 LOG(ERROR) << "Failed to use a fallback temporary directory."; | 155 LOG(ERROR) << "Failed to use a fallback temporary directory."; |
| 154 | 156 |
| 155 // We're screwed if this fails, see CHECK above. | 157 // We're screwed if this fails, see CHECK above. |
| 156 CHECK(temp_dir_.Set(system_tmp_dir)); | 158 CHECK(temp_dir_.Set(system_tmp_dir)); |
| 157 } | 159 } |
| 158 } | 160 } |
| 159 | 161 |
| 160 profile_path_ = temp_dir_.path(); | 162 profile_path_ = temp_dir_.path(); |
| 161 | 163 |
| 162 Init(); | 164 Init(); |
| 165 FinishInit(); | |
| 163 } | 166 } |
| 164 | 167 |
| 165 TestingProfile::TestingProfile(const FilePath& path) | 168 TestingProfile::TestingProfile(const FilePath& path) |
| 166 : start_time_(Time::Now()), | 169 : start_time_(Time::Now()), |
| 167 testing_prefs_(NULL), | 170 testing_prefs_(NULL), |
| 168 incognito_(false), | 171 incognito_(false), |
| 169 last_session_exited_cleanly_(true), | 172 last_session_exited_cleanly_(true), |
| 173 enable_lazy_service_initialization_(false), | |
| 170 profile_path_(path), | 174 profile_path_(path), |
| 171 profile_dependency_manager_(ProfileDependencyManager::GetInstance()) { | 175 profile_dependency_manager_(ProfileDependencyManager::GetInstance()), |
| 176 delegate_(NULL) { | |
| 172 Init(); | 177 Init(); |
| 178 FinishInit(); | |
| 179 } | |
| 180 | |
| 181 TestingProfile::TestingProfile(const FilePath& path, | |
| 182 Delegate* delegate) | |
| 183 : start_time_(Time::Now()), | |
| 184 testing_prefs_(NULL), | |
| 185 incognito_(false), | |
| 186 last_session_exited_cleanly_(true), | |
| 187 enable_lazy_service_initialization_(false), | |
| 188 profile_path_(path), | |
| 189 profile_dependency_manager_(ProfileDependencyManager::GetInstance()), | |
| 190 delegate_(delegate) { | |
| 191 Init(); | |
| 192 if (delegate_) { | |
| 193 MessageLoop::current()->PostTask(FROM_HERE, | |
| 194 base::Bind(&TestingProfile::FinishInit, | |
| 195 base::Unretained(this))); | |
| 196 } else { | |
| 197 FinishInit(); | |
| 198 } | |
| 173 } | 199 } |
| 174 | 200 |
| 175 void TestingProfile::Init() { | 201 void TestingProfile::Init() { |
| 176 profile_dependency_manager_->CreateProfileServices(this, true); | 202 profile_dependency_manager_->CreateProfileServices(this, true); |
| 177 | 203 |
| 178 // Install profile keyed service factory hooks for dummy/test services | 204 // Install profile keyed service factory hooks for dummy/test services |
| 179 DesktopNotificationServiceFactory::GetInstance()->SetTestingFactory( | 205 DesktopNotificationServiceFactory::GetInstance()->SetTestingFactory( |
| 180 this, CreateTestDesktopNotificationService); | 206 this, CreateTestDesktopNotificationService); |
| 207 } | |
| 181 | 208 |
| 209 void TestingProfile::FinishInit() { | |
| 182 content::NotificationService::current()->Notify( | 210 content::NotificationService::current()->Notify( |
| 183 chrome::NOTIFICATION_PROFILE_CREATED, | 211 chrome::NOTIFICATION_PROFILE_CREATED, |
| 184 content::Source<Profile>(static_cast<Profile*>(this)), | 212 content::Source<Profile>(static_cast<Profile*>(this)), |
| 185 content::NotificationService::NoDetails()); | 213 content::NotificationService::NoDetails()); |
| 214 | |
| 215 if (delegate_) | |
| 216 delegate_->OnProfileCreated(this, true); | |
| 186 } | 217 } |
| 187 | 218 |
| 188 TestingProfile::~TestingProfile() { | 219 TestingProfile::~TestingProfile() { |
| 189 content::NotificationService::current()->Notify( | 220 content::NotificationService::current()->Notify( |
| 190 chrome::NOTIFICATION_PROFILE_DESTROYED, | 221 chrome::NOTIFICATION_PROFILE_DESTROYED, |
| 191 content::Source<Profile>(static_cast<Profile*>(this)), | 222 content::Source<Profile>(static_cast<Profile*>(this)), |
| 192 content::NotificationService::NoDetails()); | 223 content::NotificationService::NoDetails()); |
| 193 | 224 |
| 194 profile_dependency_manager_->DestroyProfileServices(this); | 225 profile_dependency_manager_->DestroyProfileServices(this); |
| 195 | 226 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 autoupdate_enabled, | 407 autoupdate_enabled, |
| 377 true)); | 408 true)); |
| 378 return extension_service_.get(); | 409 return extension_service_.get(); |
| 379 } | 410 } |
| 380 | 411 |
| 381 FilePath TestingProfile::GetPath() { | 412 FilePath TestingProfile::GetPath() { |
| 382 return profile_path_; | 413 return profile_path_; |
| 383 } | 414 } |
| 384 | 415 |
| 385 TestingPrefService* TestingProfile::GetTestingPrefService() { | 416 TestingPrefService* TestingProfile::GetTestingPrefService() { |
| 417 // Always lazily initialize so no check for | |
|
Paweł Hajdan Jr.
2011/11/22 09:18:42
I don't understand the difference here. It seems t
rpetterson
2011/11/22 21:43:25
The intention of enable_lazy_service_initializatio
| |
| 418 // enable_lazy_service_initialization_. | |
| 386 if (!prefs_.get()) | 419 if (!prefs_.get()) |
| 387 CreateTestingPrefService(); | 420 CreateTestingPrefService(); |
| 388 DCHECK(testing_prefs_); | 421 DCHECK(testing_prefs_); |
| 389 return testing_prefs_; | 422 return testing_prefs_; |
| 390 } | 423 } |
| 391 | 424 |
| 392 TestingProfile* TestingProfile::AsTestingProfile() { | 425 TestingProfile* TestingProfile::AsTestingProfile() { |
| 393 return this; | 426 return this; |
| 394 } | 427 } |
| 395 | 428 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 473 if (!extension_special_storage_policy_.get()) | 506 if (!extension_special_storage_policy_.get()) |
| 474 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy(NULL); | 507 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy(NULL); |
| 475 return extension_special_storage_policy_.get(); | 508 return extension_special_storage_policy_.get(); |
| 476 } | 509 } |
| 477 | 510 |
| 478 SSLHostState* TestingProfile::GetSSLHostState() { | 511 SSLHostState* TestingProfile::GetSSLHostState() { |
| 479 return NULL; | 512 return NULL; |
| 480 } | 513 } |
| 481 | 514 |
| 482 FaviconService* TestingProfile::GetFaviconService(ServiceAccessType access) { | 515 FaviconService* TestingProfile::GetFaviconService(ServiceAccessType access) { |
| 516 if (enable_lazy_service_initialization_ && !favicon_service_.get()) | |
| 517 CreateFaviconService(); | |
| 483 return favicon_service_.get(); | 518 return favicon_service_.get(); |
| 484 } | 519 } |
| 485 | 520 |
| 486 HistoryService* TestingProfile::GetHistoryService(ServiceAccessType access) { | 521 HistoryService* TestingProfile::GetHistoryService(ServiceAccessType access) { |
| 522 if (enable_lazy_service_initialization_ && !history_service_.get()) | |
| 523 CreateHistoryService(true, false); | |
| 487 return history_service_.get(); | 524 return history_service_.get(); |
| 488 } | 525 } |
| 489 | 526 |
| 490 HistoryService* TestingProfile::GetHistoryServiceWithoutCreating() { | 527 HistoryService* TestingProfile::GetHistoryServiceWithoutCreating() { |
| 491 return history_service_.get(); | 528 return history_service_.get(); |
| 492 } | 529 } |
| 493 | 530 |
| 494 net::CookieMonster* TestingProfile::GetCookieMonster() { | 531 net::CookieMonster* TestingProfile::GetCookieMonster() { |
| 495 if (!GetRequestContext()) | 532 if (!GetRequestContext()) |
| 496 return NULL; | 533 return NULL; |
| 497 return GetRequestContext()->GetURLRequestContext()->cookie_store()-> | 534 return GetRequestContext()->GetURLRequestContext()->cookie_store()-> |
| 498 GetCookieMonster(); | 535 GetCookieMonster(); |
| 499 } | 536 } |
| 500 | 537 |
| 501 AutocompleteClassifier* TestingProfile::GetAutocompleteClassifier() { | 538 AutocompleteClassifier* TestingProfile::GetAutocompleteClassifier() { |
| 502 return autocomplete_classifier_.get(); | 539 return autocomplete_classifier_.get(); |
| 503 } | 540 } |
| 504 | 541 |
| 505 history::ShortcutsBackend* TestingProfile::GetShortcutsBackend() { | 542 history::ShortcutsBackend* TestingProfile::GetShortcutsBackend() { |
| 506 return NULL; | 543 return NULL; |
| 507 } | 544 } |
| 508 | 545 |
| 509 WebDataService* TestingProfile::GetWebDataService(ServiceAccessType access) { | 546 WebDataService* TestingProfile::GetWebDataService(ServiceAccessType access) { |
| 547 if (enable_lazy_service_initialization_ && !web_data_service_.get()) | |
| 548 CreateWebDataService(false); | |
| 510 return web_data_service_.get(); | 549 return web_data_service_.get(); |
| 511 } | 550 } |
| 512 | 551 |
| 513 WebDataService* TestingProfile::GetWebDataServiceWithoutCreating() { | 552 WebDataService* TestingProfile::GetWebDataServiceWithoutCreating() { |
| 514 return web_data_service_.get(); | 553 return web_data_service_.get(); |
| 515 } | 554 } |
| 516 | 555 |
| 517 PasswordStore* TestingProfile::GetPasswordStore(ServiceAccessType access) { | 556 PasswordStore* TestingProfile::GetPasswordStore(ServiceAccessType access) { |
| 518 return NULL; | 557 return NULL; |
| 519 } | 558 } |
| 520 | 559 |
| 521 void TestingProfile::SetPrefService(PrefService* prefs) { | 560 void TestingProfile::SetPrefService(PrefService* prefs) { |
| 522 DCHECK(!prefs_.get()); | 561 DCHECK(!prefs_.get()); |
| 523 prefs_.reset(prefs); | 562 prefs_.reset(prefs); |
| 524 } | 563 } |
| 525 | 564 |
| 526 void TestingProfile::CreateTestingPrefService() { | 565 void TestingProfile::CreateTestingPrefService() { |
| 527 DCHECK(!prefs_.get()); | 566 DCHECK(!prefs_.get()); |
| 528 testing_prefs_ = new TestingPrefService(); | 567 testing_prefs_ = new TestingPrefService(); |
| 529 prefs_.reset(testing_prefs_); | 568 prefs_.reset(testing_prefs_); |
| 530 Profile::RegisterUserPrefs(prefs_.get()); | 569 Profile::RegisterUserPrefs(prefs_.get()); |
| 531 browser::RegisterUserPrefs(prefs_.get()); | 570 browser::RegisterUserPrefs(prefs_.get()); |
| 532 } | 571 } |
| 533 | 572 |
| 534 PrefService* TestingProfile::GetPrefs() { | 573 PrefService* TestingProfile::GetPrefs() { |
| 535 if (!prefs_.get()) { | 574 if (!prefs_.get()) { |
|
Paweł Hajdan Jr.
2011/11/22 09:18:42
Should this check enable_lazy_service_initializati
| |
| 536 CreateTestingPrefService(); | 575 CreateTestingPrefService(); |
| 537 } | 576 } |
| 538 return prefs_.get(); | 577 return prefs_.get(); |
| 539 } | 578 } |
| 540 | 579 |
| 541 TemplateURLFetcher* TestingProfile::GetTemplateURLFetcher() { | 580 TemplateURLFetcher* TestingProfile::GetTemplateURLFetcher() { |
| 542 return template_url_fetcher_.get(); | 581 return template_url_fetcher_.get(); |
| 543 } | 582 } |
| 544 | 583 |
| 545 history::TopSites* TestingProfile::GetTopSites() { | 584 history::TopSites* TestingProfile::GetTopSites() { |
| 546 return top_sites_.get(); | 585 return top_sites_.get(); |
| 547 } | 586 } |
| 548 | 587 |
| 549 history::TopSites* TestingProfile::GetTopSitesWithoutCreating() { | 588 history::TopSites* TestingProfile::GetTopSitesWithoutCreating() { |
| 550 return top_sites_.get(); | 589 return top_sites_.get(); |
| 551 } | 590 } |
| 552 | 591 |
| 553 DownloadManager* TestingProfile::GetDownloadManager() { | 592 DownloadManager* TestingProfile::GetDownloadManager() { |
| 554 return NULL; | 593 return NULL; |
| 555 } | 594 } |
| 556 | 595 |
| 557 fileapi::FileSystemContext* TestingProfile::GetFileSystemContext() { | 596 fileapi::FileSystemContext* TestingProfile::GetFileSystemContext() { |
| 558 if (!file_system_context_) { | 597 if (!file_system_context_) { |
|
Paweł Hajdan Jr.
2011/11/22 09:18:42
Should this check enable_lazy_service_initializati
| |
| 559 file_system_context_ = new fileapi::FileSystemContext( | 598 file_system_context_ = new fileapi::FileSystemContext( |
| 560 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 599 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
| 561 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 600 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
| 562 GetExtensionSpecialStoragePolicy(), | 601 GetExtensionSpecialStoragePolicy(), |
| 563 NULL, | 602 NULL, |
| 564 GetPath(), | 603 GetPath(), |
| 565 IsOffTheRecord(), | 604 IsOffTheRecord(), |
| 566 true, // Allow file access from files. | 605 true, // Allow file access from files. |
| 567 NULL); | 606 NULL); |
| 568 } | 607 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 600 | 639 |
| 601 void TestingProfile::ResetRequestContext() { | 640 void TestingProfile::ResetRequestContext() { |
| 602 request_context_ = NULL; | 641 request_context_ = NULL; |
| 603 } | 642 } |
| 604 | 643 |
| 605 net::URLRequestContextGetter* TestingProfile::GetRequestContextForMedia() { | 644 net::URLRequestContextGetter* TestingProfile::GetRequestContextForMedia() { |
| 606 return NULL; | 645 return NULL; |
| 607 } | 646 } |
| 608 | 647 |
| 609 net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() { | 648 net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() { |
| 610 if (!extensions_request_context_) | 649 if (!extensions_request_context_) |
|
Paweł Hajdan Jr.
2011/11/22 09:18:42
Should this check enable_lazy_service_initializati
| |
| 611 extensions_request_context_ = new TestExtensionURLRequestContextGetter(); | 650 extensions_request_context_ = new TestExtensionURLRequestContextGetter(); |
| 612 return extensions_request_context_.get(); | 651 return extensions_request_context_.get(); |
| 613 } | 652 } |
| 614 | 653 |
| 615 net::SSLConfigService* TestingProfile::GetSSLConfigService() { | 654 net::SSLConfigService* TestingProfile::GetSSLConfigService() { |
| 616 return NULL; | 655 return NULL; |
| 617 } | 656 } |
| 618 | 657 |
| 619 UserStyleSheetWatcher* TestingProfile::GetUserStyleSheetWatcher() { | 658 UserStyleSheetWatcher* TestingProfile::GetUserStyleSheetWatcher() { |
| 620 return NULL; | 659 return NULL; |
| 621 } | 660 } |
| 622 | 661 |
| 623 net::URLRequestContextGetter* TestingProfile::GetRequestContextForIsolatedApp( | 662 net::URLRequestContextGetter* TestingProfile::GetRequestContextForIsolatedApp( |
| 624 const std::string& app_id) { | 663 const std::string& app_id) { |
| 625 // We don't test isolated app storage here yet, so returning the same dummy | 664 // We don't test isolated app storage here yet, so returning the same dummy |
| 626 // context is sufficient for now. | 665 // context is sufficient for now. |
| 627 return GetRequestContext(); | 666 return GetRequestContext(); |
| 628 } | 667 } |
| 629 | 668 |
| 630 const content::ResourceContext& TestingProfile::GetResourceContext() { | 669 const content::ResourceContext& TestingProfile::GetResourceContext() { |
| 631 return *content::MockResourceContext::GetInstance(); | 670 return *content::MockResourceContext::GetInstance(); |
| 632 } | 671 } |
| 633 | 672 |
| 634 FindBarState* TestingProfile::GetFindBarState() { | 673 FindBarState* TestingProfile::GetFindBarState() { |
| 635 if (!find_bar_state_.get()) | 674 if (!find_bar_state_.get()) |
|
Paweł Hajdan Jr.
2011/11/22 09:18:42
Should this check enable_lazy_service_initializati
| |
| 636 find_bar_state_.reset(new FindBarState()); | 675 find_bar_state_.reset(new FindBarState()); |
| 637 return find_bar_state_.get(); | 676 return find_bar_state_.get(); |
| 638 } | 677 } |
| 639 | 678 |
| 640 HostContentSettingsMap* TestingProfile::GetHostContentSettingsMap() { | 679 HostContentSettingsMap* TestingProfile::GetHostContentSettingsMap() { |
| 641 if (!host_content_settings_map_.get()) { | 680 if (!host_content_settings_map_.get()) { |
|
Paweł Hajdan Jr.
2011/11/22 09:18:42
Should this check enable_lazy_service_initializati
| |
| 642 host_content_settings_map_ = new HostContentSettingsMap( | 681 host_content_settings_map_ = new HostContentSettingsMap( |
| 643 GetPrefs(), GetExtensionService(), false); | 682 GetPrefs(), GetExtensionService(), false); |
| 644 } | 683 } |
| 645 return host_content_settings_map_.get(); | 684 return host_content_settings_map_.get(); |
| 646 } | 685 } |
| 647 | 686 |
| 648 GeolocationPermissionContext* | 687 GeolocationPermissionContext* |
| 649 TestingProfile::GetGeolocationPermissionContext() { | 688 TestingProfile::GetGeolocationPermissionContext() { |
| 650 if (!geolocation_permission_context_.get()) { | 689 if (!geolocation_permission_context_.get()) { |
|
Paweł Hajdan Jr.
2011/11/22 09:18:42
Should this check enable_lazy_service_initializati
| |
| 651 geolocation_permission_context_ = | 690 geolocation_permission_context_ = |
| 652 new ChromeGeolocationPermissionContext(this); | 691 new ChromeGeolocationPermissionContext(this); |
| 653 } | 692 } |
| 654 return geolocation_permission_context_.get(); | 693 return geolocation_permission_context_.get(); |
| 655 } | 694 } |
| 656 | 695 |
| 657 SpeechInputPreferences* TestingProfile::GetSpeechInputPreferences() { | 696 SpeechInputPreferences* TestingProfile::GetSpeechInputPreferences() { |
| 658 if (!speech_input_preferences_.get()) | 697 if (!speech_input_preferences_.get()) |
|
Paweł Hajdan Jr.
2011/11/22 09:18:42
Should this check enable_lazy_service_initializati
| |
| 659 speech_input_preferences_ = new ChromeSpeechInputPreferences(GetPrefs()); | 698 speech_input_preferences_ = new ChromeSpeechInputPreferences(GetPrefs()); |
| 660 return speech_input_preferences_.get(); | 699 return speech_input_preferences_.get(); |
| 661 } | 700 } |
| 662 | 701 |
| 663 HostZoomMap* TestingProfile::GetHostZoomMap() { | 702 HostZoomMap* TestingProfile::GetHostZoomMap() { |
| 664 return NULL; | 703 return NULL; |
| 665 } | 704 } |
| 666 | 705 |
| 667 bool TestingProfile::HasProfileSyncService() const { | 706 bool TestingProfile::HasProfileSyncService() const { |
| 668 return (profile_sync_service_.get() != NULL); | 707 return (profile_sync_service_.get() != NULL); |
| 669 } | 708 } |
| 670 | 709 |
| 671 std::wstring TestingProfile::GetName() { | 710 std::wstring TestingProfile::GetName() { |
| 672 return std::wstring(); | 711 return std::wstring(); |
| 673 } | 712 } |
| 674 | 713 |
| 675 std::wstring TestingProfile::GetID() { | 714 std::wstring TestingProfile::GetID() { |
| 676 return id_; | 715 return id_; |
| 677 } | 716 } |
| 678 | 717 |
| 679 void TestingProfile::SetID(const std::wstring& id) { | 718 void TestingProfile::SetID(const std::wstring& id) { |
| 680 id_ = id; | 719 id_ = id; |
| 681 } | 720 } |
| 682 | 721 |
| 683 bool TestingProfile::DidLastSessionExitCleanly() { | 722 bool TestingProfile::DidLastSessionExitCleanly() { |
| 684 return last_session_exited_cleanly_; | 723 return last_session_exited_cleanly_; |
| 685 } | 724 } |
| 686 | 725 |
| 687 BookmarkModel* TestingProfile::GetBookmarkModel() { | 726 BookmarkModel* TestingProfile::GetBookmarkModel() { |
| 727 if (enable_lazy_service_initialization_ && !bookmark_bar_model_.get()) | |
| 728 CreateBookmarkModel(true); | |
| 688 return bookmark_bar_model_.get(); | 729 return bookmark_bar_model_.get(); |
| 689 } | 730 } |
| 690 | 731 |
| 691 bool TestingProfile::IsSameProfile(Profile *p) { | 732 bool TestingProfile::IsSameProfile(Profile *p) { |
| 692 return this == p; | 733 return this == p; |
| 693 } | 734 } |
| 694 | 735 |
| 695 base::Time TestingProfile::GetStartTime() const { | 736 base::Time TestingProfile::GetStartTime() const { |
| 696 return start_time_; | 737 return start_time_; |
| 697 } | 738 } |
| 698 | 739 |
| 699 ProtocolHandlerRegistry* TestingProfile::GetProtocolHandlerRegistry() { | 740 ProtocolHandlerRegistry* TestingProfile::GetProtocolHandlerRegistry() { |
| 700 return protocol_handler_registry_.get(); | 741 return protocol_handler_registry_.get(); |
| 701 } | 742 } |
| 702 | 743 |
| 703 SpellCheckHost* TestingProfile::GetSpellCheckHost() { | 744 SpellCheckHost* TestingProfile::GetSpellCheckHost() { |
| 704 return NULL; | 745 return NULL; |
| 705 } | 746 } |
| 706 | 747 |
| 707 WebKitContext* TestingProfile::GetWebKitContext() { | 748 WebKitContext* TestingProfile::GetWebKitContext() { |
| 708 if (webkit_context_ == NULL) { | 749 if (webkit_context_ == NULL) { |
|
Paweł Hajdan Jr.
2011/11/22 09:18:42
Should this check enable_lazy_service_initializati
| |
| 709 webkit_context_ = new WebKitContext( | 750 webkit_context_ = new WebKitContext( |
| 710 IsOffTheRecord(), GetPath(), | 751 IsOffTheRecord(), GetPath(), |
| 711 GetExtensionSpecialStoragePolicy(), | 752 GetExtensionSpecialStoragePolicy(), |
| 712 false, NULL, NULL); | 753 false, NULL, NULL); |
| 713 } | 754 } |
| 714 return webkit_context_; | 755 return webkit_context_; |
| 715 } | 756 } |
| 716 | 757 |
| 717 WebKitContext* TestingProfile::GetOffTheRecordWebKitContext() { | 758 WebKitContext* TestingProfile::GetOffTheRecordWebKitContext() { |
| 718 return NULL; | 759 return NULL; |
| 719 } | 760 } |
| 720 | 761 |
| 721 FilePath TestingProfile::last_selected_directory() { | 762 FilePath TestingProfile::last_selected_directory() { |
| 722 return last_selected_directory_; | 763 return last_selected_directory_; |
| 723 } | 764 } |
| 724 | 765 |
| 725 void TestingProfile::set_last_selected_directory(const FilePath& path) { | 766 void TestingProfile::set_last_selected_directory(const FilePath& path) { |
| 726 last_selected_directory_ = path; | 767 last_selected_directory_ = path; |
| 727 } | 768 } |
| 728 | 769 |
| 729 PrefProxyConfigTracker* TestingProfile::GetProxyConfigTracker() { | 770 PrefProxyConfigTracker* TestingProfile::GetProxyConfigTracker() { |
| 730 if (!pref_proxy_config_tracker_.get()) { | 771 if (!pref_proxy_config_tracker_.get()) { |
|
Paweł Hajdan Jr.
2011/11/22 09:18:42
Should this check enable_lazy_service_initializati
| |
| 731 pref_proxy_config_tracker_.reset( | 772 pref_proxy_config_tracker_.reset( |
| 732 ProxyServiceFactory::CreatePrefProxyConfigTracker(GetPrefs())); | 773 ProxyServiceFactory::CreatePrefProxyConfigTracker(GetPrefs())); |
| 733 } | 774 } |
| 734 return pref_proxy_config_tracker_.get(); | 775 return pref_proxy_config_tracker_.get(); |
| 735 } | 776 } |
| 736 | 777 |
| 737 void TestingProfile::BlockUntilHistoryProcessesPendingRequests() { | 778 void TestingProfile::BlockUntilHistoryProcessesPendingRequests() { |
| 738 DCHECK(history_service_.get()); | 779 DCHECK(history_service_.get()); |
| 739 DCHECK(MessageLoop::current()); | 780 DCHECK(MessageLoop::current()); |
| 740 | 781 |
| 741 CancelableRequestConsumer consumer; | 782 CancelableRequestConsumer consumer; |
| 742 history_service_->ScheduleDBTask(new QuittingHistoryDBTask(), &consumer); | 783 history_service_->ScheduleDBTask(new QuittingHistoryDBTask(), &consumer); |
| 743 MessageLoop::current()->Run(); | 784 MessageLoop::current()->Run(); |
| 744 } | 785 } |
| 745 | 786 |
| 746 TokenService* TestingProfile::GetTokenService() { | 787 TokenService* TestingProfile::GetTokenService() { |
| 747 if (!token_service_.get()) { | 788 if (!token_service_.get()) { |
|
Paweł Hajdan Jr.
2011/11/22 09:18:42
Should this check enable_lazy_service_initializati
| |
| 748 token_service_.reset(new TokenService()); | 789 token_service_.reset(new TokenService()); |
| 749 } | 790 } |
| 750 return token_service_.get(); | 791 return token_service_.get(); |
| 751 } | 792 } |
| 752 | 793 |
| 753 ProfileSyncService* TestingProfile::GetProfileSyncService() { | 794 ProfileSyncService* TestingProfile::GetProfileSyncService() { |
| 754 return GetProfileSyncService(""); | 795 return GetProfileSyncService(""); |
| 755 } | 796 } |
| 756 | 797 |
| 757 ProfileSyncService* TestingProfile::GetProfileSyncService( | 798 ProfileSyncService* TestingProfile::GetProfileSyncService( |
| 758 const std::string& cros_user) { | 799 const std::string& cros_user) { |
| 759 if (!profile_sync_service_.get()) { | 800 if (!profile_sync_service_.get()) { |
|
Paweł Hajdan Jr.
2011/11/22 09:18:42
Should this check enable_lazy_service_initializati
| |
| 760 // Use a NiceMock here since we are really using the mock as a | 801 // Use a NiceMock here since we are really using the mock as a |
| 761 // fake. Test cases that want to set expectations on a | 802 // fake. Test cases that want to set expectations on a |
| 762 // ProfileSyncService should use the ProfileMock and have this | 803 // ProfileSyncService should use the ProfileMock and have this |
| 763 // method return their own mock instance. | 804 // method return their own mock instance. |
| 764 profile_sync_service_.reset(new NiceMock<ProfileSyncServiceMock>()); | 805 profile_sync_service_.reset(new NiceMock<ProfileSyncServiceMock>()); |
| 765 } | 806 } |
| 766 return profile_sync_service_.get(); | 807 return profile_sync_service_.get(); |
| 767 } | 808 } |
| 768 | 809 |
| 769 ChromeBlobStorageContext* TestingProfile::GetBlobStorageContext() { | 810 ChromeBlobStorageContext* TestingProfile::GetBlobStorageContext() { |
| 770 return NULL; | 811 return NULL; |
| 771 } | 812 } |
| 772 | 813 |
| 773 ExtensionInfoMap* TestingProfile::GetExtensionInfoMap() { | 814 ExtensionInfoMap* TestingProfile::GetExtensionInfoMap() { |
| 774 return NULL; | 815 return NULL; |
| 775 } | 816 } |
| 776 | 817 |
| 777 PromoCounter* TestingProfile::GetInstantPromoCounter() { | 818 PromoCounter* TestingProfile::GetInstantPromoCounter() { |
| 778 return NULL; | 819 return NULL; |
| 779 } | 820 } |
| 780 | 821 |
| 781 ChromeURLDataManager* TestingProfile::GetChromeURLDataManager() { | 822 ChromeURLDataManager* TestingProfile::GetChromeURLDataManager() { |
| 782 if (!chrome_url_data_manager_.get()) | 823 if (!chrome_url_data_manager_.get()) |
|
Paweł Hajdan Jr.
2011/11/22 09:18:42
Should this check enable_lazy_service_initializati
| |
| 783 chrome_url_data_manager_.reset( | 824 chrome_url_data_manager_.reset( |
| 784 new ChromeURLDataManager( | 825 new ChromeURLDataManager( |
| 785 base::Callback<ChromeURLDataManagerBackend*(void)>())); | 826 base::Callback<ChromeURLDataManagerBackend*(void)>())); |
| 786 return chrome_url_data_manager_.get(); | 827 return chrome_url_data_manager_.get(); |
| 787 } | 828 } |
| 788 | 829 |
| 789 chrome_browser_net::Predictor* TestingProfile::GetNetworkPredictor() { | 830 chrome_browser_net::Predictor* TestingProfile::GetNetworkPredictor() { |
| 790 return NULL; | 831 return NULL; |
| 791 } | 832 } |
| 792 | 833 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 809 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { | 850 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { |
| 810 return GetExtensionSpecialStoragePolicy(); | 851 return GetExtensionSpecialStoragePolicy(); |
| 811 } | 852 } |
| 812 | 853 |
| 813 void TestingProfile::DestroyWebDataService() { | 854 void TestingProfile::DestroyWebDataService() { |
| 814 if (!web_data_service_.get()) | 855 if (!web_data_service_.get()) |
| 815 return; | 856 return; |
| 816 | 857 |
| 817 web_data_service_->Shutdown(); | 858 web_data_service_->Shutdown(); |
| 818 } | 859 } |
| OLD | NEW |