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

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

Issue 11147026: Initial refactor to get profiles to propagate storage partition details. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed the order in the gypi file. Created 8 years, 2 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
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"
(...skipping 22 matching lines...) Expand all
33 #include "chrome/browser/history/shortcuts_backend_factory.h" 33 #include "chrome/browser/history/shortcuts_backend_factory.h"
34 #include "chrome/browser/history/top_sites.h" 34 #include "chrome/browser/history/top_sites.h"
35 #include "chrome/browser/net/proxy_service_factory.h" 35 #include "chrome/browser/net/proxy_service_factory.h"
36 #include "chrome/browser/notifications/desktop_notification_service.h" 36 #include "chrome/browser/notifications/desktop_notification_service.h"
37 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 37 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
38 #include "chrome/browser/policy/user_cloud_policy_manager.h" 38 #include "chrome/browser/policy/user_cloud_policy_manager.h"
39 #include "chrome/browser/prefs/browser_prefs.h" 39 #include "chrome/browser/prefs/browser_prefs.h"
40 #include "chrome/browser/prefs/testing_pref_store.h" 40 #include "chrome/browser/prefs/testing_pref_store.h"
41 #include "chrome/browser/prerender/prerender_manager.h" 41 #include "chrome/browser/prerender/prerender_manager.h"
42 #include "chrome/browser/profiles/profile_dependency_manager.h" 42 #include "chrome/browser/profiles/profile_dependency_manager.h"
43 #include "chrome/browser/profiles/storage_partition_descriptor.h"
43 #include "chrome/browser/protector/protector_service_factory.h" 44 #include "chrome/browser/protector/protector_service_factory.h"
44 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" 45 #include "chrome/browser/search_engines/template_url_fetcher_factory.h"
45 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" 46 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h"
46 #include "chrome/browser/webdata/web_data_service.h" 47 #include "chrome/browser/webdata/web_data_service.h"
47 #include "chrome/browser/webdata/web_data_service_factory.h" 48 #include "chrome/browser/webdata/web_data_service_factory.h"
48 #include "chrome/common/chrome_constants.h" 49 #include "chrome/common/chrome_constants.h"
49 #include "chrome/common/chrome_notification_types.h" 50 #include "chrome/common/chrome_notification_types.h"
50 #include "chrome/common/chrome_switches.h" 51 #include "chrome/common/chrome_switches.h"
51 #include "chrome/common/url_constants.h" 52 #include "chrome/common/url_constants.h"
52 #include "chrome/test/base/bookmark_load_observer.h" 53 #include "chrome/test/base/bookmark_load_observer.h"
53 #include "chrome/test/base/history_index_restore_observer.h" 54 #include "chrome/test/base/history_index_restore_observer.h"
54 #include "chrome/test/base/testing_pref_service.h" 55 #include "chrome/test/base/testing_pref_service.h"
55 #include "chrome/test/base/ui_test_utils.h" 56 #include "chrome/test/base/ui_test_utils.h"
56 #include "content/public/browser/browser_thread.h" 57 #include "content/public/browser/browser_thread.h"
57 #include "content/public/browser/notification_service.h" 58 #include "content/public/browser/notification_service.h"
59 #include "content/public/browser/storage_partition.h"
58 #include "content/public/browser/render_process_host.h" 60 #include "content/public/browser/render_process_host.h"
59 #include "content/public/test/mock_resource_context.h" 61 #include "content/public/test/mock_resource_context.h"
60 #include "content/public/test/test_utils.h" 62 #include "content/public/test/test_utils.h"
61 #include "net/cookies/cookie_monster.h" 63 #include "net/cookies/cookie_monster.h"
62 #include "net/url_request/url_request_context.h" 64 #include "net/url_request/url_request_context.h"
63 #include "net/url_request/url_request_context_getter.h" 65 #include "net/url_request/url_request_context_getter.h"
64 #include "net/url_request/url_request_test_util.h" 66 #include "net/url_request/url_request_test_util.h"
65 #include "testing/gmock/include/gmock/gmock.h" 67 #include "testing/gmock/include/gmock/gmock.h"
66 68
67 #if defined(ENABLE_CONFIGURATION_POLICY) 69 #if defined(ENABLE_CONFIGURATION_POLICY)
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 DownloadManagerDelegate* TestingProfile::GetDownloadManagerDelegate() { 615 DownloadManagerDelegate* TestingProfile::GetDownloadManagerDelegate() {
614 return NULL; 616 return NULL;
615 } 617 }
616 618
617 net::URLRequestContextGetter* TestingProfile::GetRequestContext() { 619 net::URLRequestContextGetter* TestingProfile::GetRequestContext() {
618 return request_context_.get(); 620 return request_context_.get();
619 } 621 }
620 622
621 net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess( 623 net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess(
622 int renderer_child_id) { 624 int renderer_child_id) {
623 ExtensionService* extension_service = 625 content::RenderProcessHost* rph = content::RenderProcessHost::FromID(
624 extensions::ExtensionSystem::Get(this)->extension_service(); 626 renderer_child_id);
625 if (extension_service) { 627 content::StoragePartition* storage_partition = rph->GetStoragePartition();
626 const extensions::Extension* extension = 628
627 extension_service->GetIsolatedAppForRenderer(renderer_child_id); 629 // TODO(nasko): Remove this conditional, once browser tag creates a proper
628 if (extension) 630 // storage partition.
629 return GetRequestContextForStoragePartition(extension->id()); 631 if (rph->IsGuest()) {
632 return GetRequestContextForStoragePartition(
633 storage_partition->GetPath(), true);
630 } 634 }
631 635
632 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( 636 return storage_partition->GetURLRequestContext();
633 renderer_child_id);
634 if (rph && rph->IsGuest()) {
635 // For guest processes (used by the browser tag), we need to isolate the
636 // storage.
637 // TODO(nasko): Until we have proper storage partitions, create a
638 // non-persistent context using the RPH's id.
639 std::string id("guest-");
640 id.append(base::IntToString(renderer_child_id));
641 return GetRequestContextForStoragePartition(id);
642 }
643
644 return GetRequestContext();
645 } 637 }
646 638
647 void TestingProfile::CreateRequestContext() { 639 void TestingProfile::CreateRequestContext() {
648 if (!request_context_) 640 if (!request_context_)
649 request_context_ = 641 request_context_ =
650 new TestURLRequestContextGetter( 642 new TestURLRequestContextGetter(
651 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); 643 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
652 } 644 }
653 645
654 void TestingProfile::ResetRequestContext() { 646 void TestingProfile::ResetRequestContext() {
655 // Any objects holding live URLFetchers should be deleted before the request 647 // Any objects holding live URLFetchers should be deleted before the request
656 // context is shut down. 648 // context is shut down.
657 TemplateURLFetcherFactory::ShutdownForProfile(this); 649 TemplateURLFetcherFactory::ShutdownForProfile(this);
658 650
659 request_context_ = NULL; 651 request_context_ = NULL;
660 } 652 }
661 653
662 net::URLRequestContextGetter* TestingProfile::GetMediaRequestContext() { 654 net::URLRequestContextGetter* TestingProfile::GetMediaRequestContext() {
663 return NULL; 655 return NULL;
664 } 656 }
665 657
666 net::URLRequestContextGetter* 658 net::URLRequestContextGetter*
667 TestingProfile::GetMediaRequestContextForRenderProcess( 659 TestingProfile::GetMediaRequestContextForRenderProcess(
668 int renderer_child_id) { 660 int renderer_child_id) {
669 return NULL; 661 return NULL;
670 } 662 }
671 663
672 net::URLRequestContextGetter* 664 net::URLRequestContextGetter*
673 TestingProfile::GetMediaRequestContextForStoragePartition( 665 TestingProfile::GetMediaRequestContextForStoragePartition(
674 const std::string& partition_id) { 666 const FilePath& partition_path,
667 bool in_memory) {
675 return NULL; 668 return NULL;
676 } 669 }
677 670
678 net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() { 671 net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() {
679 if (!extensions_request_context_) 672 if (!extensions_request_context_)
680 extensions_request_context_ = new TestExtensionURLRequestContextGetter(); 673 extensions_request_context_ = new TestExtensionURLRequestContextGetter();
681 return extensions_request_context_.get(); 674 return extensions_request_context_.get();
682 } 675 }
683 676
684 net::SSLConfigService* TestingProfile::GetSSLConfigService() { 677 net::SSLConfigService* TestingProfile::GetSSLConfigService() {
685 return NULL; 678 return NULL;
686 } 679 }
687 680
688 net::URLRequestContextGetter* 681 net::URLRequestContextGetter*
689 TestingProfile::GetRequestContextForStoragePartition( 682 TestingProfile::GetRequestContextForStoragePartition(
690 const std::string& partition_id) { 683 const FilePath& partition_path,
684 bool in_memory) {
691 // We don't test storage partitions here yet, so returning the same dummy 685 // We don't test storage partitions here yet, so returning the same dummy
692 // context is sufficient for now. 686 // context is sufficient for now.
693 return GetRequestContext(); 687 return GetRequestContext();
694 } 688 }
695 689
696 content::ResourceContext* TestingProfile::GetResourceContext() { 690 content::ResourceContext* TestingProfile::GetResourceContext() {
697 if (!resource_context_.get()) 691 if (!resource_context_.get())
698 resource_context_.reset(new content::MockResourceContext()); 692 resource_context_.reset(new content::MockResourceContext());
699 return resource_context_.get(); 693 return resource_context_.get();
700 } 694 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { 840 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() {
847 DCHECK(!build_called_); 841 DCHECK(!build_called_);
848 build_called_ = true; 842 build_called_ = true;
849 return scoped_ptr<TestingProfile>(new TestingProfile( 843 return scoped_ptr<TestingProfile>(new TestingProfile(
850 path_, 844 path_,
851 delegate_, 845 delegate_,
852 extension_policy_, 846 extension_policy_,
853 pref_service_.Pass(), 847 pref_service_.Pass(),
854 user_cloud_policy_manager_.Pass())); 848 user_cloud_policy_manager_.Pass()));
855 } 849 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698