Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: chrome/test/base/testing_profile.cc

Issue 9609024: Reland 124817 - Take extensions out of Profile into a profile-keyed service, ExtensionSystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/base/testing_profile.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 15 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
16 #include "chrome/browser/bookmarks/bookmark_model.h" 16 #include "chrome/browser/bookmarks/bookmark_model.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/content_settings/host_content_settings_map.h" 18 #include "chrome/browser/content_settings/host_content_settings_map.h"
19 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 19 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
20 #include "chrome/browser/extensions/extension_pref_value_map.h" 20 #include "chrome/browser/extensions/extension_pref_value_map.h"
21 #include "chrome/browser/extensions/extension_service.h" 21 #include "chrome/browser/extensions/extension_service.h"
22 #include "chrome/browser/extensions/extension_special_storage_policy.h" 22 #include "chrome/browser/extensions/extension_special_storage_policy.h"
23 #include "chrome/browser/extensions/extension_system.h"
24 #include "chrome/browser/extensions/extension_system_factory.h"
25 #include "chrome/browser/extensions/test_extension_system.h"
23 #include "chrome/browser/favicon/favicon_service.h" 26 #include "chrome/browser/favicon/favicon_service.h"
24 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" 27 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h"
25 #include "chrome/browser/history/history.h" 28 #include "chrome/browser/history/history.h"
26 #include "chrome/browser/history/history_backend.h" 29 #include "chrome/browser/history/history_backend.h"
27 #include "chrome/browser/history/top_sites.h" 30 #include "chrome/browser/history/top_sites.h"
28 #include "chrome/browser/net/proxy_service_factory.h" 31 #include "chrome/browser/net/proxy_service_factory.h"
29 #include "chrome/browser/notifications/desktop_notification_service.h" 32 #include "chrome/browser/notifications/desktop_notification_service.h"
30 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 33 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
31 #include "chrome/browser/prefs/browser_prefs.h" 34 #include "chrome/browser/prefs/browser_prefs.h"
32 #include "chrome/browser/prefs/testing_pref_store.h" 35 #include "chrome/browser/prefs/testing_pref_store.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 if (delegate_) { 190 if (delegate_) {
188 MessageLoop::current()->PostTask(FROM_HERE, 191 MessageLoop::current()->PostTask(FROM_HERE,
189 base::Bind(&TestingProfile::FinishInit, 192 base::Bind(&TestingProfile::FinishInit,
190 base::Unretained(this))); 193 base::Unretained(this)));
191 } else { 194 } else {
192 FinishInit(); 195 FinishInit();
193 } 196 }
194 } 197 }
195 198
196 void TestingProfile::Init() { 199 void TestingProfile::Init() {
200 ExtensionSystemFactory::GetInstance()->SetTestingFactory(
201 this, TestExtensionSystem::Build);
202
197 profile_dependency_manager_->CreateProfileServices(this, true); 203 profile_dependency_manager_->CreateProfileServices(this, true);
198 204
199 #if defined(ENABLE_NOTIFICATIONS) 205 #if defined(ENABLE_NOTIFICATIONS)
200 // Install profile keyed service factory hooks for dummy/test services 206 // Install profile keyed service factory hooks for dummy/test services
201 DesktopNotificationServiceFactory::GetInstance()->SetTestingFactory( 207 DesktopNotificationServiceFactory::GetInstance()->SetTestingFactory(
202 this, CreateTestDesktopNotificationService); 208 this, CreateTestDesktopNotificationService);
203 #endif 209 #endif
204 } 210 }
205 211
206 void TestingProfile::FinishInit() { 212 void TestingProfile::FinishInit() {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 if (turl_model->loaded()) 384 if (turl_model->loaded())
379 return; 385 return;
380 386
381 ui_test_utils::WindowedNotificationObserver turl_service_load_observer( 387 ui_test_utils::WindowedNotificationObserver turl_service_load_observer(
382 chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, 388 chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED,
383 content::NotificationService::AllSources()); 389 content::NotificationService::AllSources());
384 turl_model->Load(); 390 turl_model->Load();
385 turl_service_load_observer.Wait(); 391 turl_service_load_observer.Wait();
386 } 392 }
387 393
388 void TestingProfile::CreateExtensionProcessManager() {
389 extension_process_manager_.reset(ExtensionProcessManager::Create(this));
390 }
391
392 ExtensionService* TestingProfile::CreateExtensionService(
393 const CommandLine* command_line,
394 const FilePath& install_directory,
395 bool autoupdate_enabled) {
396 // Extension pref store, created for use by |extension_prefs_|.
397
398 extension_pref_value_map_.reset(new ExtensionPrefValueMap);
399
400 bool extensions_disabled =
401 command_line && command_line->HasSwitch(switches::kDisableExtensions);
402
403 // Note that the GetPrefs() creates a TestingPrefService, therefore
404 // the extension controlled pref values set in extension_prefs_
405 // are not reflected in the pref service. One would need to
406 // inject a new ExtensionPrefStore(extension_pref_value_map_.get(), false).
407 extension_prefs_.reset(
408 new ExtensionPrefs(GetPrefs(),
409 install_directory,
410 extension_pref_value_map_.get()));
411 extension_prefs_->Init(extensions_disabled);
412 extension_service_.reset(new ExtensionService(this,
413 command_line,
414 install_directory,
415 extension_prefs_.get(),
416 autoupdate_enabled,
417 true));
418 return extension_service_.get();
419 }
420
421 FilePath TestingProfile::GetPath() { 394 FilePath TestingProfile::GetPath() {
422 return profile_path_; 395 return profile_path_;
423 } 396 }
424 397
425 TestingPrefService* TestingProfile::GetTestingPrefService() { 398 TestingPrefService* TestingProfile::GetTestingPrefService() {
426 if (!prefs_.get()) 399 if (!prefs_.get())
427 CreateTestingPrefService(); 400 CreateTestingPrefService();
428 DCHECK(testing_prefs_); 401 DCHECK(testing_prefs_);
429 return testing_prefs_; 402 return testing_prefs_;
430 } 403 }
(...skipping 27 matching lines...) Expand all
458 } 431 }
459 432
460 Profile* TestingProfile::GetOriginalProfile() { 433 Profile* TestingProfile::GetOriginalProfile() {
461 return this; 434 return this;
462 } 435 }
463 436
464 VisitedLinkMaster* TestingProfile::GetVisitedLinkMaster() { 437 VisitedLinkMaster* TestingProfile::GetVisitedLinkMaster() {
465 return NULL; 438 return NULL;
466 } 439 }
467 440
441 ExtensionPrefValueMap* TestingProfile::GetExtensionPrefValueMap() {
442 return NULL;
443 }
444
468 ExtensionService* TestingProfile::GetExtensionService() { 445 ExtensionService* TestingProfile::GetExtensionService() {
469 return extension_service_.get(); 446 return ExtensionSystemFactory::GetForProfile(this)->extension_service();
470 } 447 }
471 448
472 UserScriptMaster* TestingProfile::GetUserScriptMaster() { 449 UserScriptMaster* TestingProfile::GetUserScriptMaster() {
473 return NULL; 450 return ExtensionSystemFactory::GetForProfile(this)->user_script_master();
474 }
475
476 ExtensionDevToolsManager* TestingProfile::GetExtensionDevToolsManager() {
477 return NULL;
478 } 451 }
479 452
480 ExtensionProcessManager* TestingProfile::GetExtensionProcessManager() { 453 ExtensionProcessManager* TestingProfile::GetExtensionProcessManager() {
481 return extension_process_manager_.get(); 454 return ExtensionSystemFactory::GetForProfile(this)->process_manager();
482 }
483
484 ExtensionMessageService* TestingProfile::GetExtensionMessageService() {
485 return NULL;
486 } 455 }
487 456
488 ExtensionEventRouter* TestingProfile::GetExtensionEventRouter() { 457 ExtensionEventRouter* TestingProfile::GetExtensionEventRouter() {
489 return NULL; 458 return ExtensionSystemFactory::GetForProfile(this)->event_router();
490 } 459 }
491 460
492 void TestingProfile::SetExtensionSpecialStoragePolicy( 461 void TestingProfile::SetExtensionSpecialStoragePolicy(
493 ExtensionSpecialStoragePolicy* extension_special_storage_policy) { 462 ExtensionSpecialStoragePolicy* extension_special_storage_policy) {
494 extension_special_storage_policy_ = extension_special_storage_policy; 463 extension_special_storage_policy_ = extension_special_storage_policy;
495 } 464 }
496 465
497 ExtensionSpecialStoragePolicy* 466 ExtensionSpecialStoragePolicy*
498 TestingProfile::GetExtensionSpecialStoragePolicy() { 467 TestingProfile::GetExtensionSpecialStoragePolicy() {
499 if (!extension_special_storage_policy_.get()) 468 if (!extension_special_storage_policy_.get())
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 DownloadManager* TestingProfile::GetDownloadManager() { 543 DownloadManager* TestingProfile::GetDownloadManager() {
575 return NULL; 544 return NULL;
576 } 545 }
577 546
578 net::URLRequestContextGetter* TestingProfile::GetRequestContext() { 547 net::URLRequestContextGetter* TestingProfile::GetRequestContext() {
579 return request_context_.get(); 548 return request_context_.get();
580 } 549 }
581 550
582 net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess( 551 net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess(
583 int renderer_child_id) { 552 int renderer_child_id) {
584 if (extension_service_.get()) { 553 ExtensionService* extension_service =
585 const Extension* installed_app = extension_service_-> 554 ExtensionSystemFactory::GetForProfile(this)->extension_service();
555 if (extension_service) {
556 const Extension* installed_app = extension_service->
586 GetInstalledAppForRenderer(renderer_child_id); 557 GetInstalledAppForRenderer(renderer_child_id);
587 if (installed_app != NULL && installed_app->is_storage_isolated()) 558 if (installed_app != NULL && installed_app->is_storage_isolated())
588 return GetRequestContextForIsolatedApp(installed_app->id()); 559 return GetRequestContextForIsolatedApp(installed_app->id());
589 } 560 }
590 561
591 return GetRequestContext(); 562 return GetRequestContext();
592 } 563 }
593 564
594 void TestingProfile::CreateRequestContext() { 565 void TestingProfile::CreateRequestContext() {
595 if (!request_context_) 566 if (!request_context_)
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 683
713 void TestingProfile::BlockUntilHistoryProcessesPendingRequests() { 684 void TestingProfile::BlockUntilHistoryProcessesPendingRequests() {
714 DCHECK(history_service_.get()); 685 DCHECK(history_service_.get());
715 DCHECK(MessageLoop::current()); 686 DCHECK(MessageLoop::current());
716 687
717 CancelableRequestConsumer consumer; 688 CancelableRequestConsumer consumer;
718 history_service_->ScheduleDBTask(new QuittingHistoryDBTask(), &consumer); 689 history_service_->ScheduleDBTask(new QuittingHistoryDBTask(), &consumer);
719 MessageLoop::current()->Run(); 690 MessageLoop::current()->Run();
720 } 691 }
721 692
722 ExtensionInfoMap* TestingProfile::GetExtensionInfoMap() {
723 return NULL;
724 }
725
726 PromoCounter* TestingProfile::GetInstantPromoCounter() { 693 PromoCounter* TestingProfile::GetInstantPromoCounter() {
727 return NULL; 694 return NULL;
728 } 695 }
729 696
730 ChromeURLDataManager* TestingProfile::GetChromeURLDataManager() { 697 ChromeURLDataManager* TestingProfile::GetChromeURLDataManager() {
731 if (!chrome_url_data_manager_.get()) 698 if (!chrome_url_data_manager_.get())
732 chrome_url_data_manager_.reset( 699 chrome_url_data_manager_.reset(
733 new ChromeURLDataManager( 700 new ChromeURLDataManager(
734 base::Callback<ChromeURLDataManagerBackend*(void)>())); 701 base::Callback<ChromeURLDataManagerBackend*(void)>()));
735 return chrome_url_data_manager_.get(); 702 return chrome_url_data_manager_.get();
(...skipping 18 matching lines...) Expand all
754 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { 721 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() {
755 return GetExtensionSpecialStoragePolicy(); 722 return GetExtensionSpecialStoragePolicy();
756 } 723 }
757 724
758 void TestingProfile::DestroyWebDataService() { 725 void TestingProfile::DestroyWebDataService() {
759 if (!web_data_service_.get()) 726 if (!web_data_service_.get())
760 return; 727 return;
761 728
762 web_data_service_->Shutdown(); 729 web_data_service_->Shutdown();
763 } 730 }
OLDNEW
« no previous file with comments | « chrome/test/base/testing_profile.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698