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 "chrome/browser/chromeos/input_method/input_method_manager_impl.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> // std::find | 9 #include <algorithm> // std::find |
10 #include <memory> | 10 #include <memory> |
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 | 1216 |
1217 void InputMethodManagerImpl::OverrideKeyboardUrlRef(const std::string& keyset) { | 1217 void InputMethodManagerImpl::OverrideKeyboardUrlRef(const std::string& keyset) { |
1218 GURL url = keyboard::GetOverrideContentUrl(); | 1218 GURL url = keyboard::GetOverrideContentUrl(); |
1219 | 1219 |
1220 // If fails to find ref or tag "id" in the ref, it means the current IME is | 1220 // If fails to find ref or tag "id" in the ref, it means the current IME is |
1221 // not system IME, and we don't support show emoji, handwriting or voice | 1221 // not system IME, and we don't support show emoji, handwriting or voice |
1222 // input for such IME extension. | 1222 // input for such IME extension. |
1223 if (!url.has_ref()) | 1223 if (!url.has_ref()) |
1224 return; | 1224 return; |
1225 std::string overridden_ref = url.ref(); | 1225 std::string overridden_ref = url.ref(); |
1226 auto i = overridden_ref.find("id"); | 1226 auto i = overridden_ref.find("id="); |
1227 if (i == std::string::npos) | 1227 if (i == std::string::npos) |
1228 return; | 1228 return; |
1229 | 1229 |
1230 if (keyset.empty()) { | 1230 if (keyset.empty()) { |
| 1231 // Resets the url as the input method default url and notify the hash |
| 1232 // changed to VK. |
1231 keyboard::SetOverrideContentUrl( | 1233 keyboard::SetOverrideContentUrl( |
1232 GetActiveIMEState()->GetCurrentInputMethod().input_view_url()); | 1234 GetActiveIMEState()->GetCurrentInputMethod().input_view_url()); |
| 1235 keyboard::KeyboardController* keyboard_controller = |
| 1236 keyboard::KeyboardController::GetInstance(); |
| 1237 if (keyboard_controller) |
| 1238 keyboard_controller->Reload(); |
1233 return; | 1239 return; |
1234 } | 1240 } |
1235 | 1241 |
1236 // For system IME extension, the input view url is overridden as: | 1242 // For system IME extension, the input view url is overridden as: |
1237 // chrome-extension://${extension_id}/inputview.html#id=us.compact.qwerty | 1243 // chrome-extension://${extension_id}/inputview.html#id=us.compact.qwerty |
1238 // &language=en-US&passwordLayout=us.compact.qwerty&name=keyboard_us | 1244 // &language=en-US&passwordLayout=us.compact.qwerty&name=keyboard_us |
1239 // Fow emoji and handwriting input, we replace the id=${keyset} part with | 1245 // Fow emoji, handwriting and voice input, we append the keyset to the end of |
1240 // desired keyset like: id=emoji; For voice, we append ".voice" to the end of | 1246 // id like: id=${keyset}.emoji/hwt/voice. |
1241 // id like: id=${keyset}.voice. | |
1242 auto j = overridden_ref.find("&", i + 1); | 1247 auto j = overridden_ref.find("&", i + 1); |
1243 if (keyset == "voice") { | 1248 if (j == std::string::npos) { |
| 1249 overridden_ref += "." + keyset; |
| 1250 } else { |
1244 overridden_ref.replace(j, 0, "." + keyset); | 1251 overridden_ref.replace(j, 0, "." + keyset); |
1245 } else { | |
1246 overridden_ref.replace(i, j - i, "id=" + keyset); | |
1247 } | 1252 } |
1248 | 1253 |
1249 GURL::Replacements replacements; | 1254 GURL::Replacements replacements; |
1250 replacements.SetRefStr(overridden_ref); | 1255 replacements.SetRefStr(overridden_ref); |
1251 keyboard::SetOverrideContentUrl(url.ReplaceComponents(replacements)); | 1256 keyboard::SetOverrideContentUrl(url.ReplaceComponents(replacements)); |
1252 } | 1257 } |
1253 | 1258 |
1254 bool InputMethodManagerImpl::IsEmojiHandwritingVoiceOnImeMenuEnabled() { | 1259 bool InputMethodManagerImpl::IsEmojiHandwritingVoiceOnImeMenuEnabled() { |
1255 return base::FeatureList::IsEnabled(features::kEHVInputOnImeMenu); | 1260 return base::FeatureList::IsEnabled(features::kEHVInputOnImeMenu); |
1256 } | 1261 } |
1257 | 1262 |
1258 } // namespace input_method | 1263 } // namespace input_method |
1259 } // namespace chromeos | 1264 } // namespace chromeos |
OLD | NEW |