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

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

Issue 10399069: Reland 137540 - Disable off-store extension installs by default. Also get rid of ExtensionService::… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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) 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/browser/download/download_crx_util.h" 5 #include "chrome/browser/download/download_crx_util.h"
6 #include "chrome/browser/download/download_service.h" 6 #include "chrome/browser/download/download_service.h"
7 #include "chrome/browser/download/download_service_factory.h" 7 #include "chrome/browser/download/download_service_factory.h"
8 #include "chrome/browser/download/download_test_observer.h" 8 #include "chrome/browser/download/download_test_observer.h"
9 #include "chrome/browser/extensions/crx_installer.h" 9 #include "chrome/browser/extensions/crx_installer.h"
10 #include "chrome/browser/extensions/extension_browsertest.h" 10 #include "chrome/browser/extensions/extension_browsertest.h"
11 #include "chrome/browser/extensions/extension_install_ui.h" 11 #include "chrome/browser/extensions/extension_install_ui.h"
12 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/extensions/extension_file_util.h" 16 #include "chrome/common/extensions/extension_file_util.h"
17 #include "chrome/common/extensions/extension_switch_utils.h"
17 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
18 19
19 class SkBitmap; 20 class SkBitmap;
20 21
21 namespace { 22 namespace {
22 23
23 // Observer waits for exactly one download to finish. 24 // Observer waits for exactly one download to finish.
24 25
25 class MockInstallUI : public ExtensionInstallUI { 26 class MockInstallUI : public ExtensionInstallUI {
26 public: 27 public:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 MockInstallUI* mock_install_ui = new MockInstallUI(browser()->profile()); 61 MockInstallUI* mock_install_ui = new MockInstallUI(browser()->profile());
61 FilePath ext_path = test_data_dir_.AppendASCII(ext_relpath); 62 FilePath ext_path = test_data_dir_.AppendASCII(ext_relpath);
62 63
63 std::string error; 64 std::string error;
64 base::DictionaryValue* parsed_manifest = 65 base::DictionaryValue* parsed_manifest =
65 extension_file_util::LoadManifest(ext_path, &error); 66 extension_file_util::LoadManifest(ext_path, &error);
66 if (!parsed_manifest) 67 if (!parsed_manifest)
67 return false; 68 return false;
68 69
69 scoped_ptr<WebstoreInstaller::Approval> approval( 70 scoped_ptr<WebstoreInstaller::Approval> approval(
70 new WebstoreInstaller::Approval); 71 WebstoreInstaller::Approval::CreateWithNoInstallPrompt(
71 approval->extension_id = id; 72 browser()->profile(),
72 approval->profile = browser()->profile(); 73 id,
73 approval->parsed_manifest.reset(parsed_manifest); 74 scoped_ptr<base::DictionaryValue>(parsed_manifest)));
74 75
75 scoped_refptr<CrxInstaller> installer( 76 scoped_refptr<CrxInstaller> installer(
76 CrxInstaller::Create(service, 77 CrxInstaller::Create(service,
77 mock_install_ui, /* ownership transferred */ 78 mock_install_ui, /* ownership transferred */
78 approval.get() /* keep ownership */)); 79 approval.get() /* keep ownership */));
79 installer->set_allow_silent_install(true); 80 installer->set_allow_silent_install(true);
80 installer->set_is_gallery_install(true); 81 installer->set_is_gallery_install(true);
81 installer->InstallCrx(PackExtension(ext_path)); 82 installer->InstallCrx(PackExtension(ext_path));
82 ui_test_utils::RunMessageLoop(); 83 ui_test_utils::RunMessageLoop();
83 84
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 118
118 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PlatformAppCrx) { 119 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PlatformAppCrx) {
119 CommandLine* command_line = CommandLine::ForCurrentProcess(); 120 CommandLine* command_line = CommandLine::ForCurrentProcess();
120 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); 121 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
121 command_line->AppendSwitch(switches::kEnablePlatformApps); 122 command_line->AppendSwitch(switches::kEnablePlatformApps);
122 EXPECT_TRUE(InstallExtension( 123 EXPECT_TRUE(InstallExtension(
123 test_data_dir_.AppendASCII("minimal_platform_app.crx"), 1)); 124 test_data_dir_.AppendASCII("minimal_platform_app.crx"), 1));
124 } 125 }
125 126
126 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PackAndInstallExtension) { 127 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PackAndInstallExtension) {
128 if (!extensions::switch_utils::IsOffStoreInstallEnabled())
129 return;
130
127 const int kNumDownloadsExpected = 1; 131 const int kNumDownloadsExpected = 1;
128 const bool kExpectFileSelectDialog = false; 132 const bool kExpectFileSelectDialog = false;
129 133
130 LOG(ERROR) << "PackAndInstallExtension: Packing extension"; 134 LOG(ERROR) << "PackAndInstallExtension: Packing extension";
131 FilePath crx_path = PackExtension( 135 FilePath crx_path = PackExtension(
132 test_data_dir_.AppendASCII("common/background_page")); 136 test_data_dir_.AppendASCII("common/background_page"));
133 ASSERT_FALSE(crx_path.empty()); 137 ASSERT_FALSE(crx_path.empty());
134 std::string crx_path_string(crx_path.value().begin(), crx_path.value().end()); 138 std::string crx_path_string(crx_path.value().begin(), crx_path.value().end());
135 GURL url = GURL(std::string("file:///").append(crx_path_string)); 139 GURL url = GURL(std::string("file:///").append(crx_path_string));
136 140
(...skipping 12 matching lines...) Expand all
149 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT)); 153 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT));
150 LOG(ERROR) << "PackAndInstallExtension: Navigating to URL"; 154 LOG(ERROR) << "PackAndInstallExtension: Navigating to URL";
151 ui_test_utils::NavigateToURLWithDisposition(browser(), url, CURRENT_TAB, 155 ui_test_utils::NavigateToURLWithDisposition(browser(), url, CURRENT_TAB,
152 ui_test_utils::BROWSER_TEST_NONE); 156 ui_test_utils::BROWSER_TEST_NONE);
153 157
154 EXPECT_TRUE(WaitForExtensionInstall()); 158 EXPECT_TRUE(WaitForExtensionInstall());
155 LOG(ERROR) << "PackAndInstallExtension: Extension install"; 159 LOG(ERROR) << "PackAndInstallExtension: Extension install";
156 EXPECT_TRUE(mock_ui->confirmation_requested()); 160 EXPECT_TRUE(mock_ui->confirmation_requested());
157 LOG(ERROR) << "PackAndInstallExtension: Extension install confirmed"; 161 LOG(ERROR) << "PackAndInstallExtension: Extension install confirmed";
158 } 162 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/crx_installer.cc ('k') | chrome/browser/extensions/extension_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698