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 "extensions/browser/api/management/management_api.h" | 5 #include "extensions/browser/api/management/management_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 const Extension* target_extension = | 507 const Extension* target_extension = |
508 extensions::ExtensionRegistry::Get(browser_context()) | 508 extensions::ExtensionRegistry::Get(browser_context()) |
509 ->GetExtensionById(extension_id_, ExtensionRegistry::EVERYTHING); | 509 ->GetExtensionById(extension_id_, ExtensionRegistry::EVERYTHING); |
510 if (!target_extension || | 510 if (!target_extension || |
511 ShouldNotBeVisible(target_extension, browser_context())) { | 511 ShouldNotBeVisible(target_extension, browser_context())) { |
512 error_ = | 512 error_ = |
513 ErrorUtils::FormatErrorMessage(keys::kNoExtensionError, extension_id_); | 513 ErrorUtils::FormatErrorMessage(keys::kNoExtensionError, extension_id_); |
514 return false; | 514 return false; |
515 } | 515 } |
516 | 516 |
517 if (!ExtensionSystem::Get(browser_context()) | 517 ManagementPolicy* policy = |
518 ->management_policy() | 518 ExtensionSystem::Get(browser_context())->management_policy(); |
519 ->UserMayModifySettings(target_extension, NULL)) { | 519 if (!policy->UserMayModifySettings(target_extension, nullptr) || |
| 520 policy->MustRemainInstalled(target_extension, nullptr)) { |
520 error_ = ErrorUtils::FormatErrorMessage(keys::kUserCantModifyError, | 521 error_ = ErrorUtils::FormatErrorMessage(keys::kUserCantModifyError, |
521 extension_id_); | 522 extension_id_); |
522 return false; | 523 return false; |
523 } | 524 } |
524 | 525 |
525 if (auto_confirm_for_test == DO_NOT_SKIP) { | 526 if (auto_confirm_for_test == DO_NOT_SKIP) { |
526 if (show_confirm_dialog) { | 527 if (show_confirm_dialog) { |
527 AddRef(); // Balanced in ExtensionUninstallAccepted/Canceled | 528 AddRef(); // Balanced in ExtensionUninstallAccepted/Canceled |
528 uninstall_dialog_ = | 529 uninstall_dialog_ = |
529 delegate->UninstallFunctionDelegate(this, target_extension_id); | 530 delegate->UninstallFunctionDelegate(this, target_extension_id); |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 ManagementAPI::GetFactoryInstance() { | 894 ManagementAPI::GetFactoryInstance() { |
894 return g_factory.Pointer(); | 895 return g_factory.Pointer(); |
895 } | 896 } |
896 | 897 |
897 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { | 898 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { |
898 management_event_router_.reset(new ManagementEventRouter(browser_context_)); | 899 management_event_router_.reset(new ManagementEventRouter(browser_context_)); |
899 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 900 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
900 } | 901 } |
901 | 902 |
902 } // namespace extensions | 903 } // namespace extensions |
OLD | NEW |