| 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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 | 447 |
| 448 extension_id_ = params->id; | 448 extension_id_ = params->id; |
| 449 | 449 |
| 450 const Extension* extension = service()->GetInstalledExtension(extension_id_); | 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. | |
| 458 if (service()->GetTerminatedExtension(extension_id_)) { | |
| 459 if (params->enabled) { | |
| 460 service()->ReloadExtension(extension_id_); | |
| 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 | |
| 471 const extensions::ManagementPolicy* policy = extensions::ExtensionSystem::Get( | 457 const extensions::ManagementPolicy* policy = extensions::ExtensionSystem::Get( |
| 472 profile())->management_policy(); | 458 profile())->management_policy(); |
| 473 if (!policy->UserMayModifySettings(extension, NULL)) { | 459 if (!policy->UserMayModifySettings(extension, NULL)) { |
| 474 error_ = ExtensionErrorUtils::FormatErrorMessage( | 460 error_ = ExtensionErrorUtils::FormatErrorMessage( |
| 475 keys::kUserCantModifyError, extension_id_); | 461 keys::kUserCantModifyError, extension_id_); |
| 476 return false; | 462 return false; |
| 477 } | 463 } |
| 478 | 464 |
| 479 bool currently_enabled = service()->IsExtensionEnabled(extension_id_); | 465 bool currently_enabled = service()->IsExtensionEnabled(extension_id_); |
| 480 | 466 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 } | 643 } |
| 658 CHECK(extension); | 644 CHECK(extension); |
| 659 scoped_ptr<management::ExtensionInfo> info = CreateExtensionInfo( | 645 scoped_ptr<management::ExtensionInfo> info = CreateExtensionInfo( |
| 660 *extension, ExtensionSystem::Get(profile)); | 646 *extension, ExtensionSystem::Get(profile)); |
| 661 args->Append(info->ToValue().release()); | 647 args->Append(info->ToValue().release()); |
| 662 } | 648 } |
| 663 | 649 |
| 664 profile->GetExtensionEventRouter()->DispatchEventToRenderers( | 650 profile->GetExtensionEventRouter()->DispatchEventToRenderers( |
| 665 event_name, args.Pass(), NULL, GURL(), extensions::EventFilteringInfo()); | 651 event_name, args.Pass(), NULL, GURL(), extensions::EventFilteringInfo()); |
| 666 } | 652 } |
| OLD | NEW |