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

Side by Side Diff: chrome/browser/extensions/api/management/management_api.cc

Issue 10832237: Allow chrome.management.setEnabled() to re-enable crashed extensions. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Navigate to about:crash instead of using base::KillProcess Created 8 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/management/management_api_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/api/management/management_api.h" 5 #include "chrome/browser/extensions/api/management/management_api.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 SetEnabledFunction::~SetEnabledFunction() { 440 SetEnabledFunction::~SetEnabledFunction() {
441 } 441 }
442 442
443 bool SetEnabledFunction::RunImpl() { 443 bool SetEnabledFunction::RunImpl() {
444 scoped_ptr<management::SetEnabled::Params> params( 444 scoped_ptr<management::SetEnabled::Params> params(
445 management::SetEnabled::Params::Create(*args_)); 445 management::SetEnabled::Params::Create(*args_));
446 EXTENSION_FUNCTION_VALIDATE(params.get()); 446 EXTENSION_FUNCTION_VALIDATE(params.get());
447 447
448 extension_id_ = params->id; 448 extension_id_ = params->id;
449 449
450 const Extension* extension = service()->GetExtensionById(extension_id_, true); 450 const Extension* extension = service()->GetInstalledExtension(extension_id_);
451 if (!extension) { 451 if (!extension) {
452 error_ = ExtensionErrorUtils::FormatErrorMessage( 452 error_ = ExtensionErrorUtils::FormatErrorMessage(
453 keys::kNoExtensionError, extension_id_); 453 keys::kNoExtensionError, extension_id_);
454 return false; 454 return false;
455 } 455 }
456 456
457 // The extension may have been unloaded due to a crash.
Aaron Boodman 2012/09/04 22:47:19 Does not seem right that this code is before polic
458 if (service()->GetTerminatedExtension(extension_id_)) {
459 if (params->enabled) {
460 service()->ReloadExtension(extension_id_);
Aaron Boodman 2012/09/04 22:47:19 Why this special case? Just make this extension af
mitchellwrosen 2012/09/04 23:00:08 Isn't it a special case, though? Terminated extens
461 } else {
462 // Treat setEnabled(false) when the extension has crashed as a no-op.
463 BrowserThread::PostTask(
464 BrowserThread::UI,
465 FROM_HERE,
466 base::Bind(&SetEnabledFunction::SendResponse, this, true));
467 return true;
468 }
469 }
470
457 const extensions::ManagementPolicy* policy = extensions::ExtensionSystem::Get( 471 const extensions::ManagementPolicy* policy = extensions::ExtensionSystem::Get(
458 profile())->management_policy(); 472 profile())->management_policy();
459 if (!policy->UserMayModifySettings(extension, NULL)) { 473 if (!policy->UserMayModifySettings(extension, NULL)) {
460 error_ = ExtensionErrorUtils::FormatErrorMessage( 474 error_ = ExtensionErrorUtils::FormatErrorMessage(
461 keys::kUserCantModifyError, extension_id_); 475 keys::kUserCantModifyError, extension_id_);
462 return false; 476 return false;
463 } 477 }
464 478
465 bool currently_enabled = service()->IsExtensionEnabled(extension_id_); 479 bool currently_enabled = service()->IsExtensionEnabled(extension_id_);
466 480
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 } 657 }
644 CHECK(extension); 658 CHECK(extension);
645 scoped_ptr<management::ExtensionInfo> info = CreateExtensionInfo( 659 scoped_ptr<management::ExtensionInfo> info = CreateExtensionInfo(
646 *extension, ExtensionSystem::Get(profile)); 660 *extension, ExtensionSystem::Get(profile));
647 args->Append(info->ToValue().release()); 661 args->Append(info->ToValue().release());
648 } 662 }
649 663
650 profile->GetExtensionEventRouter()->DispatchEventToRenderers( 664 profile->GetExtensionEventRouter()->DispatchEventToRenderers(
651 event_name, args.Pass(), NULL, GURL(), extensions::EventFilteringInfo()); 665 event_name, args.Pass(), NULL, GURL(), extensions::EventFilteringInfo());
652 } 666 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/management/management_api_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698