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

Side by Side Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 12546016: Remove the Extensions URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android webview init fix merged in. Created 7 years, 3 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/browser/extensions/extension_service_unittest.h" 5 #include "chrome/browser/extensions/extension_service_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/at_exit.h" 11 #include "base/at_exit.h"
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/file_util.h" 15 #include "base/file_util.h"
16 #include "base/files/file_enumerator.h" 16 #include "base/files/file_enumerator.h"
17 #include "base/files/scoped_temp_dir.h" 17 #include "base/files/scoped_temp_dir.h"
18 #include "base/json/json_file_value_serializer.h" 18 #include "base/json/json_file_value_serializer.h"
19 #include "base/json/json_reader.h" 19 #include "base/json/json_reader.h"
20 #include "base/json/json_string_value_serializer.h" 20 #include "base/json/json_string_value_serializer.h"
21 #include "base/memory/scoped_ptr.h" 21 #include "base/memory/scoped_ptr.h"
22 #include "base/memory/weak_ptr.h" 22 #include "base/memory/weak_ptr.h"
23 #include "base/message_loop/message_loop.h" 23 #include "base/message_loop/message_loop.h"
24 #include "base/path_service.h" 24 #include "base/path_service.h"
25 #include "base/run_loop.h"
25 #include "base/stl_util.h" 26 #include "base/stl_util.h"
26 #include "base/strings/string16.h" 27 #include "base/strings/string16.h"
27 #include "base/strings/string_number_conversions.h" 28 #include "base/strings/string_number_conversions.h"
28 #include "base/strings/string_util.h" 29 #include "base/strings/string_util.h"
29 #include "base/strings/utf_string_conversions.h" 30 #include "base/strings/utf_string_conversions.h"
30 #include "base/version.h" 31 #include "base/version.h"
31 #include "chrome/browser/browser_process.h" 32 #include "chrome/browser/browser_process.h"
32 #include "chrome/browser/chrome_notification_types.h" 33 #include "chrome/browser/chrome_notification_types.h"
33 #include "chrome/browser/extensions/app_sync_data.h" 34 #include "chrome/browser/extensions/app_sync_data.h"
34 #include "chrome/browser/extensions/component_loader.h" 35 #include "chrome/browser/extensions/component_loader.h"
(...skipping 4067 matching lines...) Expand 10 before | Expand all | Expand 10 after
4102 // Load a test extension. 4103 // Load a test extension.
4103 base::FilePath path = data_dir_; 4104 base::FilePath path = data_dir_;
4104 path = path.AppendASCII("good.crx"); 4105 path = path.AppendASCII("good.crx");
4105 const Extension* extension = InstallCRX(path, INSTALL_NEW); 4106 const Extension* extension = InstallCRX(path, INSTALL_NEW);
4106 ASSERT_TRUE(extension); 4107 ASSERT_TRUE(extension);
4107 GURL ext_url(extension->url()); 4108 GURL ext_url(extension->url());
4108 std::string origin_id = webkit_database::GetIdentifierFromOrigin(ext_url); 4109 std::string origin_id = webkit_database::GetIdentifierFromOrigin(ext_url);
4109 4110
4110 // Set a cookie for the extension. 4111 // Set a cookie for the extension.
4111 net::CookieMonster* cookie_monster = 4112 net::CookieMonster* cookie_monster =
4112 profile_->GetRequestContextForExtensions()->GetURLRequestContext()-> 4113 BrowserContext::GetDefaultStoragePartition(profile_.get())->
4113 cookie_store()->GetCookieMonster(); 4114 GetCookieStoreForScheme(ext_url.scheme())->GetCookieMonster();
4114 ASSERT_TRUE(cookie_monster); 4115 ASSERT_TRUE(cookie_monster);
4115 net::CookieOptions options; 4116 net::CookieOptions options;
4116 cookie_monster->SetCookieWithOptionsAsync( 4117 cookie_monster->SetCookieWithOptionsAsync(
4117 ext_url, "dummy=value", options, 4118 ext_url, "dummy=value", options,
4118 base::Bind(&ExtensionCookieCallback::SetCookieCallback, 4119 base::Bind(&ExtensionCookieCallback::SetCookieCallback,
4119 base::Unretained(&callback))); 4120 base::Unretained(&callback)));
4120 base::RunLoop().RunUntilIdle(); 4121 base::RunLoop().RunUntilIdle();
4121 EXPECT_TRUE(callback.result_); 4122 EXPECT_TRUE(callback.result_);
4122 4123
4123 cookie_monster->GetAllCookiesForURLAsync( 4124 cookie_monster->GetAllCookiesForURLAsync(
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
4218 EXPECT_TRUE(extension->web_extent().MatchesURL( 4219 EXPECT_TRUE(extension->web_extent().MatchesURL(
4219 extensions::AppLaunchInfo::GetFullLaunchURL(extension))); 4220 extensions::AppLaunchInfo::GetFullLaunchURL(extension)));
4220 const GURL origin2( 4221 const GURL origin2(
4221 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin()); 4222 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin());
4222 EXPECT_EQ(origin1, origin2); 4223 EXPECT_EQ(origin1, origin2);
4223 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 4224 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
4224 IsStorageUnlimited(origin2)); 4225 IsStorageUnlimited(origin2));
4225 4226
4226 // Set a cookie for the extension. 4227 // Set a cookie for the extension.
4227 net::CookieMonster* cookie_monster = 4228 net::CookieMonster* cookie_monster =
4228 profile_->GetRequestContext()->GetURLRequestContext()-> 4229 BrowserContext::GetDefaultStoragePartition(profile_.get())->
4229 cookie_store()->GetCookieMonster(); 4230 GetCookieStoreForScheme(origin1.scheme())->GetCookieMonster();
4230 ASSERT_TRUE(cookie_monster); 4231 ASSERT_TRUE(cookie_monster);
4231 net::CookieOptions options; 4232 net::CookieOptions options;
4232 cookie_monster->SetCookieWithOptionsAsync( 4233 cookie_monster->SetCookieWithOptionsAsync(
4233 origin1, "dummy=value", options, 4234 origin1, "dummy=value", options,
4234 base::Bind(&ExtensionCookieCallback::SetCookieCallback, 4235 base::Bind(&ExtensionCookieCallback::SetCookieCallback,
4235 base::Unretained(&callback))); 4236 base::Unretained(&callback)));
4236 base::RunLoop().RunUntilIdle(); 4237 base::RunLoop().RunUntilIdle();
4237 EXPECT_TRUE(callback.result_); 4238 EXPECT_TRUE(callback.result_);
4238 4239
4239 cookie_monster->GetAllCookiesForURLAsync( 4240 cookie_monster->GetAllCookiesForURLAsync(
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
4915 TEST(ExtensionServiceTestSimple, Enabledness) { 4916 TEST(ExtensionServiceTestSimple, Enabledness) {
4916 // Make sure the PluginService singleton is destroyed at the end of the test. 4917 // Make sure the PluginService singleton is destroyed at the end of the test.
4917 base::ShadowingAtExitManager at_exit_manager; 4918 base::ShadowingAtExitManager at_exit_manager;
4918 #if defined(ENABLE_PLUGINS) 4919 #if defined(ENABLE_PLUGINS)
4919 content::PluginService::GetInstance()->Init(); 4920 content::PluginService::GetInstance()->Init();
4920 content::PluginService::GetInstance()->DisablePluginsDiscoveryForTesting(); 4921 content::PluginService::GetInstance()->DisablePluginsDiscoveryForTesting();
4921 #endif 4922 #endif
4922 4923
4923 ExtensionErrorReporter::Init(false); // no noisy errors 4924 ExtensionErrorReporter::Init(false); // no noisy errors
4924 ExtensionsReadyRecorder recorder; 4925 ExtensionsReadyRecorder recorder;
4926 content::TestBrowserThreadBundle thread_bundle;
4925 scoped_ptr<TestingProfile> profile(new TestingProfile()); 4927 scoped_ptr<TestingProfile> profile(new TestingProfile());
4926 content::TestBrowserThreadBundle thread_bundle_;
4927 #if defined OS_CHROMEOS 4928 #if defined OS_CHROMEOS
4928 chromeos::ScopedTestDeviceSettingsService device_settings_service; 4929 chromeos::ScopedTestDeviceSettingsService device_settings_service;
4929 chromeos::ScopedTestCrosSettings cros_settings; 4930 chromeos::ScopedTestCrosSettings cros_settings;
4930 scoped_ptr<chromeos::ScopedTestUserManager> user_manager( 4931 scoped_ptr<chromeos::ScopedTestUserManager> user_manager(
4931 new chromeos::ScopedTestUserManager); 4932 new chromeos::ScopedTestUserManager);
4932 #endif 4933 #endif
4933 scoped_ptr<CommandLine> command_line; 4934 scoped_ptr<CommandLine> command_line;
4934 base::FilePath install_dir = profile->GetPath() 4935 base::FilePath install_dir = profile->GetPath()
4935 .AppendASCII(extensions::kInstallDirectoryName); 4936 .AppendASCII(extensions::kInstallDirectoryName);
4936 4937
(...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after
6370 EXPECT_TRUE(notifications.CheckNotifications( 6371 EXPECT_TRUE(notifications.CheckNotifications(
6371 chrome::NOTIFICATION_EXTENSION_INSTALLED)); 6372 chrome::NOTIFICATION_EXTENSION_INSTALLED));
6372 6373
6373 EXPECT_TRUE(service_->GetInstalledExtension(id)); 6374 EXPECT_TRUE(service_->GetInstalledExtension(id));
6374 EXPECT_FALSE(service_->extensions()->Contains(id)); 6375 EXPECT_FALSE(service_->extensions()->Contains(id));
6375 EXPECT_TRUE(service_->blacklisted_extensions()->Contains(id)); 6376 EXPECT_TRUE(service_->blacklisted_extensions()->Contains(id));
6376 EXPECT_TRUE(service_->extension_prefs()->IsExtensionBlacklisted(id)); 6377 EXPECT_TRUE(service_->extension_prefs()->IsExtensionBlacklisted(id));
6377 EXPECT_TRUE( 6378 EXPECT_TRUE(
6378 service_->extension_prefs()->IsBlacklistedExtensionAcknowledged(id)); 6379 service_->extension_prefs()->IsBlacklistedExtensionAcknowledged(id));
6379 } 6380 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698