| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 DictionaryValue* dict = new DictionaryValue(); | 106 DictionaryValue* dict = new DictionaryValue(); |
| 107 dict->SetBoolean("visible", false); | 107 dict->SetBoolean("visible", false); |
| 108 | 108 |
| 109 ListValue *candidates = new ListValue(); | 109 ListValue *candidates = new ListValue(); |
| 110 dict->Set("candidates", candidates); | 110 dict->Set("candidates", candidates); |
| 111 | 111 |
| 112 ListValue args; | 112 ListValue args; |
| 113 args.Append(dict); | 113 args.Append(dict); |
| 114 | 114 |
| 115 std::string json_args; | 115 std::string json_args; |
| 116 base::JSONWriter::Write(&args, false, &json_args); | 116 base::JSONWriter::Write(&args, &json_args); |
| 117 profile_->GetExtensionEventRouter()->DispatchEventToExtension( | 117 profile_->GetExtensionEventRouter()->DispatchEventToExtension( |
| 118 extension_id_, events::kOnUpdateLookupTable, json_args, profile_, GURL()); | 118 extension_id_, events::kOnUpdateLookupTable, json_args, profile_, GURL()); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void ExtensionInputUiEventRouter::OnHidePreeditText() { | 121 void ExtensionInputUiEventRouter::OnHidePreeditText() { |
| 122 } | 122 } |
| 123 | 123 |
| 124 void ExtensionInputUiEventRouter::OnSetCursorLocation( | 124 void ExtensionInputUiEventRouter::OnSetCursorLocation( |
| 125 int x, int y, int width, int height) { | 125 int x, int y, int width, int height) { |
| 126 | 126 |
| 127 if (profile_ == NULL || extension_id_.empty()) | 127 if (profile_ == NULL || extension_id_.empty()) |
| 128 return; | 128 return; |
| 129 | 129 |
| 130 ListValue args; | 130 ListValue args; |
| 131 args.Append(Value::CreateIntegerValue(x)); | 131 args.Append(Value::CreateIntegerValue(x)); |
| 132 args.Append(Value::CreateIntegerValue(y)); | 132 args.Append(Value::CreateIntegerValue(y)); |
| 133 args.Append(Value::CreateIntegerValue(width)); | 133 args.Append(Value::CreateIntegerValue(width)); |
| 134 args.Append(Value::CreateIntegerValue(height)); | 134 args.Append(Value::CreateIntegerValue(height)); |
| 135 | 135 |
| 136 std::string json_args; | 136 std::string json_args; |
| 137 base::JSONWriter::Write(&args, false, &json_args); | 137 base::JSONWriter::Write(&args, &json_args); |
| 138 profile_->GetExtensionEventRouter()->DispatchEventToExtension( | 138 profile_->GetExtensionEventRouter()->DispatchEventToExtension( |
| 139 extension_id_, events::kOnSetCursorLocation, json_args, profile_, GURL()); | 139 extension_id_, events::kOnSetCursorLocation, json_args, profile_, GURL()); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void ExtensionInputUiEventRouter::OnUpdateAuxiliaryText( | 142 void ExtensionInputUiEventRouter::OnUpdateAuxiliaryText( |
| 143 const std::string& utf8_text, | 143 const std::string& utf8_text, |
| 144 bool visible) { | 144 bool visible) { |
| 145 if (profile_ == NULL || extension_id_.empty()) | 145 if (profile_ == NULL || extension_id_.empty()) |
| 146 return; | 146 return; |
| 147 | 147 |
| 148 ListValue args; | 148 ListValue args; |
| 149 args.Append(Value::CreateStringValue(visible ? utf8_text : "")); | 149 args.Append(Value::CreateStringValue(visible ? utf8_text : "")); |
| 150 | 150 |
| 151 std::string json_args; | 151 std::string json_args; |
| 152 base::JSONWriter::Write(&args, false, &json_args); | 152 base::JSONWriter::Write(&args, &json_args); |
| 153 profile_->GetExtensionEventRouter()->DispatchEventToExtension( | 153 profile_->GetExtensionEventRouter()->DispatchEventToExtension( |
| 154 extension_id_, events::kOnUpdateAuxiliaryText, json_args, profile_, GURL()); | 154 extension_id_, events::kOnUpdateAuxiliaryText, json_args, profile_, GURL()); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void ExtensionInputUiEventRouter::OnUpdateLookupTable( | 157 void ExtensionInputUiEventRouter::OnUpdateLookupTable( |
| 158 const chromeos::input_method::InputMethodLookupTable& lookup_table) { | 158 const chromeos::input_method::InputMethodLookupTable& lookup_table) { |
| 159 if (profile_ == NULL || extension_id_.empty()) | 159 if (profile_ == NULL || extension_id_.empty()) |
| 160 return; | 160 return; |
| 161 | 161 |
| 162 DictionaryValue* dict = new DictionaryValue(); | 162 DictionaryValue* dict = new DictionaryValue(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 175 for (size_t i = begin; i < end; i++) { | 175 for (size_t i = begin; i < end; i++) { |
| 176 candidates->Append(Value::CreateStringValue(lookup_table.candidates[i])); | 176 candidates->Append(Value::CreateStringValue(lookup_table.candidates[i])); |
| 177 } | 177 } |
| 178 | 178 |
| 179 dict->Set("candidates", candidates); | 179 dict->Set("candidates", candidates); |
| 180 | 180 |
| 181 ListValue args; | 181 ListValue args; |
| 182 args.Append(dict); | 182 args.Append(dict); |
| 183 | 183 |
| 184 std::string json_args; | 184 std::string json_args; |
| 185 base::JSONWriter::Write(&args, false, &json_args); | 185 base::JSONWriter::Write(&args, &json_args); |
| 186 profile_->GetExtensionEventRouter()->DispatchEventToExtension( | 186 profile_->GetExtensionEventRouter()->DispatchEventToExtension( |
| 187 extension_id_, events::kOnUpdateLookupTable, json_args, profile_, GURL()); | 187 extension_id_, events::kOnUpdateLookupTable, json_args, profile_, GURL()); |
| 188 } | 188 } |
| 189 | 189 |
| 190 void ExtensionInputUiEventRouter::OnUpdatePreeditText( | 190 void ExtensionInputUiEventRouter::OnUpdatePreeditText( |
| 191 const std::string& utf8_text, | 191 const std::string& utf8_text, |
| 192 unsigned int cursor, | 192 unsigned int cursor, |
| 193 bool visible) { | 193 bool visible) { |
| 194 } | 194 } |
| 195 | 195 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 ExtensionInputUiEventRouter::GetInstance()->PageUp( | 230 ExtensionInputUiEventRouter::GetInstance()->PageUp( |
| 231 profile(), extension_id()); | 231 profile(), extension_id()); |
| 232 return true; | 232 return true; |
| 233 } | 233 } |
| 234 | 234 |
| 235 bool PageDownInputUiFunction::RunImpl() { | 235 bool PageDownInputUiFunction::RunImpl() { |
| 236 ExtensionInputUiEventRouter::GetInstance()->PageDown( | 236 ExtensionInputUiEventRouter::GetInstance()->PageDown( |
| 237 profile(), extension_id()); | 237 profile(), extension_id()); |
| 238 return true; | 238 return true; |
| 239 } | 239 } |
| OLD | NEW |