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

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

Issue 9369013: Take extensions out of Profile into a profile-keyed service, ExtensionSystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rerebase 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 if (delegate_) { 191 if (delegate_) {
189 MessageLoop::current()->PostTask(FROM_HERE, 192 MessageLoop::current()->PostTask(FROM_HERE,
190 base::Bind(&TestingProfile::FinishInit, 193 base::Bind(&TestingProfile::FinishInit,
191 base::Unretained(this))); 194 base::Unretained(this)));
192 } else { 195 } else {
193 FinishInit(); 196 FinishInit();
194 } 197 }
195 } 198 }
196 199
197 void TestingProfile::Init() { 200 void TestingProfile::Init() {
201 ExtensionSystemFactory::GetInstance()->SetTestingFactory(
202 this, TestExtensionSystem::Build);
203
198 profile_dependency_manager_->CreateProfileServices(this, true); 204 profile_dependency_manager_->CreateProfileServices(this, true);
199 205
200 #if defined(ENABLE_NOTIFICATIONS) 206 #if defined(ENABLE_NOTIFICATIONS)
201 // Install profile keyed service factory hooks for dummy/test services 207 // Install profile keyed service factory hooks for dummy/test services
202 DesktopNotificationServiceFactory::GetInstance()->SetTestingFactory( 208 DesktopNotificationServiceFactory::GetInstance()->SetTestingFactory(
203 this, CreateTestDesktopNotificationService); 209 this, CreateTestDesktopNotificationService);
204 #endif 210 #endif
205 } 211 }
206 212
207 void TestingProfile::FinishInit() { 213 void TestingProfile::FinishInit() {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 if (turl_model->loaded()) 385 if (turl_model->loaded())
380 return; 386 return;
381 387
382 ui_test_utils::WindowedNotificationObserver turl_service_load_observer( 388 ui_test_utils::WindowedNotificationObserver turl_service_load_observer(
383 chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, 389 chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED,
384 content::NotificationService::AllSources()); 390 content::NotificationService::AllSources());
385 turl_model->Load(); 391 turl_model->Load();
386 turl_service_load_observer.Wait(); 392 turl_service_load_observer.Wait();
387 } 393 }
388 394
389 void TestingProfile::CreateExtensionProcessManager() {
390 extension_process_manager_.reset(ExtensionProcessManager::Create(this));
391 }
392
393 ExtensionService* TestingProfile::CreateExtensionService(
394 const CommandLine* command_line,
395 const FilePath& install_directory,
396 bool autoupdate_enabled) {
397 // Extension pref store, created for use by |extension_prefs_|.
398
399 extension_pref_value_map_.reset(new ExtensionPrefValueMap);
400
401 bool extensions_disabled =
402 command_line && command_line->HasSwitch(switches::kDisableExtensions);
403
404 // Note that the GetPrefs() creates a TestingPrefService, therefore
405 // the extension controlled pref values set in extension_prefs_
406 // are not reflected in the pref service. One would need to
407 // inject a new ExtensionPrefStore(extension_pref_value_map_.get(), false).
408 extension_prefs_.reset(
409 new ExtensionPrefs(GetPrefs(),
410 install_directory,
411 extension_pref_value_map_.get()));
412 extension_prefs_->Init(extensions_disabled);
413 extension_service_.reset(new ExtensionService(this,
414 command_line,
415 install_directory,
416 extension_prefs_.get(),
417 autoupdate_enabled,
418 true));
419 return extension_service_.get();
420 }
421
422 FilePath TestingProfile::GetPath() { 395 FilePath TestingProfile::GetPath() {
423 return profile_path_; 396 return profile_path_;
424 } 397 }
425 398
426 TestingPrefService* TestingProfile::GetTestingPrefService() { 399 TestingPrefService* TestingProfile::GetTestingPrefService() {
427 if (!prefs_.get()) 400 if (!prefs_.get())
428 CreateTestingPrefService(); 401 CreateTestingPrefService();
429 DCHECK(testing_prefs_); 402 DCHECK(testing_prefs_);
430 return testing_prefs_; 403 return testing_prefs_;
431 } 404 }
(...skipping 27 matching lines...) Expand all
459 } 432 }
460 433
461 Profile* TestingProfile::GetOriginalProfile() { 434 Profile* TestingProfile::GetOriginalProfile() {
462 return this; 435 return this;
463 } 436 }
464 437
465 VisitedLinkMaster* TestingProfile::GetVisitedLinkMaster() { 438 VisitedLinkMaster* TestingProfile::GetVisitedLinkMaster() {
466 return NULL; 439 return NULL;
467 } 440 }
468 441
442 ExtensionPrefValueMap* TestingProfile::GetExtensionPrefValueMap() {
443 return NULL;
444 }
445
469 ExtensionService* TestingProfile::GetExtensionService() { 446 ExtensionService* TestingProfile::GetExtensionService() {
470 return extension_service_.get(); 447 return ExtensionSystemFactory::GetForProfile(this)->extension_service();
471 } 448 }
472 449
473 UserScriptMaster* TestingProfile::GetUserScriptMaster() { 450 UserScriptMaster* TestingProfile::GetUserScriptMaster() {
474 return NULL; 451 return ExtensionSystemFactory::GetForProfile(this)->user_script_master();
475 }
476
477 ExtensionDevToolsManager* TestingProfile::GetExtensionDevToolsManager() {
478 return NULL;
479 } 452 }
480 453
481 ExtensionProcessManager* TestingProfile::GetExtensionProcessManager() { 454 ExtensionProcessManager* TestingProfile::GetExtensionProcessManager() {
482 return extension_process_manager_.get(); 455 return ExtensionSystemFactory::GetForProfile(this)->process_manager();
483 }
484
485 ExtensionMessageService* TestingProfile::GetExtensionMessageService() {
486 return NULL;
487 } 456 }
488 457
489 ExtensionEventRouter* TestingProfile::GetExtensionEventRouter() { 458 ExtensionEventRouter* TestingProfile::GetExtensionEventRouter() {
490 return NULL; 459 return ExtensionSystemFactory::GetForProfile(this)->event_router();
491 } 460 }
492 461
493 void TestingProfile::SetExtensionSpecialStoragePolicy( 462 void TestingProfile::SetExtensionSpecialStoragePolicy(
494 ExtensionSpecialStoragePolicy* extension_special_storage_policy) { 463 ExtensionSpecialStoragePolicy* extension_special_storage_policy) {
495 extension_special_storage_policy_ = extension_special_storage_policy; 464 extension_special_storage_policy_ = extension_special_storage_policy;
496 } 465 }
497 466
498 ExtensionSpecialStoragePolicy* 467 ExtensionSpecialStoragePolicy*
499 TestingProfile::GetExtensionSpecialStoragePolicy() { 468 TestingProfile::GetExtensionSpecialStoragePolicy() {
500 if (!extension_special_storage_policy_.get()) 469 if (!extension_special_storage_policy_.get())
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 DownloadManager* TestingProfile::GetDownloadManager() { 544 DownloadManager* TestingProfile::GetDownloadManager() {
576 return NULL; 545 return NULL;
577 } 546 }
578 547
579 net::URLRequestContextGetter* TestingProfile::GetRequestContext() { 548 net::URLRequestContextGetter* TestingProfile::GetRequestContext() {
580 return request_context_.get(); 549 return request_context_.get();
581 } 550 }
582 551
583 net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess( 552 net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess(
584 int renderer_child_id) { 553 int renderer_child_id) {
585 if (extension_service_.get()) { 554 ExtensionService* extension_service =
586 const Extension* installed_app = extension_service_-> 555 ExtensionSystemFactory::GetForProfile(this)->extension_service();
556 if (extension_service) {
557 const Extension* installed_app = extension_service->
587 GetInstalledAppForRenderer(renderer_child_id); 558 GetInstalledAppForRenderer(renderer_child_id);
588 if (installed_app != NULL && installed_app->is_storage_isolated()) 559 if (installed_app != NULL && installed_app->is_storage_isolated())
589 return GetRequestContextForIsolatedApp(installed_app->id()); 560 return GetRequestContextForIsolatedApp(installed_app->id());
590 } 561 }
591 562
592 return GetRequestContext(); 563 return GetRequestContext();
593 } 564 }
594 565
595 void TestingProfile::CreateRequestContext() { 566 void TestingProfile::CreateRequestContext() {
596 if (!request_context_) 567 if (!request_context_)
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 MessageLoop::current()->Run(); 689 MessageLoop::current()->Run();
719 } 690 }
720 691
721 TokenService* TestingProfile::GetTokenService() { 692 TokenService* TestingProfile::GetTokenService() {
722 if (!token_service_.get()) { 693 if (!token_service_.get()) {
723 token_service_.reset(new TokenService()); 694 token_service_.reset(new TokenService());
724 } 695 }
725 return token_service_.get(); 696 return token_service_.get();
726 } 697 }
727 698
728 ExtensionInfoMap* TestingProfile::GetExtensionInfoMap() {
729 return NULL;
730 }
731
732 PromoCounter* TestingProfile::GetInstantPromoCounter() { 699 PromoCounter* TestingProfile::GetInstantPromoCounter() {
733 return NULL; 700 return NULL;
734 } 701 }
735 702
736 ChromeURLDataManager* TestingProfile::GetChromeURLDataManager() { 703 ChromeURLDataManager* TestingProfile::GetChromeURLDataManager() {
737 if (!chrome_url_data_manager_.get()) 704 if (!chrome_url_data_manager_.get())
738 chrome_url_data_manager_.reset( 705 chrome_url_data_manager_.reset(
739 new ChromeURLDataManager( 706 new ChromeURLDataManager(
740 base::Callback<ChromeURLDataManagerBackend*(void)>())); 707 base::Callback<ChromeURLDataManagerBackend*(void)>()));
741 return chrome_url_data_manager_.get(); 708 return chrome_url_data_manager_.get();
(...skipping 18 matching lines...) Expand all
760 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { 727 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() {
761 return GetExtensionSpecialStoragePolicy(); 728 return GetExtensionSpecialStoragePolicy();
762 } 729 }
763 730
764 void TestingProfile::DestroyWebDataService() { 731 void TestingProfile::DestroyWebDataService() {
765 if (!web_data_service_.get()) 732 if (!web_data_service_.get())
766 return; 733 return;
767 734
768 web_data_service_->Shutdown(); 735 web_data_service_->Shutdown();
769 } 736 }
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