| 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 <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/memory/linked_ptr.h" | 16 #include "base/memory/linked_ptr.h" |
| 17 #include "base/memory/ptr_util.h" |
| 17 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
| 18 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 21 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 22 #include "content/public/browser/browser_context.h" | 23 #include "content/public/browser/browser_context.h" |
| 23 #include "extensions/browser/api/extensions_api_client.h" | 24 #include "extensions/browser/api/extensions_api_client.h" |
| 24 #include "extensions/browser/api/management/management_api_constants.h" | 25 #include "extensions/browser/api/management/management_api_constants.h" |
| 25 #include "extensions/browser/event_router.h" | 26 #include "extensions/browser/event_router.h" |
| 26 #include "extensions/browser/extension_prefs.h" | 27 #include "extensions/browser/extension_prefs.h" |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 | 474 |
| 474 return RespondNow(NoArguments()); | 475 return RespondNow(NoArguments()); |
| 475 } | 476 } |
| 476 | 477 |
| 477 void ManagementSetEnabledFunction::OnInstallPromptDone(bool did_accept) { | 478 void ManagementSetEnabledFunction::OnInstallPromptDone(bool did_accept) { |
| 478 if (did_accept) { | 479 if (did_accept) { |
| 479 ManagementAPI::GetFactoryInstance() | 480 ManagementAPI::GetFactoryInstance() |
| 480 ->Get(browser_context()) | 481 ->Get(browser_context()) |
| 481 ->GetDelegate() | 482 ->GetDelegate() |
| 482 ->EnableExtension(browser_context(), extension_id_); | 483 ->EnableExtension(browser_context(), extension_id_); |
| 483 Respond(OneArgument(new base::FundamentalValue(true))); | 484 Respond(OneArgument(base::MakeUnique<base::FundamentalValue>(true))); |
| 484 } else { | 485 } else { |
| 485 Respond(Error(keys::kUserDidNotReEnableError)); | 486 Respond(Error(keys::kUserDidNotReEnableError)); |
| 486 } | 487 } |
| 487 | 488 |
| 488 Release(); // Balanced in Run(). | 489 Release(); // Balanced in Run(). |
| 489 } | 490 } |
| 490 | 491 |
| 491 void ManagementSetEnabledFunction::OnRequirementsChecked( | 492 void ManagementSetEnabledFunction::OnRequirementsChecked( |
| 492 const std::vector<std::string>& requirements_errors) { | 493 const std::vector<std::string>& requirements_errors) { |
| 493 if (requirements_errors.empty()) { | 494 if (requirements_errors.empty()) { |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 ManagementAPI::GetFactoryInstance() { | 900 ManagementAPI::GetFactoryInstance() { |
| 900 return g_factory.Pointer(); | 901 return g_factory.Pointer(); |
| 901 } | 902 } |
| 902 | 903 |
| 903 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { | 904 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { |
| 904 management_event_router_.reset(new ManagementEventRouter(browser_context_)); | 905 management_event_router_.reset(new ManagementEventRouter(browser_context_)); |
| 905 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 906 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
| 906 } | 907 } |
| 907 | 908 |
| 908 } // namespace extensions | 909 } // namespace extensions |
| OLD | NEW |