Chromium Code Reviews| 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/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 Loading... | |
| 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 Loading... | |
| 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 } |
| OLD | NEW |