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

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

Issue 10387167: Revert 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"
18 #include "chrome/test/base/ui_test_utils.h" 17 #include "chrome/test/base/ui_test_utils.h"
19 18
20 class SkBitmap; 19 class SkBitmap;
21 20
22 namespace { 21 namespace {
23 22
24 // Observer waits for exactly one download to finish. 23 // Observer waits for exactly one download to finish.
25 24
26 class MockInstallUI : public ExtensionInstallUI { 25 class MockInstallUI : public ExtensionInstallUI {
27 public: 26 public:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 MockInstallUI* mock_install_ui = new MockInstallUI(browser()->profile()); 60 MockInstallUI* mock_install_ui = new MockInstallUI(browser()->profile());
62 FilePath ext_path = test_data_dir_.AppendASCII(ext_relpath); 61 FilePath ext_path = test_data_dir_.AppendASCII(ext_relpath);
63 62
64 std::string error; 63 std::string error;
65 base::DictionaryValue* parsed_manifest = 64 base::DictionaryValue* parsed_manifest =
66 extension_file_util::LoadManifest(ext_path, &error); 65 extension_file_util::LoadManifest(ext_path, &error);
67 if (!parsed_manifest) 66 if (!parsed_manifest)
68 return false; 67 return false;
69 68
70 scoped_ptr<WebstoreInstaller::Approval> approval( 69 scoped_ptr<WebstoreInstaller::Approval> approval(
71 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( 70 new WebstoreInstaller::Approval);
72 browser()->profile(), 71 approval->extension_id = id;
73 id, 72 approval->profile = browser()->profile();
74 scoped_ptr<base::DictionaryValue>(parsed_manifest))); 73 approval->parsed_manifest.reset(parsed_manifest);
75 74
76 scoped_refptr<CrxInstaller> installer( 75 scoped_refptr<CrxInstaller> installer(
77 CrxInstaller::Create(service, 76 CrxInstaller::Create(service,
78 mock_install_ui, /* ownership transferred */ 77 mock_install_ui, /* ownership transferred */
79 approval.get() /* keep ownership */)); 78 approval.get() /* keep ownership */));
80 installer->set_allow_silent_install(true); 79 installer->set_allow_silent_install(true);
81 installer->set_is_gallery_install(true); 80 installer->set_is_gallery_install(true);
82 installer->InstallCrx(PackExtension(ext_path)); 81 installer->InstallCrx(PackExtension(ext_path));
83 ui_test_utils::RunMessageLoop(); 82 ui_test_utils::RunMessageLoop();
84 83
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 117
119 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PlatformAppCrx) { 118 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PlatformAppCrx) {
120 CommandLine* command_line = CommandLine::ForCurrentProcess(); 119 CommandLine* command_line = CommandLine::ForCurrentProcess();
121 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); 120 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
122 command_line->AppendSwitch(switches::kEnablePlatformApps); 121 command_line->AppendSwitch(switches::kEnablePlatformApps);
123 EXPECT_TRUE(InstallExtension( 122 EXPECT_TRUE(InstallExtension(
124 test_data_dir_.AppendASCII("minimal_platform_app.crx"), 1)); 123 test_data_dir_.AppendASCII("minimal_platform_app.crx"), 1));
125 } 124 }
126 125
127 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PackAndInstallExtension) { 126 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PackAndInstallExtension) {
128 if (!extensions::switch_utils::IsOffStoreInstallEnabled())
129 return;
130
131 const int kNumDownloadsExpected = 1; 127 const int kNumDownloadsExpected = 1;
132 const bool kExpectFileSelectDialog = false; 128 const bool kExpectFileSelectDialog = false;
133 129
134 LOG(ERROR) << "PackAndInstallExtension: Packing extension"; 130 LOG(ERROR) << "PackAndInstallExtension: Packing extension";
135 FilePath crx_path = PackExtension( 131 FilePath crx_path = PackExtension(
136 test_data_dir_.AppendASCII("common/background_page")); 132 test_data_dir_.AppendASCII("common/background_page"));
137 ASSERT_FALSE(crx_path.empty()); 133 ASSERT_FALSE(crx_path.empty());
138 std::string crx_path_string(crx_path.value().begin(), crx_path.value().end()); 134 std::string crx_path_string(crx_path.value().begin(), crx_path.value().end());
139 GURL url = GURL(std::string("file:///").append(crx_path_string)); 135 GURL url = GURL(std::string("file:///").append(crx_path_string));
140 136
(...skipping 12 matching lines...) Expand all
153 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT)); 149 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT));
154 LOG(ERROR) << "PackAndInstallExtension: Navigating to URL"; 150 LOG(ERROR) << "PackAndInstallExtension: Navigating to URL";
155 ui_test_utils::NavigateToURLWithDisposition(browser(), url, CURRENT_TAB, 151 ui_test_utils::NavigateToURLWithDisposition(browser(), url, CURRENT_TAB,
156 ui_test_utils::BROWSER_TEST_NONE); 152 ui_test_utils::BROWSER_TEST_NONE);
157 153
158 EXPECT_TRUE(WaitForExtensionInstall()); 154 EXPECT_TRUE(WaitForExtensionInstall());
159 LOG(ERROR) << "PackAndInstallExtension: Extension install"; 155 LOG(ERROR) << "PackAndInstallExtension: Extension install";
160 EXPECT_TRUE(mock_ui->confirmation_requested()); 156 EXPECT_TRUE(mock_ui->confirmation_requested());
161 LOG(ERROR) << "PackAndInstallExtension: Extension install confirmed"; 157 LOG(ERROR) << "PackAndInstallExtension: Extension install confirmed";
162 } 158 }
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