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

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: Fixes Created 8 years, 4 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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 SetEnabledFunction::~SetEnabledFunction() { 426 SetEnabledFunction::~SetEnabledFunction() {
427 } 427 }
428 428
429 bool SetEnabledFunction::RunImpl() { 429 bool SetEnabledFunction::RunImpl() {
430 scoped_ptr<management::SetEnabled::Params> params( 430 scoped_ptr<management::SetEnabled::Params> params(
431 management::SetEnabled::Params::Create(*args_)); 431 management::SetEnabled::Params::Create(*args_));
432 EXTENSION_FUNCTION_VALIDATE(params.get()); 432 EXTENSION_FUNCTION_VALIDATE(params.get());
433 433
434 extension_id_ = params->id; 434 extension_id_ = params->id;
435 435
436 const Extension* extension = service()->GetExtensionById(extension_id_, true); 436 const Extension* extension = service()->GetInstalledExtension(extension_id_);
437 if (!extension) { 437 if (!extension) {
438 error_ = ExtensionErrorUtils::FormatErrorMessage( 438 error_ = ExtensionErrorUtils::FormatErrorMessage(
439 keys::kNoExtensionError, extension_id_); 439 keys::kNoExtensionError, extension_id_);
440 return false; 440 return false;
441 } 441 }
442 442
443 // The extension may have been unloaded due to a crash.
444 if (service()->GetTerminatedExtension(extension_id_))
445 service()->ReloadExtension(extension_id_);
asargent_no_longer_on_chrome 2012/08/13 19:10:34 nit: I think we should only call ReloadExtension i
446
443 const extensions::ManagementPolicy* policy = extensions::ExtensionSystem::Get( 447 const extensions::ManagementPolicy* policy = extensions::ExtensionSystem::Get(
444 profile())->management_policy(); 448 profile())->management_policy();
445 if (!policy->UserMayModifySettings(extension, NULL)) { 449 if (!policy->UserMayModifySettings(extension, NULL)) {
446 error_ = ExtensionErrorUtils::FormatErrorMessage( 450 error_ = ExtensionErrorUtils::FormatErrorMessage(
447 keys::kUserCantModifyError, extension_id_); 451 keys::kUserCantModifyError, extension_id_);
448 return false; 452 return false;
449 } 453 }
450 454
451 bool currently_enabled = service()->IsExtensionEnabled(extension_id_); 455 bool currently_enabled = service()->IsExtensionEnabled(extension_id_);
452 456
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 } 633 }
630 CHECK(extension); 634 CHECK(extension);
631 scoped_ptr<management::ExtensionInfo> info = CreateExtensionInfo( 635 scoped_ptr<management::ExtensionInfo> info = CreateExtensionInfo(
632 *extension, ExtensionSystem::Get(profile)); 636 *extension, ExtensionSystem::Get(profile));
633 args->Append(info->ToValue().release()); 637 args->Append(info->ToValue().release());
634 } 638 }
635 639
636 profile->GetExtensionEventRouter()->DispatchEventToRenderers( 640 profile->GetExtensionEventRouter()->DispatchEventToRenderers(
637 event_name, args.Pass(), NULL, GURL(), extensions::EventFilteringInfo()); 641 event_name, args.Pass(), NULL, GURL(), extensions::EventFilteringInfo());
638 } 642 }
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