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/profiler/scoped_profile.h" | 18 #include "base/profiler/scoped_profile.h" |
19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
22 #include "chrome/browser/extensions/api/management/management_api_constants.h" | 22 #include "chrome/browser/extensions/api/management/management_api_constants.h" |
23 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
24 #include "chrome/browser/extensions/extension_ui_util.h" | 24 #include "chrome/browser/extensions/extension_ui_util.h" |
25 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 25 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
26 #include "chrome/browser/extensions/extension_util.h" | 26 #include "chrome/browser/extensions/extension_util.h" |
27 #include "chrome/browser/extensions/launch_util.h" | 27 #include "chrome/browser/extensions/launch_util.h" |
28 #include "chrome/browser/extensions/window_controller.h" | |
29 #include "chrome/browser/favicon/favicon_service_factory.h" | 28 #include "chrome/browser/favicon/favicon_service_factory.h" |
30 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
31 #include "chrome/browser/ui/browser_dialogs.h" | 30 #include "chrome/browser/ui/browser_dialogs.h" |
32 #include "chrome/browser/ui/browser_finder.h" | 31 #include "chrome/browser/ui/browser_finder.h" |
33 #include "chrome/browser/ui/browser_window.h" | 32 #include "chrome/browser/ui/browser_window.h" |
34 #include "chrome/browser/ui/extensions/application_launch.h" | 33 #include "chrome/browser/ui/extensions/application_launch.h" |
35 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 34 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
36 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" | 35 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" |
37 #include "chrome/common/extensions/api/management.h" | 36 #include "chrome/common/extensions/api/management.h" |
38 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" | 37 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 ->management_policy() | 613 ->management_policy() |
615 ->UserMayModifySettings(target_extension, NULL)) { | 614 ->UserMayModifySettings(target_extension, NULL)) { |
616 error_ = ErrorUtils::FormatErrorMessage( | 615 error_ = ErrorUtils::FormatErrorMessage( |
617 keys::kUserCantModifyError, extension_id_); | 616 keys::kUserCantModifyError, extension_id_); |
618 return false; | 617 return false; |
619 } | 618 } |
620 | 619 |
621 if (auto_confirm_for_test == DO_NOT_SKIP) { | 620 if (auto_confirm_for_test == DO_NOT_SKIP) { |
622 if (show_confirm_dialog) { | 621 if (show_confirm_dialog) { |
623 AddRef(); // Balanced in ExtensionUninstallAccepted/Canceled | 622 AddRef(); // Balanced in ExtensionUninstallAccepted/Canceled |
624 extensions::WindowController* controller = GetExtensionWindowController(); | 623 content::WebContents* web_contents = GetAssociatedWebContents(); |
625 extension_uninstall_dialog_.reset(ExtensionUninstallDialog::Create( | 624 extension_uninstall_dialog_.reset(ExtensionUninstallDialog::Create( |
626 GetProfile(), | 625 GetProfile(), |
627 controller ? controller->window()->GetNativeWindow() : NULL, | 626 web_contents ? web_contents->GetTopLevelNativeWindow() : NULL, |
628 this)); | 627 this)); |
629 if (extension_id() != target_extension_id) { | 628 if (extension_id() != target_extension_id) { |
630 extension_uninstall_dialog_->ConfirmProgrammaticUninstall( | 629 extension_uninstall_dialog_->ConfirmProgrammaticUninstall( |
631 target_extension, extension()); | 630 target_extension, extension()); |
632 } else { | 631 } else { |
633 // If this is a self uninstall, show the generic uninstall dialog. | 632 // If this is a self uninstall, show the generic uninstall dialog. |
634 extension_uninstall_dialog_->ConfirmUninstall(target_extension); | 633 extension_uninstall_dialog_->ConfirmUninstall(target_extension); |
635 } | 634 } |
636 } else { | 635 } else { |
637 Finish(true); | 636 Finish(true); |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { | 1019 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { |
1021 // TODO(vadimt): Remove ScopedProfile below once crbug.com/417106 is fixed. | 1020 // TODO(vadimt): Remove ScopedProfile below once crbug.com/417106 is fixed. |
1022 tracked_objects::ScopedProfile tracking_profile( | 1021 tracked_objects::ScopedProfile tracking_profile( |
1023 FROM_HERE_WITH_EXPLICIT_FUNCTION("ManagementAPI::OnListenerAdded")); | 1022 FROM_HERE_WITH_EXPLICIT_FUNCTION("ManagementAPI::OnListenerAdded")); |
1024 | 1023 |
1025 management_event_router_.reset(new ManagementEventRouter(browser_context_)); | 1024 management_event_router_.reset(new ManagementEventRouter(browser_context_)); |
1026 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 1025 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
1027 } | 1026 } |
1028 | 1027 |
1029 } // namespace extensions | 1028 } // namespace extensions |
OLD | NEW |