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

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

Issue 2524553002: [Extensions] Create ChromeTestExtensionLoader (Closed)
Patch Set: compile Created 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_test_with_install.h" 5 #include "chrome/browser/extensions/extension_service_test_with_install.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/extensions/chrome_test_extension_loader.h"
9 #include "chrome/browser/extensions/crx_installer.h" 10 #include "chrome/browser/extensions/crx_installer.h"
10 #include "chrome/browser/extensions/extension_creator.h" 11 #include "chrome/browser/extensions/extension_creator.h"
11 #include "chrome/browser/extensions/extension_error_reporter.h" 12 #include "chrome/browser/extensions/extension_error_reporter.h"
13 #include "chrome/browser/profiles/profile.h"
12 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
13 #include "extensions/browser/extension_registry.h" 15 #include "extensions/browser/extension_registry.h"
14 #include "extensions/browser/notification_types.h" 16 #include "extensions/browser/notification_types.h"
15 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
16 18
17 namespace extensions { 19 namespace extensions {
18 20
19 namespace { 21 namespace {
20 22
21 struct ExtensionsOrder { 23 struct ExtensionsOrder {
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 412 }
411 413
412 // Create a CrxInstaller and install the CRX file. 414 // Create a CrxInstaller and install the CRX file.
413 // Instead of calling this method yourself, use InstallCRX(), which does extra 415 // Instead of calling this method yourself, use InstallCRX(), which does extra
414 // error checking. 416 // error checking.
415 void ExtensionServiceTestWithInstall::InstallCRXInternal( 417 void ExtensionServiceTestWithInstall::InstallCRXInternal(
416 const base::FilePath& crx_path, 418 const base::FilePath& crx_path,
417 Manifest::Location install_location, 419 Manifest::Location install_location,
418 InstallState install_state, 420 InstallState install_state,
419 int creation_flags) { 421 int creation_flags) {
420 EXPECT_TRUE(base::PathExists(crx_path)) << "Path does not exist: " 422 ChromeTestExtensionLoader extension_loader(profile());
421 << crx_path.value().c_str(); 423 extension_loader.set_location(install_location);
422 // no client (silent install) 424 extension_loader.set_creation_flags(creation_flags);
423 scoped_refptr<CrxInstaller> installer( 425 extension_loader.set_should_fail(install_state == INSTALL_FAILED);
424 CrxInstaller::CreateSilent(service())); 426 // TODO(devlin): We shouldn't be granting permissions based on whether
425 installer->set_install_source(install_location); 427 // something was installed by default. That's weird.
426 installer->set_creation_flags(creation_flags); 428 extension_loader.set_grant_permissions(
427 if (!(creation_flags & Extension::WAS_INSTALLED_BY_DEFAULT)) 429 (creation_flags & Extension::WAS_INSTALLED_BY_DEFAULT) == 0);
428 installer->set_allow_silent_install(true); 430 // TODO(devlin): We shouldn't ignore manifest warnings here, but we always
429 431 // did so a bunch of stuff fails. Migrate this over.
430 content::WindowedNotificationObserver observer( 432 extension_loader.set_ignore_manifest_warnings(true);
431 extensions::NOTIFICATION_CRX_INSTALLER_DONE, 433 extension_loader.LoadExtension(crx_path);
432 content::Source<extensions::CrxInstaller>(installer.get()));
433
434 installer->InstallCrx(crx_path);
435 observer.Wait();
436 } 434 }
437 435
438 } // namespace extensions 436 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698