| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/virtual_keyboard_private/virtual_keyboard_priva
te_api.h" | 5 #include "extensions/browser/api/virtual_keyboard_private/virtual_keyboard_priva
te_api.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" |
| 10 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 11 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 12 #include "extensions/browser/api/extensions_api_client.h" | 13 #include "extensions/browser/api/extensions_api_client.h" |
| 13 #include "extensions/browser/api/virtual_keyboard_private/virtual_keyboard_deleg
ate.h" | 14 #include "extensions/browser/api/virtual_keyboard_private/virtual_keyboard_deleg
ate.h" |
| 14 #include "extensions/browser/extension_function_registry.h" | 15 #include "extensions/browser/extension_function_registry.h" |
| 15 #include "extensions/common/api/virtual_keyboard_private.h" | 16 #include "extensions/common/api/virtual_keyboard_private.h" |
| 16 #include "ui/events/event.h" | 17 #include "ui/events/event.h" |
| 17 | 18 |
| 18 namespace extensions { | 19 namespace extensions { |
| 19 | 20 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 97 |
| 97 ExtensionFunction::ResponseAction | 98 ExtensionFunction::ResponseAction |
| 98 VirtualKeyboardPrivateKeyboardLoadedFunction::Run() { | 99 VirtualKeyboardPrivateKeyboardLoadedFunction::Run() { |
| 99 if (!delegate()->OnKeyboardLoaded()) | 100 if (!delegate()->OnKeyboardLoaded()) |
| 100 return RespondNow(Error(kUnknownError)); | 101 return RespondNow(Error(kUnknownError)); |
| 101 return RespondNow(NoArguments()); | 102 return RespondNow(NoArguments()); |
| 102 } | 103 } |
| 103 | 104 |
| 104 ExtensionFunction::ResponseAction | 105 ExtensionFunction::ResponseAction |
| 105 VirtualKeyboardPrivateGetKeyboardConfigFunction::Run() { | 106 VirtualKeyboardPrivateGetKeyboardConfigFunction::Run() { |
| 106 std::unique_ptr<base::DictionaryValue> results(new base::DictionaryValue()); | 107 delegate()->GetKeyboardConfig(base::Bind( |
| 107 if (!delegate()->GetKeyboardConfig(results.get())) | 108 &VirtualKeyboardPrivateGetKeyboardConfigFunction::OnKeyboardConfig, |
| 108 return RespondNow(Error(kUnknownError)); | 109 this)); |
| 109 return RespondNow(OneArgument(std::move(results))); | 110 return RespondLater(); |
| 111 } |
| 112 |
| 113 void VirtualKeyboardPrivateGetKeyboardConfigFunction::OnKeyboardConfig( |
| 114 std::unique_ptr<base::DictionaryValue> results) { |
| 115 Respond(results ? OneArgument(std::move(results)) : Error(kUnknownError)); |
| 110 } | 116 } |
| 111 | 117 |
| 112 ExtensionFunction::ResponseAction | 118 ExtensionFunction::ResponseAction |
| 113 VirtualKeyboardPrivateOpenSettingsFunction::Run() { | 119 VirtualKeyboardPrivateOpenSettingsFunction::Run() { |
| 114 if (!delegate()->IsLanguageSettingsEnabled() || | 120 if (!delegate()->IsLanguageSettingsEnabled() || |
| 115 !delegate()->ShowLanguageSettings()) { | 121 !delegate()->ShowLanguageSettings()) { |
| 116 return RespondNow(Error(kUnknownError)); | 122 return RespondNow(Error(kUnknownError)); |
| 117 } | 123 } |
| 118 return RespondNow(NoArguments()); | 124 return RespondNow(NoArguments()); |
| 119 } | 125 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 147 static base::LazyInstance<BrowserContextKeyedAPIFactory<VirtualKeyboardAPI>> | 153 static base::LazyInstance<BrowserContextKeyedAPIFactory<VirtualKeyboardAPI>> |
| 148 g_factory = LAZY_INSTANCE_INITIALIZER; | 154 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 149 | 155 |
| 150 // static | 156 // static |
| 151 BrowserContextKeyedAPIFactory<VirtualKeyboardAPI>* | 157 BrowserContextKeyedAPIFactory<VirtualKeyboardAPI>* |
| 152 VirtualKeyboardAPI::GetFactoryInstance() { | 158 VirtualKeyboardAPI::GetFactoryInstance() { |
| 153 return g_factory.Pointer(); | 159 return g_factory.Pointer(); |
| 154 } | 160 } |
| 155 | 161 |
| 156 } // namespace extensions | 162 } // namespace extensions |
| OLD | NEW |