OLD | NEW |
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/extensions/extension_browsertest.h" | 5 #include "chrome/browser/extensions/extension_browsertest.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 extension = service->GetExtensionById(extension_id, false); | 127 extension = service->GetExtensionById(extension_id, false); |
128 CHECK(extension) << extension_id << " not found after reloading."; | 128 CHECK(extension) << extension_id << " not found after reloading."; |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 { | 132 { |
133 content::WindowedNotificationObserver load_signal( | 133 content::WindowedNotificationObserver load_signal( |
134 chrome::NOTIFICATION_EXTENSION_LOADED, | 134 chrome::NOTIFICATION_EXTENSION_LOADED, |
135 content::Source<Profile>(browser()->profile())); | 135 content::Source<Profile>(browser()->profile())); |
136 CHECK(service->AllowFileAccess(extension)); | 136 CHECK(service->AllowFileAccess(extension)); |
137 | |
138 if (!fileaccess_enabled) { | 137 if (!fileaccess_enabled) { |
139 service->SetAllowFileAccess(extension, fileaccess_enabled); | 138 service->SetAllowFileAccess(extension, fileaccess_enabled); |
140 load_signal.Wait(); | 139 load_signal.Wait(); |
141 extension = service->GetExtensionById(extension_id, false); | 140 extension = service->GetExtensionById(extension_id, false); |
142 CHECK(extension) << extension_id << " not found after reloading."; | 141 CHECK(extension) << extension_id << " not found after reloading."; |
143 } | 142 } |
144 } | 143 } |
145 | 144 |
146 if (!WaitForExtensionViewsToLoad()) | 145 if (!WaitForExtensionViewsToLoad()) |
147 return NULL; | 146 return NULL; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 // Proceed without confirmation prompt. | 257 // Proceed without confirmation prompt. |
259 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { | 258 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { |
260 delegate->InstallUIProceed(); | 259 delegate->InstallUIProceed(); |
261 } | 260 } |
262 }; | 261 }; |
263 | 262 |
264 const Extension* ExtensionBrowserTest::InstallExtensionFromWebstore( | 263 const Extension* ExtensionBrowserTest::InstallExtensionFromWebstore( |
265 const FilePath& path, | 264 const FilePath& path, |
266 int expected_change) { | 265 int expected_change) { |
267 return InstallOrUpdateExtension("", path, INSTALL_UI_TYPE_NONE, | 266 return InstallOrUpdateExtension("", path, INSTALL_UI_TYPE_NONE, |
268 expected_change, browser(), true); | 267 expected_change, Extension::INTERNAL, |
| 268 browser(), true); |
269 } | 269 } |
270 | 270 |
271 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 271 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
272 const std::string& id, | 272 const std::string& id, |
273 const FilePath& path, | 273 const FilePath& path, |
274 InstallUIType ui_type, | 274 InstallUIType ui_type, |
275 int expected_change) { | 275 int expected_change) { |
276 return InstallOrUpdateExtension(id, path, ui_type, expected_change, | 276 return InstallOrUpdateExtension(id, path, ui_type, expected_change, |
277 browser(), false); | 277 Extension::INTERNAL, browser(), false); |
278 } | 278 } |
279 | 279 |
280 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 280 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
| 281 const std::string& id, |
| 282 const FilePath& path, |
| 283 InstallUIType ui_type, |
| 284 int expected_change, |
| 285 Browser* browser, |
| 286 bool from_webstore) { |
| 287 return InstallOrUpdateExtension(id, path, ui_type, expected_change, |
| 288 Extension::INTERNAL, browser, from_webstore); |
| 289 } |
| 290 |
| 291 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
| 292 const std::string& id, |
| 293 const FilePath& path, |
| 294 InstallUIType ui_type, |
| 295 int expected_change, |
| 296 Extension::Location install_source) { |
| 297 return InstallOrUpdateExtension(id, path, ui_type, expected_change, |
| 298 install_source, browser(), false); |
| 299 } |
| 300 |
| 301 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
281 const std::string& id, | 302 const std::string& id, |
282 const FilePath& path, | 303 const FilePath& path, |
283 InstallUIType ui_type, | 304 InstallUIType ui_type, |
284 int expected_change, | 305 int expected_change, |
| 306 Extension::Location install_source, |
285 Browser* browser, | 307 Browser* browser, |
286 bool from_webstore) { | 308 bool from_webstore) { |
287 ExtensionService* service = browser->profile()->GetExtensionService(); | 309 ExtensionService* service = browser->profile()->GetExtensionService(); |
288 service->set_show_extensions_prompts(false); | 310 service->set_show_extensions_prompts(false); |
289 size_t num_before = service->extensions()->size(); | 311 size_t num_before = service->extensions()->size(); |
290 | 312 |
291 { | 313 { |
292 ExtensionInstallPrompt* install_ui = NULL; | 314 ExtensionInstallPrompt* install_ui = NULL; |
293 if (ui_type == INSTALL_UI_TYPE_CANCEL) { | 315 if (ui_type == INSTALL_UI_TYPE_CANCEL) { |
294 install_ui = new MockAbortExtensionInstallPrompt(); | 316 install_ui = new MockAbortExtensionInstallPrompt(); |
(...skipping 14 matching lines...) Expand all Loading... |
309 if (crx_path.Extension() != FILE_PATH_LITERAL(".crx")) { | 331 if (crx_path.Extension() != FILE_PATH_LITERAL(".crx")) { |
310 crx_path = PackExtension(path); | 332 crx_path = PackExtension(path); |
311 } | 333 } |
312 if (crx_path.empty()) | 334 if (crx_path.empty()) |
313 return NULL; | 335 return NULL; |
314 | 336 |
315 scoped_refptr<extensions::CrxInstaller> installer( | 337 scoped_refptr<extensions::CrxInstaller> installer( |
316 extensions::CrxInstaller::Create(service, install_ui)); | 338 extensions::CrxInstaller::Create(service, install_ui)); |
317 installer->set_expected_id(id); | 339 installer->set_expected_id(id); |
318 installer->set_is_gallery_install(from_webstore); | 340 installer->set_is_gallery_install(from_webstore); |
| 341 installer->set_install_source(install_source); |
319 if (!from_webstore) { | 342 if (!from_webstore) { |
320 installer->set_off_store_install_allow_reason( | 343 installer->set_off_store_install_allow_reason( |
321 extensions::CrxInstaller::OffStoreInstallAllowedInTest); | 344 extensions::CrxInstaller::OffStoreInstallAllowedInTest); |
322 } | 345 } |
323 | 346 |
324 content::NotificationRegistrar registrar; | 347 content::NotificationRegistrar registrar; |
325 registrar.Add(this, chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 348 registrar.Add(this, chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
326 content::Source<extensions::CrxInstaller>(installer.get())); | 349 content::Source<extensions::CrxInstaller>(installer.get())); |
327 | 350 |
328 installer->InstallCrx(crx_path); | 351 installer->InstallCrx(crx_path); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 case content::NOTIFICATION_LOAD_STOP: | 655 case content::NOTIFICATION_LOAD_STOP: |
633 VLOG(1) << "Got LOAD_STOP notification."; | 656 VLOG(1) << "Got LOAD_STOP notification."; |
634 MessageLoopForUI::current()->Quit(); | 657 MessageLoopForUI::current()->Quit(); |
635 break; | 658 break; |
636 | 659 |
637 default: | 660 default: |
638 NOTREACHED(); | 661 NOTREACHED(); |
639 break; | 662 break; |
640 } | 663 } |
641 } | 664 } |
OLD | NEW |