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

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

Issue 342003005: Show alert failure for reloading unpacked extensions with bad manifest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved path handling back to C++ Created 6 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/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_util.h" 10 #include "base/file_util.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 extensions::ExtensionPrefs::Get(profile()) 194 extensions::ExtensionPrefs::Get(profile())
195 ->SetInstallParam(extension_id, install_param); 195 ->SetInstallParam(extension_id, install_param);
196 // Re-enable the extension if needed. 196 // Re-enable the extension if needed.
197 if (service->extensions()->Contains(extension_id)) { 197 if (service->extensions()->Contains(extension_id)) {
198 content::WindowedNotificationObserver load_signal( 198 content::WindowedNotificationObserver load_signal(
199 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, 199 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
200 content::Source<Profile>(profile())); 200 content::Source<Profile>(profile()));
201 // Reload the extension so that the 201 // Reload the extension so that the
202 // NOTIFICATION_EXTENSION_LOADED_DEPRECATED 202 // NOTIFICATION_EXTENSION_LOADED_DEPRECATED
203 // observers may access |install_param|. 203 // observers may access |install_param|.
204 service->ReloadExtension(extension_id); 204 service->ReloadExtension(extension_id, true);
205 load_signal.Wait(); 205 load_signal.Wait();
206 extension = service->GetExtensionById(extension_id, false); 206 extension = service->GetExtensionById(extension_id, false);
207 CHECK(extension) << extension_id << " not found after reloading."; 207 CHECK(extension) << extension_id << " not found after reloading.";
208 } 208 }
209 } 209 }
210 210
211 // Toggling incognito or file access will reload the extension, so wait for 211 // Toggling incognito or file access will reload the extension, so wait for
212 // the reload and grab the new extension instance. The default state is 212 // the reload and grab the new extension instance. The default state is
213 // incognito disabled and file access enabled, so we don't wait in those 213 // incognito disabled and file access enabled, so we don't wait in those
214 // cases. 214 // cases.
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 return NULL; 528 return NULL;
529 return service->GetExtensionById(last_loaded_extension_id(), false); 529 return service->GetExtensionById(last_loaded_extension_id(), false);
530 } 530 }
531 531
532 void ExtensionBrowserTest::ReloadExtension(const std::string extension_id) { 532 void ExtensionBrowserTest::ReloadExtension(const std::string extension_id) {
533 observer_->Watch(chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, 533 observer_->Watch(chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
534 content::NotificationService::AllSources()); 534 content::NotificationService::AllSources());
535 535
536 ExtensionService* service = 536 ExtensionService* service =
537 extensions::ExtensionSystem::Get(profile())->extension_service(); 537 extensions::ExtensionSystem::Get(profile())->extension_service();
538 service->ReloadExtension(extension_id); 538 service->ReloadExtension(extension_id, true);
539 539
540 observer_->Wait(); 540 observer_->Wait();
541 observer_->WaitForExtensionViewsToLoad(); 541 observer_->WaitForExtensionViewsToLoad();
542 } 542 }
543 543
544 void ExtensionBrowserTest::UnloadExtension(const std::string& extension_id) { 544 void ExtensionBrowserTest::UnloadExtension(const std::string& extension_id) {
545 ExtensionService* service = extensions::ExtensionSystem::Get( 545 ExtensionService* service = extensions::ExtensionSystem::Get(
546 profile())->extension_service(); 546 profile())->extension_service();
547 service->UnloadExtension(extension_id, 547 service->UnloadExtension(extension_id,
548 extensions::UnloadedExtensionInfo::REASON_DISABLE); 548 extensions::UnloadedExtensionInfo::REASON_DISABLE);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( 641 return extensions::browsertest_util::ExecuteScriptInBackgroundPage(
642 profile(), extension_id, script); 642 profile(), extension_id, script);
643 } 643 }
644 644
645 bool ExtensionBrowserTest::ExecuteScriptInBackgroundPageNoWait( 645 bool ExtensionBrowserTest::ExecuteScriptInBackgroundPageNoWait(
646 const std::string& extension_id, 646 const std::string& extension_id,
647 const std::string& script) { 647 const std::string& script) {
648 return extensions::browsertest_util::ExecuteScriptInBackgroundPageNoWait( 648 return extensions::browsertest_util::ExecuteScriptInBackgroundPageNoWait(
649 profile(), extension_id, script); 649 profile(), extension_id, script);
650 } 650 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698