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

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

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

Powered by Google App Engine
This is Rietveld 408576698