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

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: Fixing Android's BrowserContext. Created 8 years, 1 month 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 23 matching lines...) Expand all
34 #include "chrome/browser/history/shortcuts_backend.h" 34 #include "chrome/browser/history/shortcuts_backend.h"
35 #include "chrome/browser/history/shortcuts_backend_factory.h" 35 #include "chrome/browser/history/shortcuts_backend_factory.h"
36 #include "chrome/browser/history/top_sites.h" 36 #include "chrome/browser/history/top_sites.h"
37 #include "chrome/browser/net/proxy_service_factory.h" 37 #include "chrome/browser/net/proxy_service_factory.h"
38 #include "chrome/browser/notifications/desktop_notification_service.h" 38 #include "chrome/browser/notifications/desktop_notification_service.h"
39 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 39 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
40 #include "chrome/browser/policy/user_cloud_policy_manager.h" 40 #include "chrome/browser/policy/user_cloud_policy_manager.h"
41 #include "chrome/browser/prefs/browser_prefs.h" 41 #include "chrome/browser/prefs/browser_prefs.h"
42 #include "chrome/browser/prerender/prerender_manager.h" 42 #include "chrome/browser/prerender/prerender_manager.h"
43 #include "chrome/browser/profiles/profile_dependency_manager.h" 43 #include "chrome/browser/profiles/profile_dependency_manager.h"
44 #include "chrome/browser/profiles/storage_partition_descriptor.h"
44 #include "chrome/browser/protector/protector_service_factory.h" 45 #include "chrome/browser/protector/protector_service_factory.h"
45 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" 46 #include "chrome/browser/search_engines/template_url_fetcher_factory.h"
46 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" 47 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h"
47 #include "chrome/browser/webdata/web_data_service.h" 48 #include "chrome/browser/webdata/web_data_service.h"
48 #include "chrome/browser/webdata/web_data_service_factory.h" 49 #include "chrome/browser/webdata/web_data_service_factory.h"
49 #include "chrome/common/chrome_constants.h" 50 #include "chrome/common/chrome_constants.h"
50 #include "chrome/common/chrome_notification_types.h" 51 #include "chrome/common/chrome_notification_types.h"
51 #include "chrome/common/chrome_switches.h" 52 #include "chrome/common/chrome_switches.h"
52 #include "chrome/common/url_constants.h" 53 #include "chrome/common/url_constants.h"
53 #include "chrome/test/base/bookmark_load_observer.h" 54 #include "chrome/test/base/bookmark_load_observer.h"
54 #include "chrome/test/base/history_index_restore_observer.h" 55 #include "chrome/test/base/history_index_restore_observer.h"
55 #include "chrome/test/base/testing_pref_service.h" 56 #include "chrome/test/base/testing_pref_service.h"
56 #include "chrome/test/base/ui_test_utils.h" 57 #include "chrome/test/base/ui_test_utils.h"
57 #include "content/public/browser/browser_thread.h" 58 #include "content/public/browser/browser_thread.h"
58 #include "content/public/browser/notification_service.h" 59 #include "content/public/browser/notification_service.h"
60 #include "content/public/browser/storage_partition.h"
59 #include "content/public/browser/render_process_host.h" 61 #include "content/public/browser/render_process_host.h"
60 #include "content/public/test/mock_resource_context.h" 62 #include "content/public/test/mock_resource_context.h"
61 #include "content/public/test/test_utils.h" 63 #include "content/public/test/test_utils.h"
62 #include "net/cookies/cookie_monster.h" 64 #include "net/cookies/cookie_monster.h"
63 #include "net/url_request/url_request_context.h" 65 #include "net/url_request/url_request_context.h"
64 #include "net/url_request/url_request_context_getter.h" 66 #include "net/url_request/url_request_context_getter.h"
65 #include "net/url_request/url_request_test_util.h" 67 #include "net/url_request/url_request_test_util.h"
66 #include "testing/gmock/include/gmock/gmock.h" 68 #include "testing/gmock/include/gmock/gmock.h"
67 69
68 #if defined(ENABLE_CONFIGURATION_POLICY) 70 #if defined(ENABLE_CONFIGURATION_POLICY)
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 DownloadManagerDelegate* TestingProfile::GetDownloadManagerDelegate() { 604 DownloadManagerDelegate* TestingProfile::GetDownloadManagerDelegate() {
603 return NULL; 605 return NULL;
604 } 606 }
605 607
606 net::URLRequestContextGetter* TestingProfile::GetRequestContext() { 608 net::URLRequestContextGetter* TestingProfile::GetRequestContext() {
607 return request_context_.get(); 609 return request_context_.get();
608 } 610 }
609 611
610 net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess( 612 net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess(
611 int renderer_child_id) { 613 int renderer_child_id) {
612 ExtensionService* extension_service = 614 content::RenderProcessHost* rph = content::RenderProcessHost::FromID(
613 extensions::ExtensionSystem::Get(this)->extension_service(); 615 renderer_child_id);
614 if (extension_service) { 616 content::StoragePartition* storage_partition = rph->GetStoragePartition();
615 const extensions::Extension* extension = 617
616 extension_service->GetIsolatedAppForRenderer(renderer_child_id); 618 // TODO(nasko): Remove this conditional, once browser tag creates a proper
Charlie Reis 2012/10/30 17:47:48 nit: webview tag
nasko 2012/10/30 19:55:25 Done.
617 if (extension) 619 // storage partition.
618 return GetRequestContextForStoragePartition(extension->id()); 620 if (rph->IsGuest()) {
621 return GetRequestContextForStoragePartition(
622 storage_partition->GetPath(), true);
619 } 623 }
620 624
621 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( 625 return storage_partition->GetURLRequestContext();
622 renderer_child_id);
623 if (rph && rph->IsGuest()) {
624 // For guest processes (used by the browser tag), we need to isolate the
625 // storage.
626 // TODO(nasko): Until we have proper storage partitions, create a
627 // non-persistent context using the RPH's id.
628 std::string id("guest-");
629 id.append(base::IntToString(renderer_child_id));
630 return GetRequestContextForStoragePartition(id);
631 }
632
633 return GetRequestContext();
634 } 626 }
635 627
636 void TestingProfile::CreateRequestContext() { 628 void TestingProfile::CreateRequestContext() {
637 if (!request_context_) 629 if (!request_context_)
638 request_context_ = 630 request_context_ =
639 new TestURLRequestContextGetter( 631 new TestURLRequestContextGetter(
640 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); 632 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
641 } 633 }
642 634
643 void TestingProfile::ResetRequestContext() { 635 void TestingProfile::ResetRequestContext() {
644 // Any objects holding live URLFetchers should be deleted before the request 636 // Any objects holding live URLFetchers should be deleted before the request
645 // context is shut down. 637 // context is shut down.
646 TemplateURLFetcherFactory::ShutdownForProfile(this); 638 TemplateURLFetcherFactory::ShutdownForProfile(this);
647 639
648 request_context_ = NULL; 640 request_context_ = NULL;
649 } 641 }
650 642
651 net::URLRequestContextGetter* TestingProfile::GetMediaRequestContext() { 643 net::URLRequestContextGetter* TestingProfile::GetMediaRequestContext() {
652 return NULL; 644 return NULL;
653 } 645 }
654 646
655 net::URLRequestContextGetter* 647 net::URLRequestContextGetter*
656 TestingProfile::GetMediaRequestContextForRenderProcess( 648 TestingProfile::GetMediaRequestContextForRenderProcess(
657 int renderer_child_id) { 649 int renderer_child_id) {
658 return NULL; 650 return NULL;
659 } 651 }
660 652
661 net::URLRequestContextGetter* 653 net::URLRequestContextGetter*
662 TestingProfile::GetMediaRequestContextForStoragePartition( 654 TestingProfile::GetMediaRequestContextForStoragePartition(
663 const std::string& partition_id) { 655 const FilePath& partition_path,
656 bool in_memory) {
664 return NULL; 657 return NULL;
665 } 658 }
666 659
667 net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() { 660 net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() {
668 if (!extensions_request_context_) 661 if (!extensions_request_context_)
669 extensions_request_context_ = new TestExtensionURLRequestContextGetter(); 662 extensions_request_context_ = new TestExtensionURLRequestContextGetter();
670 return extensions_request_context_.get(); 663 return extensions_request_context_.get();
671 } 664 }
672 665
673 net::SSLConfigService* TestingProfile::GetSSLConfigService() { 666 net::SSLConfigService* TestingProfile::GetSSLConfigService() {
674 return NULL; 667 return NULL;
675 } 668 }
676 669
677 net::URLRequestContextGetter* 670 net::URLRequestContextGetter*
678 TestingProfile::GetRequestContextForStoragePartition( 671 TestingProfile::GetRequestContextForStoragePartition(
679 const std::string& partition_id) { 672 const FilePath& partition_path,
673 bool in_memory) {
680 // We don't test storage partitions here yet, so returning the same dummy 674 // We don't test storage partitions here yet, so returning the same dummy
681 // context is sufficient for now. 675 // context is sufficient for now.
682 return GetRequestContext(); 676 return GetRequestContext();
683 } 677 }
684 678
685 content::ResourceContext* TestingProfile::GetResourceContext() { 679 content::ResourceContext* TestingProfile::GetResourceContext() {
686 if (!resource_context_.get()) 680 if (!resource_context_.get())
687 resource_context_.reset(new content::MockResourceContext()); 681 resource_context_.reset(new content::MockResourceContext());
688 return resource_context_.get(); 682 return resource_context_.get();
689 } 683 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { 829 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() {
836 DCHECK(!build_called_); 830 DCHECK(!build_called_);
837 build_called_ = true; 831 build_called_ = true;
838 return scoped_ptr<TestingProfile>(new TestingProfile( 832 return scoped_ptr<TestingProfile>(new TestingProfile(
839 path_, 833 path_,
840 delegate_, 834 delegate_,
841 extension_policy_, 835 extension_policy_,
842 pref_service_.Pass(), 836 pref_service_.Pass(),
843 user_cloud_policy_manager_.Pass())); 837 user_cloud_policy_manager_.Pass()));
844 } 838 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698