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

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

Issue 10683003: Moved CrxInstaller and CrxInstallerError into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest-er master Created 8 years, 5 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
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_prompt.h" 11 #include "chrome/browser/extensions/extension_install_prompt.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/browser/ui/browser_window.h" 15 #include "chrome/browser/ui/browser_window.h"
16 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/extensions/extension.h" 17 #include "chrome/common/extensions/extension.h"
18 #include "chrome/common/extensions/extension_file_util.h" 18 #include "chrome/common/extensions/extension_file_util.h"
19 #include "chrome/common/extensions/extension_switch_utils.h" 19 #include "chrome/common/extensions/extension_switch_utils.h"
20 #include "chrome/common/extensions/permissions/permission_set.h" 20 #include "chrome/common/extensions/permissions/permission_set.h"
21 #include "chrome/test/base/ui_test_utils.h" 21 #include "chrome/test/base/ui_test_utils.h"
22 #include "grit/generated_resources.h" 22 #include "grit/generated_resources.h"
23 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
24 24
25 class SkBitmap; 25 class SkBitmap;
26 26
27 using extensions::Extension; 27 namespace extensions {
28 28
29 namespace { 29 namespace {
30 30
31 // Observer waits for exactly one download to finish. 31 // Observer waits for exactly one download to finish.
32 32
33 class MockInstallPrompt : public ExtensionInstallPrompt { 33 class MockInstallPrompt : public ExtensionInstallPrompt {
34 public: 34 public:
35 explicit MockInstallPrompt(gfx::NativeWindow parent, 35 explicit MockInstallPrompt(gfx::NativeWindow parent,
36 content::PageNavigator* navigator, 36 content::PageNavigator* navigator,
37 Profile* profile) : 37 Profile* profile) :
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 MockInstallPrompt* mock_install_prompt) { 85 MockInstallPrompt* mock_install_prompt) {
86 ExtensionService* service = browser()->profile()->GetExtensionService(); 86 ExtensionService* service = browser()->profile()->GetExtensionService();
87 FilePath ext_path = test_data_dir_.AppendASCII(ext_relpath); 87 FilePath ext_path = test_data_dir_.AppendASCII(ext_relpath);
88 88
89 std::string error; 89 std::string error;
90 base::DictionaryValue* parsed_manifest = 90 base::DictionaryValue* parsed_manifest =
91 extension_file_util::LoadManifest(ext_path, &error); 91 extension_file_util::LoadManifest(ext_path, &error);
92 if (!parsed_manifest) 92 if (!parsed_manifest)
93 return scoped_refptr<CrxInstaller>(); 93 return scoped_refptr<CrxInstaller>();
94 94
95 scoped_ptr<extensions::WebstoreInstaller::Approval> approval; 95 scoped_ptr<WebstoreInstaller::Approval> approval;
96 if (!id.empty()) { 96 if (!id.empty()) {
97 approval = 97 approval = WebstoreInstaller::Approval::CreateWithNoInstallPrompt(
98 extensions::WebstoreInstaller::Approval::CreateWithNoInstallPrompt( 98 browser()->profile(),
99 browser()->profile(), 99 id,
100 id, 100 scoped_ptr<base::DictionaryValue>(parsed_manifest));
101 scoped_ptr<base::DictionaryValue>(parsed_manifest));
102 } 101 }
103 102
104 scoped_refptr<CrxInstaller> installer( 103 scoped_refptr<CrxInstaller> installer(
105 CrxInstaller::Create(service, 104 CrxInstaller::Create(service,
106 mock_install_prompt, /* ownership transferred */ 105 mock_install_prompt, /* ownership transferred */
107 approval.get() /* keep ownership */)); 106 approval.get() /* keep ownership */));
108 installer->set_allow_silent_install(true); 107 installer->set_allow_silent_install(true);
109 installer->set_is_gallery_install(true); 108 installer->set_is_gallery_install(true);
110 installer->InstallCrx(PackExtension(ext_path)); 109 installer->InstallCrx(PackExtension(ext_path));
111 ui_test_utils::RunMessageLoop(); 110 ui_test_utils::RunMessageLoop();
(...skipping 10 matching lines...) Expand all
122 switches::kEnableExperimentalExtensionApis); 121 switches::kEnableExperimentalExtensionApis);
123 122
124 ExtensionService* service = browser()->profile()->GetExtensionService(); 123 ExtensionService* service = browser()->profile()->GetExtensionService();
125 124
126 MockInstallPrompt* mock_prompt = 125 MockInstallPrompt* mock_prompt =
127 CreateMockInstallPromptForBrowser(browser()); 126 CreateMockInstallPromptForBrowser(browser());
128 mock_prompt->set_record_oauth2_grant(record_oauth2_grant); 127 mock_prompt->set_record_oauth2_grant(record_oauth2_grant);
129 scoped_refptr<CrxInstaller> installer = 128 scoped_refptr<CrxInstaller> installer =
130 InstallWithPrompt("browsertest/scopes", std::string(), mock_prompt); 129 InstallWithPrompt("browsertest/scopes", std::string(), mock_prompt);
131 130
132 scoped_refptr<extensions::PermissionSet> permissions = 131 scoped_refptr<PermissionSet> permissions =
133 service->extension_prefs()->GetGrantedPermissions( 132 service->extension_prefs()->GetGrantedPermissions(
134 mock_prompt->extension()->id()); 133 mock_prompt->extension()->id());
135 ASSERT_TRUE(permissions.get()); 134 ASSERT_TRUE(permissions.get());
136 EXPECT_EQ(record_oauth2_grant, installer->record_oauth2_grant_); 135 EXPECT_EQ(record_oauth2_grant, installer->record_oauth2_grant_);
137 } 136 }
138 }; 137 };
139 138
140 #if defined(OS_CHROMEOS) 139 #if defined(OS_CHROMEOS)
141 #define MAYBE_Whitelisting DISABLED_Whitelisting 140 #define MAYBE_Whitelisting DISABLED_Whitelisting
142 #else 141 #else
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 181 }
183 182
184 // http://crbug.com/136397 183 // http://crbug.com/136397
185 #if defined(OS_CHROMEOS) 184 #if defined(OS_CHROMEOS)
186 #define MAYBE_PackAndInstallExtension DISABLED_PackAndInstallExtension 185 #define MAYBE_PackAndInstallExtension DISABLED_PackAndInstallExtension
187 #else 186 #else
188 #define MAYBE_PackAndInstallExtension PackAndInstallExtension 187 #define MAYBE_PackAndInstallExtension PackAndInstallExtension
189 #endif 188 #endif
190 IN_PROC_BROWSER_TEST_F( 189 IN_PROC_BROWSER_TEST_F(
191 ExtensionCrxInstallerTest, MAYBE_PackAndInstallExtension) { 190 ExtensionCrxInstallerTest, MAYBE_PackAndInstallExtension) {
192 if (!extensions::switch_utils::IsEasyOffStoreInstallEnabled()) 191 if (!switch_utils::IsEasyOffStoreInstallEnabled())
193 return; 192 return;
194 193
195 const int kNumDownloadsExpected = 1; 194 const int kNumDownloadsExpected = 1;
196 const bool kExpectFileSelectDialog = false; 195 const bool kExpectFileSelectDialog = false;
197 196
198 LOG(ERROR) << "PackAndInstallExtension: Packing extension"; 197 LOG(ERROR) << "PackAndInstallExtension: Packing extension";
199 FilePath crx_path = PackExtension( 198 FilePath crx_path = PackExtension(
200 test_data_dir_.AppendASCII("common/background_page")); 199 test_data_dir_.AppendASCII("common/background_page"));
201 ASSERT_FALSE(crx_path.empty()); 200 ASSERT_FALSE(crx_path.empty());
202 std::string crx_path_string(crx_path.value().begin(), crx_path.value().end()); 201 std::string crx_path_string(crx_path.value().begin(), crx_path.value().end());
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 kTestData[i]; 266 kTestData[i];
268 if (kTestData[i]) { 267 if (kTestData[i]) {
269 EXPECT_EQ(string16(), mock_prompt->error()) << kTestData[i]; 268 EXPECT_EQ(string16(), mock_prompt->error()) << kTestData[i];
270 } else { 269 } else {
271 EXPECT_EQ(l10n_util::GetStringUTF16( 270 EXPECT_EQ(l10n_util::GetStringUTF16(
272 IDS_EXTENSION_INSTALL_DISALLOWED_ON_SITE), 271 IDS_EXTENSION_INSTALL_DISALLOWED_ON_SITE),
273 mock_prompt->error()) << kTestData[i]; 272 mock_prompt->error()) << kTestData[i];
274 } 273 }
275 } 274 }
276 } 275 }
276
277 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/crx_installer.cc ('k') | chrome/browser/extensions/crx_installer_error.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698