| 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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 | 597 |
| 598 ManagementUninstallFunction::ManagementUninstallFunction() { | 598 ManagementUninstallFunction::ManagementUninstallFunction() { |
| 599 } | 599 } |
| 600 | 600 |
| 601 ManagementUninstallFunction::~ManagementUninstallFunction() { | 601 ManagementUninstallFunction::~ManagementUninstallFunction() { |
| 602 } | 602 } |
| 603 | 603 |
| 604 bool ManagementUninstallFunction::RunImpl() { | 604 bool ManagementUninstallFunction::RunImpl() { |
| 605 scoped_ptr<management::Uninstall::Params> params( | 605 scoped_ptr<management::Uninstall::Params> params( |
| 606 management::Uninstall::Params::Create(*args_)); | 606 management::Uninstall::Params::Create(*args_)); |
| 607 EXTENSION_FUNCTION_VALIDATE(extension_); |
| 607 EXTENSION_FUNCTION_VALIDATE(params.get()); | 608 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 608 | 609 |
| 609 bool show_confirm_dialog = false; | 610 bool show_confirm_dialog = true; |
| 610 if (params->options.get() && params->options->show_confirm_dialog.get()) | 611 // By default confirmation dialog isn't shown when uninstalling self, but this |
| 611 show_confirm_dialog = *params->options->show_confirm_dialog; | 612 // can be overridden with showConfirmDialog. |
| 612 | 613 if (params->id == extension_->id()) { |
| 614 show_confirm_dialog = params->options.get() && |
| 615 params->options->show_confirm_dialog.get() && |
| 616 *params->options->show_confirm_dialog; |
| 617 } |
| 618 if (show_confirm_dialog && !user_gesture()) { |
| 619 error_ = keys::kGestureNeededForUninstallError; |
| 620 return false; |
| 621 } |
| 613 return Uninstall(params->id, show_confirm_dialog); | 622 return Uninstall(params->id, show_confirm_dialog); |
| 614 } | 623 } |
| 615 | 624 |
| 616 ManagementUninstallSelfFunction::ManagementUninstallSelfFunction() { | 625 ManagementUninstallSelfFunction::ManagementUninstallSelfFunction() { |
| 617 } | 626 } |
| 618 | 627 |
| 619 ManagementUninstallSelfFunction::~ManagementUninstallSelfFunction() { | 628 ManagementUninstallSelfFunction::~ManagementUninstallSelfFunction() { |
| 620 } | 629 } |
| 621 | 630 |
| 622 bool ManagementUninstallSelfFunction::RunImpl() { | 631 bool ManagementUninstallSelfFunction::RunImpl() { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 ProfileKeyedAPIFactory<ManagementAPI>* ManagementAPI::GetFactoryInstance() { | 736 ProfileKeyedAPIFactory<ManagementAPI>* ManagementAPI::GetFactoryInstance() { |
| 728 return &g_factory.Get(); | 737 return &g_factory.Get(); |
| 729 } | 738 } |
| 730 | 739 |
| 731 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { | 740 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { |
| 732 management_event_router_.reset(new ManagementEventRouter(profile_)); | 741 management_event_router_.reset(new ManagementEventRouter(profile_)); |
| 733 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); | 742 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); |
| 734 } | 743 } |
| 735 | 744 |
| 736 } // namespace extensions | 745 } // namespace extensions |
| OLD | NEW |