| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_input_method_api.h" | 5 #include "chrome/browser/extensions/extension_input_method_api.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 8 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
| 9 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" | 9 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 | 12 |
| 13 namespace { | |
| 14 | |
| 15 const char kErrorInputMethodPrivateApi[] = "Input method API is private"; | |
| 16 | |
| 17 } // namespace | |
| 18 | |
| 19 GetInputMethodFunction::GetInputMethodFunction() { | 13 GetInputMethodFunction::GetInputMethodFunction() { |
| 20 } | 14 } |
| 21 | 15 |
| 22 GetInputMethodFunction::~GetInputMethodFunction() { | 16 GetInputMethodFunction::~GetInputMethodFunction() { |
| 23 } | 17 } |
| 24 | 18 |
| 25 bool GetInputMethodFunction::RunImpl() { | 19 bool GetInputMethodFunction::RunImpl() { |
| 26 #if !defined(OS_CHROMEOS) | 20 #if !defined(OS_CHROMEOS) |
| 27 error_ = kErrorInputMethodPrivateApi; | 21 NOTREACHED(); |
| 28 return false; | |
| 29 #else | 22 #else |
| 30 chromeos::ExtensionInputMethodEventRouter* router = | 23 chromeos::ExtensionInputMethodEventRouter* router = |
| 31 profile_->GetExtensionService()->input_method_event_router(); | 24 profile_->GetExtensionService()->input_method_event_router(); |
| 32 if (!router->IsExtensionWhitelisted(extension_id())) { | |
| 33 error_ = kErrorInputMethodPrivateApi; | |
| 34 return false; | |
| 35 } | |
| 36 chromeos::input_method::InputMethodManager* manager = | 25 chromeos::input_method::InputMethodManager* manager = |
| 37 chromeos::input_method::InputMethodManager::GetInstance(); | 26 chromeos::input_method::InputMethodManager::GetInstance(); |
| 38 const std::string input_method = | 27 const std::string input_method = |
| 39 router->GetInputMethodForXkb(manager->current_input_method().id()); | 28 router->GetInputMethodForXkb(manager->current_input_method().id()); |
| 40 result_.reset(Value::CreateStringValue(input_method)); | 29 result_.reset(Value::CreateStringValue(input_method)); |
| 41 return true; | 30 return true; |
| 42 #endif | 31 #endif |
| 43 } | 32 } |
| OLD | NEW |