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_ui_api.h" | 5 #include "chrome/browser/extensions/extension_input_ui_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/chromeos/cros/cros_library.h" |
13 #include "chrome/browser/extensions/extension_event_router.h" | 14 #include "chrome/browser/extensions/extension_event_router.h" |
14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
15 #include "third_party/cros/chromeos_cros_api.h" | 16 #include "third_party/cros/chromeos_cros_api.h" |
16 #include "third_party/cros/chromeos_input_method_ui.h" | 17 #include "third_party/cros/chromeos_input_method_ui.h" |
17 | 18 |
18 namespace events { | 19 namespace events { |
19 | 20 |
20 const char kOnUpdateAuxiliaryText[] = | 21 const char kOnUpdateAuxiliaryText[] = |
21 "experimental.inputUI.onUpdateAuxiliaryText"; | 22 "experimental.inputUI.onUpdateAuxiliaryText"; |
22 const char kOnUpdateLookupTable[] = "experimental.inputUI.onUpdateLookupTable"; | 23 const char kOnUpdateLookupTable[] = "experimental.inputUI.onUpdateLookupTable"; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 ExtensionInputUiEventRouter* router_; | 71 ExtensionInputUiEventRouter* router_; |
71 chromeos::InputMethodUiStatusConnection* ui_status_connection_; | 72 chromeos::InputMethodUiStatusConnection* ui_status_connection_; |
72 | 73 |
73 DISALLOW_COPY_AND_ASSIGN(InputUiController); | 74 DISALLOW_COPY_AND_ASSIGN(InputUiController); |
74 }; | 75 }; |
75 | 76 |
76 InputUiController::InputUiController( | 77 InputUiController::InputUiController( |
77 ExtensionInputUiEventRouter* router) : | 78 ExtensionInputUiEventRouter* router) : |
78 router_(router), | 79 router_(router), |
79 ui_status_connection_(NULL) { | 80 ui_status_connection_(NULL) { |
80 std::string error; | 81 if (!chromeos::CrosLibrary::Get()->EnsureLoaded()) |
81 chromeos::LoadLibcros(NULL, error); | 82 return; |
82 | 83 |
83 chromeos::InputMethodUiStatusMonitorFunctions functions; | 84 chromeos::InputMethodUiStatusMonitorFunctions functions; |
84 functions.hide_auxiliary_text = | 85 functions.hide_auxiliary_text = |
85 &InputUiController::OnHideAuxiliaryText; | 86 &InputUiController::OnHideAuxiliaryText; |
86 functions.hide_lookup_table = | 87 functions.hide_lookup_table = |
87 &InputUiController::OnHideLookupTable; | 88 &InputUiController::OnHideLookupTable; |
88 functions.set_cursor_location = | 89 functions.set_cursor_location = |
89 &InputUiController::OnSetCursorLocation; | 90 &InputUiController::OnSetCursorLocation; |
90 functions.update_auxiliary_text = | 91 functions.update_auxiliary_text = |
91 &InputUiController::OnUpdateAuxiliaryText; | 92 &InputUiController::OnUpdateAuxiliaryText; |
92 functions.update_lookup_table = | 93 functions.update_lookup_table = |
93 &InputUiController::OnUpdateLookupTable; | 94 &InputUiController::OnUpdateLookupTable; |
94 ui_status_connection_ = chromeos::MonitorInputMethodUiStatus(functions, this); | 95 ui_status_connection_ = chromeos::MonitorInputMethodUiStatus(functions, this); |
95 | 96 |
96 if (!ui_status_connection_) | 97 if (!ui_status_connection_) |
97 LOG(ERROR) << "chromeos::MonitorInputMethodUiStatus() failed!"; | 98 LOG(ERROR) << "chromeos::MonitorInputMethodUiStatus() failed!"; |
98 } | 99 } |
99 | 100 |
100 InputUiController::~InputUiController() { | 101 InputUiController::~InputUiController() { |
101 chromeos::DisconnectInputMethodUiStatus(ui_status_connection_); | 102 if (ui_status_connection_) |
| 103 chromeos::DisconnectInputMethodUiStatus(ui_status_connection_); |
102 } | 104 } |
103 | 105 |
104 void InputUiController::CandidateClicked( | 106 void InputUiController::CandidateClicked( |
105 int index, int button, int flags) { | 107 int index, int button, int flags) { |
106 chromeos::NotifyCandidateClicked(ui_status_connection_, index, button, flags); | 108 chromeos::NotifyCandidateClicked(ui_status_connection_, index, button, flags); |
107 } | 109 } |
108 | 110 |
109 void InputUiController::CursorUp() { | 111 void InputUiController::CursorUp() { |
110 chromeos::NotifyCursorUp(ui_status_connection_); | 112 chromeos::NotifyCursorUp(ui_status_connection_); |
111 } | 113 } |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 profile(), extension_id()); | 344 profile(), extension_id()); |
343 return true; | 345 return true; |
344 } | 346 } |
345 | 347 |
346 bool PageDownInputUiFunction::RunImpl() { | 348 bool PageDownInputUiFunction::RunImpl() { |
347 ExtensionInputUiEventRouter::GetInstance()->PageDown( | 349 ExtensionInputUiEventRouter::GetInstance()->PageDown( |
348 profile(), extension_id()); | 350 profile(), extension_id()); |
349 return true; | 351 return true; |
350 } | 352 } |
351 | 353 |
OLD | NEW |