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

Side by Side Diff: chrome/browser/extensions/api/management/management_browsertest.cc

Issue 11365181: Remove GetExtensionService from Profile. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: replace missing extension_system include Created 8 years 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
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "chrome/browser/extensions/autoupdate_interceptor.h" 9 #include "chrome/browser/extensions/autoupdate_interceptor.h"
10 #include "chrome/browser/extensions/extension_browsertest.h" 10 #include "chrome/browser/extensions/extension_browsertest.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 #if defined(OS_WIN) 117 #if defined(OS_WIN)
118 // http://crbug.com/141913 118 // http://crbug.com/141913
119 #define MAYBE_InstallRequiresConfirm FLAKY_InstallRequiresConfirm 119 #define MAYBE_InstallRequiresConfirm FLAKY_InstallRequiresConfirm
120 #else 120 #else
121 #define MAYBE_InstallRequiresConfirm InstallRequiresConfirm 121 #define MAYBE_InstallRequiresConfirm InstallRequiresConfirm
122 #endif 122 #endif
123 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, MAYBE_InstallRequiresConfirm) { 123 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, MAYBE_InstallRequiresConfirm) {
124 // Installing the extension without an auto confirming UI should result in 124 // Installing the extension without an auto confirming UI should result in
125 // it being disabled, since good.crx has permissions that require approval. 125 // it being disabled, since good.crx has permissions that require approval.
126 ExtensionService* service = browser()->profile()->GetExtensionService(); 126 ExtensionService* service = extensions::ExtensionSystem::Get(
127 browser()->profile())->extension_service();
127 std::string id = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; 128 std::string id = "ldnnhddmnhbkjipkidpdiheffobcpfmf";
128 ASSERT_FALSE(InstallExtension(test_data_dir_.AppendASCII("good.crx"), 0)); 129 ASSERT_FALSE(InstallExtension(test_data_dir_.AppendASCII("good.crx"), 0));
129 ASSERT_TRUE(service->GetExtensionById(id, true)); 130 ASSERT_TRUE(service->GetExtensionById(id, true));
130 UninstallExtension(id); 131 UninstallExtension(id);
131 132
132 // And the install should succeed when the permissions are accepted. 133 // And the install should succeed when the permissions are accepted.
133 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( 134 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(
134 test_data_dir_.AppendASCII("good.crx"), 1, browser())); 135 test_data_dir_.AppendASCII("good.crx"), 1, browser()));
135 UninstallExtension(id); 136 UninstallExtension(id);
136 } 137 }
137 138
138 // Tests that disabling and re-enabling an extension works. 139 // Tests that disabling and re-enabling an extension works.
139 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, DisableEnable) { 140 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, DisableEnable) {
140 ExtensionProcessManager* manager = 141 ExtensionProcessManager* manager =
141 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); 142 extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
142 ExtensionService* service = browser()->profile()->GetExtensionService(); 143 ExtensionService* service = extensions::ExtensionSystem::Get(
144 browser()->profile())->extension_service();
143 const size_t size_before = service->extensions()->size(); 145 const size_t size_before = service->extensions()->size();
144 146
145 // Load an extension, expect the background page to be available. 147 // Load an extension, expect the background page to be available.
146 std::string extension_id = "bjafgdebaacbbbecmhlhpofkepfkgcpa"; 148 std::string extension_id = "bjafgdebaacbbbecmhlhpofkepfkgcpa";
147 ASSERT_TRUE(LoadExtension( 149 ASSERT_TRUE(LoadExtension(
148 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") 150 test_data_dir_.AppendASCII("good").AppendASCII("Extensions")
149 .AppendASCII(extension_id) 151 .AppendASCII(extension_id)
150 .AppendASCII("1.0"))); 152 .AppendASCII("1.0")));
151 ASSERT_EQ(size_before + 1, service->extensions()->size()); 153 ASSERT_EQ(size_before + 1, service->extensions()->size());
152 EXPECT_EQ(0u, service->disabled_extensions()->size()); 154 EXPECT_EQ(0u, service->disabled_extensions()->size());
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 new extensions::AutoUpdateInterceptor()); 254 new extensions::AutoUpdateInterceptor());
253 net::URLFetcher::SetEnableInterceptionForTests(true); 255 net::URLFetcher::SetEnableInterceptionForTests(true);
254 256
255 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", 257 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest",
256 basedir.AppendASCII("manifest_v2.xml")); 258 basedir.AppendASCII("manifest_v2.xml"));
257 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", 259 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx",
258 basedir.AppendASCII("v2.crx")); 260 basedir.AppendASCII("v2.crx"));
259 261
260 // Install version 1 of the extension. 262 // Install version 1 of the extension.
261 ExtensionTestMessageListener listener1("v1 installed", false); 263 ExtensionTestMessageListener listener1("v1 installed", false);
262 ExtensionService* service = browser()->profile()->GetExtensionService(); 264 ExtensionService* service = extensions::ExtensionSystem::Get(
265 browser()->profile())->extension_service();
263 const size_t size_before = service->extensions()->size(); 266 const size_t size_before = service->extensions()->size();
264 ASSERT_TRUE(service->disabled_extensions()->is_empty()); 267 ASSERT_TRUE(service->disabled_extensions()->is_empty());
265 const Extension* extension = 268 const Extension* extension =
266 InstallExtension(basedir.AppendASCII("v1.crx"), 1); 269 InstallExtension(basedir.AppendASCII("v1.crx"), 1);
267 ASSERT_TRUE(extension); 270 ASSERT_TRUE(extension);
268 listener1.WaitUntilSatisfied(); 271 listener1.WaitUntilSatisfied();
269 ASSERT_EQ(size_before + 1, service->extensions()->size()); 272 ASSERT_EQ(size_before + 1, service->extensions()->size());
270 ASSERT_EQ("ogjcoiohnmldgjemafoockdghcjciccf", extension->id()); 273 ASSERT_EQ("ogjcoiohnmldgjemafoockdghcjciccf", extension->id());
271 ASSERT_EQ("1.0", extension->VersionString()); 274 ASSERT_EQ("1.0", extension->VersionString());
272 275
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 new extensions::AutoUpdateInterceptor()); 339 new extensions::AutoUpdateInterceptor());
337 net::URLFetcher::SetEnableInterceptionForTests(true); 340 net::URLFetcher::SetEnableInterceptionForTests(true);
338 341
339 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", 342 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest",
340 basedir.AppendASCII("manifest_v2.xml")); 343 basedir.AppendASCII("manifest_v2.xml"));
341 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", 344 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx",
342 basedir.AppendASCII("v2.crx")); 345 basedir.AppendASCII("v2.crx"));
343 346
344 // Install version 1 of the extension. 347 // Install version 1 of the extension.
345 ExtensionTestMessageListener listener1("v1 installed", false); 348 ExtensionTestMessageListener listener1("v1 installed", false);
346 ExtensionService* service = browser()->profile()->GetExtensionService(); 349 ExtensionService* service = extensions::ExtensionSystem::Get(
350 browser()->profile())->extension_service();
347 const size_t enabled_size_before = service->extensions()->size(); 351 const size_t enabled_size_before = service->extensions()->size();
348 const size_t disabled_size_before = service->disabled_extensions()->size(); 352 const size_t disabled_size_before = service->disabled_extensions()->size();
349 const Extension* extension = 353 const Extension* extension =
350 InstallExtension(basedir.AppendASCII("v1.crx"), 1); 354 InstallExtension(basedir.AppendASCII("v1.crx"), 1);
351 ASSERT_TRUE(extension); 355 ASSERT_TRUE(extension);
352 listener1.WaitUntilSatisfied(); 356 listener1.WaitUntilSatisfied();
353 DisableExtension(extension->id()); 357 DisableExtension(extension->id());
354 ASSERT_EQ(disabled_size_before + 1, service->disabled_extensions()->size()); 358 ASSERT_EQ(disabled_size_before + 1, service->disabled_extensions()->size());
355 ASSERT_EQ(enabled_size_before, service->extensions()->size()); 359 ASSERT_EQ(enabled_size_before, service->extensions()->size());
356 ASSERT_EQ("ogjcoiohnmldgjemafoockdghcjciccf", extension->id()); 360 ASSERT_EQ("ogjcoiohnmldgjemafoockdghcjciccf", extension->id());
(...skipping 26 matching lines...) Expand all
383 EnableExtension(extension->id()); 387 EnableExtension(extension->id());
384 listener2.WaitUntilSatisfied(); 388 listener2.WaitUntilSatisfied();
385 ASSERT_TRUE(notification_listener.started()); 389 ASSERT_TRUE(notification_listener.started());
386 ASSERT_TRUE(notification_listener.finished()); 390 ASSERT_TRUE(notification_listener.finished());
387 ASSERT_TRUE(ContainsKey(notification_listener.updates(), 391 ASSERT_TRUE(ContainsKey(notification_listener.updates(),
388 "ogjcoiohnmldgjemafoockdghcjciccf")); 392 "ogjcoiohnmldgjemafoockdghcjciccf"));
389 notification_listener.Reset(); 393 notification_listener.Reset();
390 } 394 }
391 395
392 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalUrlUpdate) { 396 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalUrlUpdate) {
393 ExtensionService* service = browser()->profile()->GetExtensionService(); 397 ExtensionService* service = extensions::ExtensionSystem::Get(
398 browser()->profile())->extension_service();
394 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; 399 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf";
395 // We don't want autoupdate blacklist checks. 400 // We don't want autoupdate blacklist checks.
396 extensions::ExtensionUpdater::CheckParams params; 401 extensions::ExtensionUpdater::CheckParams params;
397 params.check_blacklist = false; 402 params.check_blacklist = false;
398 403
399 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); 404 FilePath basedir = test_data_dir_.AppendASCII("autoupdate");
400 405
401 // Note: This interceptor gets requests on the IO thread. 406 // Note: This interceptor gets requests on the IO thread.
402 scoped_refptr<extensions::AutoUpdateInterceptor> interceptor( 407 scoped_refptr<extensions::AutoUpdateInterceptor> interceptor(
403 new extensions::AutoUpdateInterceptor()); 408 new extensions::AutoUpdateInterceptor());
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 const char* kForceInstallNotEmptyHelp = 473 const char* kForceInstallNotEmptyHelp =
469 "A policy may already be controlling the list of force-installed " 474 "A policy may already be controlling the list of force-installed "
470 "extensions. Please remove all policy settings from your computer " 475 "extensions. Please remove all policy settings from your computer "
471 "before running tests. E.g. from /etc/chromium/policies Linux or " 476 "before running tests. E.g. from /etc/chromium/policies Linux or "
472 "from the registry on Windows, etc."; 477 "from the registry on Windows, etc.";
473 478
474 } 479 }
475 480
476 // See http://crbug.com/57378 for flakiness details. 481 // See http://crbug.com/57378 for flakiness details.
477 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalPolicyRefresh) { 482 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalPolicyRefresh) {
478 ExtensionService* service = browser()->profile()->GetExtensionService(); 483 ExtensionService* service = extensions::ExtensionSystem::Get(
484 browser()->profile())->extension_service();
479 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; 485 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf";
480 // We don't want autoupdate blacklist checks. 486 // We don't want autoupdate blacklist checks.
481 extensions::ExtensionUpdater::CheckParams params; 487 extensions::ExtensionUpdater::CheckParams params;
482 params.check_blacklist = false; 488 params.check_blacklist = false;
483 489
484 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); 490 FilePath basedir = test_data_dir_.AppendASCII("autoupdate");
485 491
486 // Note: This interceptor gets requests on the IO thread. 492 // Note: This interceptor gets requests on the IO thread.
487 scoped_refptr<extensions::AutoUpdateInterceptor> interceptor( 493 scoped_refptr<extensions::AutoUpdateInterceptor> interceptor(
488 new extensions::AutoUpdateInterceptor()); 494 new extensions::AutoUpdateInterceptor());
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 551
546 // See http://crbug.com/103371 and http://crbug.com/120640. 552 // See http://crbug.com/103371 and http://crbug.com/120640.
547 #if defined(ADDRESS_SANITIZER) 553 #if defined(ADDRESS_SANITIZER)
548 #define MAYBE_PolicyOverridesUserInstall DISABLED_PolicyOverridesUserInstall 554 #define MAYBE_PolicyOverridesUserInstall DISABLED_PolicyOverridesUserInstall
549 #else 555 #else
550 #define MAYBE_PolicyOverridesUserInstall PolicyOverridesUserInstall 556 #define MAYBE_PolicyOverridesUserInstall PolicyOverridesUserInstall
551 #endif 557 #endif
552 558
553 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, 559 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest,
554 MAYBE_PolicyOverridesUserInstall) { 560 MAYBE_PolicyOverridesUserInstall) {
555 ExtensionService* service = browser()->profile()->GetExtensionService(); 561 ExtensionService* service = extensions::ExtensionSystem::Get(
562 browser()->profile())->extension_service();
556 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf"; 563 const char* kExtensionId = "ogjcoiohnmldgjemafoockdghcjciccf";
557 extensions::ExtensionUpdater::CheckParams params; 564 extensions::ExtensionUpdater::CheckParams params;
558 params.check_blacklist = false; 565 params.check_blacklist = false;
559 service->updater()->set_default_check_params(params); 566 service->updater()->set_default_check_params(params);
560 const size_t size_before = service->extensions()->size(); 567 const size_t size_before = service->extensions()->size();
561 FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); 568 FilePath basedir = test_data_dir_.AppendASCII("autoupdate");
562 ASSERT_TRUE(service->disabled_extensions()->is_empty()); 569 ASSERT_TRUE(service->disabled_extensions()->is_empty());
563 570
564 // Note: This interceptor gets requests on the IO thread. 571 // Note: This interceptor gets requests on the IO thread.
565 scoped_refptr<extensions::AutoUpdateInterceptor> interceptor( 572 scoped_refptr<extensions::AutoUpdateInterceptor> interceptor(
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 std::string(kExtensionId) + ";http://localhost/autoupdate/manifest")); 646 std::string(kExtensionId) + ";http://localhost/autoupdate/manifest"));
640 } 647 }
641 ASSERT_TRUE(WaitForExtensionInstall()); 648 ASSERT_TRUE(WaitForExtensionInstall());
642 ASSERT_EQ(size_before + 1, service->extensions()->size()); 649 ASSERT_EQ(size_before + 1, service->extensions()->size());
643 extension = service->GetExtensionById(kExtensionId, false); 650 extension = service->GetExtensionById(kExtensionId, false);
644 ASSERT_TRUE(extension); 651 ASSERT_TRUE(extension);
645 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, extension->location()); 652 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, extension->location());
646 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); 653 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId));
647 EXPECT_TRUE(service->disabled_extensions()->is_empty()); 654 EXPECT_TRUE(service->disabled_extensions()->is_empty());
648 } 655 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698