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

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: Missed a merging of removed variable. 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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 DownloadManagerDelegate* TestingProfile::GetDownloadManagerDelegate() { 600 DownloadManagerDelegate* TestingProfile::GetDownloadManagerDelegate() {
599 return NULL; 601 return NULL;
600 } 602 }
601 603
602 net::URLRequestContextGetter* TestingProfile::GetRequestContext() { 604 net::URLRequestContextGetter* TestingProfile::GetRequestContext() {
603 return request_context_.get(); 605 return request_context_.get();
604 } 606 }
605 607
606 net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess( 608 net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess(
607 int renderer_child_id) { 609 int renderer_child_id) {
608 ExtensionService* extension_service = 610 content::RenderProcessHost* rph = content::RenderProcessHost::FromID(
609 extensions::ExtensionSystem::Get(this)->extension_service(); 611 renderer_child_id);
610 if (extension_service) { 612 content::StoragePartition* storage_partition = rph->GetStoragePartition();
611 const extensions::Extension* extension = 613
612 extension_service->GetIsolatedAppForRenderer(renderer_child_id); 614 // TODO(nasko): Remove this conditional, once webview tag creates a proper
613 if (extension) 615 // storage partition.
614 return GetRequestContextForStoragePartition(extension->id()); 616 if (rph->IsGuest()) {
617 return GetRequestContextForStoragePartition(
618 storage_partition->GetPath(), true);
615 } 619 }
616 620
617 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( 621 return storage_partition->GetURLRequestContext();
618 renderer_child_id);
619 if (rph && rph->IsGuest()) {
620 // For guest processes (used by the browser tag), we need to isolate the
621 // storage.
622 // TODO(nasko): Until we have proper storage partitions, create a
623 // non-persistent context using the RPH's id.
624 std::string id("guest-");
625 id.append(base::IntToString(renderer_child_id));
626 return GetRequestContextForStoragePartition(id);
627 }
628
629 return GetRequestContext();
630 } 622 }
631 623
632 void TestingProfile::CreateRequestContext() { 624 void TestingProfile::CreateRequestContext() {
633 if (!request_context_) 625 if (!request_context_)
634 request_context_ = 626 request_context_ =
635 new TestURLRequestContextGetter( 627 new TestURLRequestContextGetter(
636 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); 628 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
637 } 629 }
638 630
639 void TestingProfile::ResetRequestContext() { 631 void TestingProfile::ResetRequestContext() {
640 // Any objects holding live URLFetchers should be deleted before the request 632 // Any objects holding live URLFetchers should be deleted before the request
641 // context is shut down. 633 // context is shut down.
642 TemplateURLFetcherFactory::ShutdownForProfile(this); 634 TemplateURLFetcherFactory::ShutdownForProfile(this);
643 635
644 request_context_ = NULL; 636 request_context_ = NULL;
645 } 637 }
646 638
647 net::URLRequestContextGetter* TestingProfile::GetMediaRequestContext() { 639 net::URLRequestContextGetter* TestingProfile::GetMediaRequestContext() {
648 return NULL; 640 return NULL;
649 } 641 }
650 642
651 net::URLRequestContextGetter* 643 net::URLRequestContextGetter*
652 TestingProfile::GetMediaRequestContextForRenderProcess( 644 TestingProfile::GetMediaRequestContextForRenderProcess(
653 int renderer_child_id) { 645 int renderer_child_id) {
654 return NULL; 646 return NULL;
655 } 647 }
656 648
657 net::URLRequestContextGetter* 649 net::URLRequestContextGetter*
658 TestingProfile::GetMediaRequestContextForStoragePartition( 650 TestingProfile::GetMediaRequestContextForStoragePartition(
659 const std::string& partition_id) { 651 const FilePath& partition_path,
652 bool in_memory) {
660 return NULL; 653 return NULL;
661 } 654 }
662 655
663 net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() { 656 net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() {
664 if (!extensions_request_context_) 657 if (!extensions_request_context_)
665 extensions_request_context_ = new TestExtensionURLRequestContextGetter(); 658 extensions_request_context_ = new TestExtensionURLRequestContextGetter();
666 return extensions_request_context_.get(); 659 return extensions_request_context_.get();
667 } 660 }
668 661
669 net::SSLConfigService* TestingProfile::GetSSLConfigService() { 662 net::SSLConfigService* TestingProfile::GetSSLConfigService() {
670 return NULL; 663 return NULL;
671 } 664 }
672 665
673 net::URLRequestContextGetter* 666 net::URLRequestContextGetter*
674 TestingProfile::GetRequestContextForStoragePartition( 667 TestingProfile::GetRequestContextForStoragePartition(
675 const std::string& partition_id) { 668 const FilePath& partition_path,
669 bool in_memory) {
676 // We don't test storage partitions here yet, so returning the same dummy 670 // We don't test storage partitions here yet, so returning the same dummy
677 // context is sufficient for now. 671 // context is sufficient for now.
678 return GetRequestContext(); 672 return GetRequestContext();
679 } 673 }
680 674
681 content::ResourceContext* TestingProfile::GetResourceContext() { 675 content::ResourceContext* TestingProfile::GetResourceContext() {
682 if (!resource_context_.get()) 676 if (!resource_context_.get())
683 resource_context_.reset(new content::MockResourceContext()); 677 resource_context_.reset(new content::MockResourceContext());
684 return resource_context_.get(); 678 return resource_context_.get();
685 } 679 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { 825 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() {
832 DCHECK(!build_called_); 826 DCHECK(!build_called_);
833 build_called_ = true; 827 build_called_ = true;
834 return scoped_ptr<TestingProfile>(new TestingProfile( 828 return scoped_ptr<TestingProfile>(new TestingProfile(
835 path_, 829 path_,
836 delegate_, 830 delegate_,
837 extension_policy_, 831 extension_policy_,
838 pref_service_.Pass(), 832 pref_service_.Pass(),
839 user_cloud_policy_manager_.Pass())); 833 user_cloud_policy_manager_.Pass()));
840 } 834 }
OLDNEW
« no previous file with comments | « chrome/test/base/testing_profile.h ('k') | content/browser/download/download_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698