| 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/memory/linked_ptr.h" | 15 #include "base/memory/linked_ptr.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 21 #include "chrome/browser/extensions/api/management/management_api_constants.h" | 21 #include "chrome/browser/extensions/api/management/management_api_constants.h" |
| 22 #include "chrome/browser/extensions/extension_service.h" | 22 #include "chrome/browser/extensions/extension_service.h" |
| 23 #include "chrome/browser/extensions/extension_ui_util.h" | 23 #include "chrome/browser/extensions/extension_ui_util.h" |
| 24 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 24 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
| 25 #include "chrome/browser/extensions/launch_util.h" | 25 #include "chrome/browser/extensions/launch_util.h" |
| 26 #include "chrome/browser/extensions/window_controller.h" |
| 26 #include "chrome/browser/favicon/favicon_service_factory.h" | 27 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 27 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
| 28 #include "chrome/browser/ui/browser_dialogs.h" | 29 #include "chrome/browser/ui/browser_dialogs.h" |
| 29 #include "chrome/browser/ui/browser_finder.h" | 30 #include "chrome/browser/ui/browser_finder.h" |
| 30 #include "chrome/browser/ui/browser_window.h" | 31 #include "chrome/browser/ui/browser_window.h" |
| 31 #include "chrome/browser/ui/extensions/application_launch.h" | 32 #include "chrome/browser/ui/extensions/application_launch.h" |
| 32 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 33 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 33 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" | 34 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" |
| 34 #include "chrome/common/chrome_switches.h" | 35 #include "chrome/common/chrome_switches.h" |
| 35 #include "chrome/common/extensions/api/management.h" | 36 #include "chrome/common/extensions/api/management.h" |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 ->management_policy() | 604 ->management_policy() |
| 604 ->UserMayModifySettings(target_extension, NULL)) { | 605 ->UserMayModifySettings(target_extension, NULL)) { |
| 605 error_ = ErrorUtils::FormatErrorMessage( | 606 error_ = ErrorUtils::FormatErrorMessage( |
| 606 keys::kUserCantModifyError, extension_id_); | 607 keys::kUserCantModifyError, extension_id_); |
| 607 return false; | 608 return false; |
| 608 } | 609 } |
| 609 | 610 |
| 610 if (auto_confirm_for_test == DO_NOT_SKIP) { | 611 if (auto_confirm_for_test == DO_NOT_SKIP) { |
| 611 if (show_confirm_dialog) { | 612 if (show_confirm_dialog) { |
| 612 AddRef(); // Balanced in ExtensionUninstallAccepted/Canceled | 613 AddRef(); // Balanced in ExtensionUninstallAccepted/Canceled |
| 614 extensions::WindowController* controller = GetExtensionWindowController(); |
| 613 extension_uninstall_dialog_.reset(ExtensionUninstallDialog::Create( | 615 extension_uninstall_dialog_.reset(ExtensionUninstallDialog::Create( |
| 614 GetProfile(), GetCurrentBrowser(), this)); | 616 GetProfile(), |
| 617 controller ? controller->window()->GetNativeWindow() : NULL, |
| 618 this)); |
| 615 if (extension_id() != target_extension_id) { | 619 if (extension_id() != target_extension_id) { |
| 616 extension_uninstall_dialog_->ConfirmProgrammaticUninstall( | 620 extension_uninstall_dialog_->ConfirmProgrammaticUninstall( |
| 617 target_extension, GetExtension()); | 621 target_extension, GetExtension()); |
| 618 } else { | 622 } else { |
| 619 // If this is a self uninstall, show the generic uninstall dialog. | 623 // If this is a self uninstall, show the generic uninstall dialog. |
| 620 extension_uninstall_dialog_->ConfirmUninstall(target_extension); | 624 extension_uninstall_dialog_->ConfirmUninstall(target_extension); |
| 621 } | 625 } |
| 622 } else { | 626 } else { |
| 623 Finish(true); | 627 Finish(true); |
| 624 } | 628 } |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 ManagementAPI::GetFactoryInstance() { | 1003 ManagementAPI::GetFactoryInstance() { |
| 1000 return g_factory.Pointer(); | 1004 return g_factory.Pointer(); |
| 1001 } | 1005 } |
| 1002 | 1006 |
| 1003 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { | 1007 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { |
| 1004 management_event_router_.reset(new ManagementEventRouter(browser_context_)); | 1008 management_event_router_.reset(new ManagementEventRouter(browser_context_)); |
| 1005 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 1009 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
| 1006 } | 1010 } |
| 1007 | 1011 |
| 1008 } // namespace extensions | 1012 } // namespace extensions |
| OLD | NEW |