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 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 | 400 |
| 401 SetEnabledFunction::~SetEnabledFunction() { | 401 SetEnabledFunction::~SetEnabledFunction() { |
| 402 } | 402 } |
| 403 | 403 |
| 404 bool SetEnabledFunction::RunImpl() { | 404 bool SetEnabledFunction::RunImpl() { |
| 405 bool enable; | 405 bool enable; |
| 406 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &extension_id_)); | 406 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &extension_id_)); |
| 407 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &enable)); | 407 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &enable)); |
| 408 | 408 |
| 409 const Extension* extension = service()->GetExtensionById(extension_id_, true); | 409 const Extension* extension = service()->GetExtensionById(extension_id_, true); |
| 410 // The extension may have been unloaded due to a crash. | |
| 410 if (!extension) { | 411 if (!extension) { |
| 411 error_ = ExtensionErrorUtils::FormatErrorMessage( | 412 UnloadedExtensionPathMap::const_iterator iter = service()-> |
| 412 keys::kNoExtensionError, extension_id_); | 413 unloaded_extension_paths().find(extension_id_); |
|
asargent_no_longer_on_chrome
2012/08/10 20:26:21
I'm not sure operating on unloaded extensions is c
mitchellwrosen
2012/08/10 23:15:27
Thanks, I didn't catch the "terminated" keyword. M
| |
| 413 return false; | 414 if (iter != service()->unloaded_extension_paths().end()) { |
| 415 if (enable) | |
| 416 service()->ReloadExtension(extension_id_); | |
| 417 | |
| 418 BrowserThread::PostTask( | |
| 419 BrowserThread::UI, | |
| 420 FROM_HERE, | |
| 421 base::Bind(&SetEnabledFunction::SendResponse, this, true)); | |
| 422 return true; | |
| 423 } else { | |
| 424 error_ = ExtensionErrorUtils::FormatErrorMessage( | |
| 425 keys::kNoExtensionError, extension_id_); | |
| 426 return false; | |
| 427 } | |
| 414 } | 428 } |
| 415 | 429 |
| 416 const extensions::ManagementPolicy* policy = extensions::ExtensionSystem::Get( | 430 const extensions::ManagementPolicy* policy = extensions::ExtensionSystem::Get( |
| 417 profile())->management_policy(); | 431 profile())->management_policy(); |
| 418 if (!policy->UserMayModifySettings(extension, NULL)) { | 432 if (!policy->UserMayModifySettings(extension, NULL)) { |
| 419 error_ = ExtensionErrorUtils::FormatErrorMessage( | 433 error_ = ExtensionErrorUtils::FormatErrorMessage( |
| 420 keys::kUserCantModifyError, extension_id_); | 434 keys::kUserCantModifyError, extension_id_); |
| 421 return false; | 435 return false; |
| 422 } | 436 } |
| 423 | 437 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 605 extension = content::Details<const Extension>(details).ptr(); | 619 extension = content::Details<const Extension>(details).ptr(); |
| 606 } | 620 } |
| 607 CHECK(extension); | 621 CHECK(extension); |
| 608 ExtensionService* service = profile->GetExtensionService(); | 622 ExtensionService* service = profile->GetExtensionService(); |
| 609 args->Append(CreateExtensionInfo(*extension, service)); | 623 args->Append(CreateExtensionInfo(*extension, service)); |
| 610 } | 624 } |
| 611 | 625 |
| 612 profile->GetExtensionEventRouter()->DispatchEventToRenderers( | 626 profile->GetExtensionEventRouter()->DispatchEventToRenderers( |
| 613 event_name, args.Pass(), NULL, GURL(), extensions::EventFilteringInfo()); | 627 event_name, args.Pass(), NULL, GURL(), extensions::EventFilteringInfo()); |
| 614 } | 628 } |
| OLD | NEW |