| OLD | NEW |
| 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 25 matching lines...) Expand all Loading... |
| 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/protector/protector_service_factory.h" | 43 #include "chrome/browser/protector/protector_service_factory.h" |
| 44 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" | 44 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" |
| 45 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" | 45 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" |
| 46 #include "chrome/browser/storage_partition_details.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 Loading... |
| 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) { |
| 625 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( |
| 626 renderer_child_id); |
| 627 CHECK(rph); |
| 628 content::StoragePartition* storage_partition = rph->GetStoragePartition(); |
| 629 |
| 623 ExtensionService* extension_service = | 630 ExtensionService* extension_service = |
| 624 extensions::ExtensionSystem::Get(this)->extension_service(); | 631 extensions::ExtensionSystem::Get(this)->extension_service(); |
| 625 if (extension_service) { | 632 if (extension_service) { |
| 626 const extensions::Extension* extension = | 633 const extensions::Extension* extension = |
| 627 extension_service->GetIsolatedAppForRenderer(renderer_child_id); | 634 extension_service->GetIsolatedAppForRenderer(renderer_child_id); |
| 628 if (extension) | 635 if (extension) |
| 629 return GetRequestContextForStoragePartition(extension->id()); | 636 return GetRequestContextForStoragePartition( |
| 637 storage_partition->GetPath(), |
| 638 storage_partition->IsInMemoryOnly()); |
| 630 } | 639 } |
| 631 | 640 |
| 632 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( | 641 if (rph->IsGuest()) { |
| 633 renderer_child_id); | |
| 634 if (rph && rph->IsGuest()) { | |
| 635 // For guest processes (used by the browser tag), we need to isolate the | 642 // For guest processes (used by the browser tag), we need to isolate the |
| 636 // storage. | 643 // storage. |
| 637 // TODO(nasko): Until we have proper storage partitions, create a | 644 // TODO(nasko): Pass the proper value for in_memory when the browser tag |
| 638 // non-persistent context using the RPH's id. | 645 // is wired properly with storage partition. |
| 639 std::string id("guest-"); | 646 return GetRequestContextForStoragePartition( |
| 640 id.append(base::IntToString(renderer_child_id)); | 647 storage_partition->GetPath(), true); |
| 641 return GetRequestContextForStoragePartition(id); | |
| 642 } | 648 } |
| 643 | 649 |
| 644 return GetRequestContext(); | 650 return GetRequestContext(); |
| 645 } | 651 } |
| 646 | 652 |
| 647 void TestingProfile::CreateRequestContext() { | 653 void TestingProfile::CreateRequestContext() { |
| 648 if (!request_context_) | 654 if (!request_context_) |
| 649 request_context_ = | 655 request_context_ = |
| 650 new TestURLRequestContextGetter( | 656 new TestURLRequestContextGetter( |
| 651 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 657 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 664 } | 670 } |
| 665 | 671 |
| 666 net::URLRequestContextGetter* | 672 net::URLRequestContextGetter* |
| 667 TestingProfile::GetMediaRequestContextForRenderProcess( | 673 TestingProfile::GetMediaRequestContextForRenderProcess( |
| 668 int renderer_child_id) { | 674 int renderer_child_id) { |
| 669 return NULL; | 675 return NULL; |
| 670 } | 676 } |
| 671 | 677 |
| 672 net::URLRequestContextGetter* | 678 net::URLRequestContextGetter* |
| 673 TestingProfile::GetMediaRequestContextForStoragePartition( | 679 TestingProfile::GetMediaRequestContextForStoragePartition( |
| 674 const std::string& partition_id) { | 680 const FilePath& partition_path, |
| 681 const bool& in_memory) { |
| 675 return NULL; | 682 return NULL; |
| 676 } | 683 } |
| 677 | 684 |
| 678 net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() { | 685 net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() { |
| 679 if (!extensions_request_context_) | 686 if (!extensions_request_context_) |
| 680 extensions_request_context_ = new TestExtensionURLRequestContextGetter(); | 687 extensions_request_context_ = new TestExtensionURLRequestContextGetter(); |
| 681 return extensions_request_context_.get(); | 688 return extensions_request_context_.get(); |
| 682 } | 689 } |
| 683 | 690 |
| 684 net::SSLConfigService* TestingProfile::GetSSLConfigService() { | 691 net::SSLConfigService* TestingProfile::GetSSLConfigService() { |
| 685 return NULL; | 692 return NULL; |
| 686 } | 693 } |
| 687 | 694 |
| 688 net::URLRequestContextGetter* | 695 net::URLRequestContextGetter* |
| 689 TestingProfile::GetRequestContextForStoragePartition( | 696 TestingProfile::GetRequestContextForStoragePartition( |
| 690 const std::string& partition_id) { | 697 const FilePath& partition_path, |
| 698 const bool& in_memory) { |
| 691 // We don't test storage partitions here yet, so returning the same dummy | 699 // We don't test storage partitions here yet, so returning the same dummy |
| 692 // context is sufficient for now. | 700 // context is sufficient for now. |
| 693 return GetRequestContext(); | 701 return GetRequestContext(); |
| 694 } | 702 } |
| 695 | 703 |
| 696 content::ResourceContext* TestingProfile::GetResourceContext() { | 704 content::ResourceContext* TestingProfile::GetResourceContext() { |
| 697 if (!resource_context_.get()) | 705 if (!resource_context_.get()) |
| 698 resource_context_.reset(new content::MockResourceContext()); | 706 resource_context_.reset(new content::MockResourceContext()); |
| 699 return resource_context_.get(); | 707 return resource_context_.get(); |
| 700 } | 708 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { | 854 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { |
| 847 DCHECK(!build_called_); | 855 DCHECK(!build_called_); |
| 848 build_called_ = true; | 856 build_called_ = true; |
| 849 return scoped_ptr<TestingProfile>(new TestingProfile( | 857 return scoped_ptr<TestingProfile>(new TestingProfile( |
| 850 path_, | 858 path_, |
| 851 delegate_, | 859 delegate_, |
| 852 extension_policy_, | 860 extension_policy_, |
| 853 pref_service_.Pass(), | 861 pref_service_.Pass(), |
| 854 user_cloud_policy_manager_.Pass())); | 862 user_cloud_policy_manager_.Pass())); |
| 855 } | 863 } |
| OLD | NEW |