Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Side by Side Diff: chrome/browser/chromeos/input_method/input_method_manager_impl.cc

Issue 2603663002: Make IME extensions decide when to show the keyboard. (Closed)
Patch Set: Addressed comments. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/common/system/chromeos/ime_menu/ime_menu_tray.cc ('k') | ui/keyboard/keyboard_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 return; 1207 return;
1208 1208
1209 is_ime_menu_activated_ = state_->menu_activated; 1209 is_ime_menu_activated_ = state_->menu_activated;
1210 for (auto& observer : ime_menu_observers_) 1210 for (auto& observer : ime_menu_observers_)
1211 observer.ImeMenuActivationChanged(is_ime_menu_activated_); 1211 observer.ImeMenuActivationChanged(is_ime_menu_activated_);
1212 UMA_HISTOGRAM_BOOLEAN("InputMethod.ImeMenu.ActivationChanged", 1212 UMA_HISTOGRAM_BOOLEAN("InputMethod.ImeMenu.ActivationChanged",
1213 is_ime_menu_activated_); 1213 is_ime_menu_activated_);
1214 } 1214 }
1215 1215
1216 void InputMethodManagerImpl::OverrideKeyboardUrlRef(const std::string& keyset) { 1216 void InputMethodManagerImpl::OverrideKeyboardUrlRef(const std::string& keyset) {
1217 GURL url = keyboard::GetOverrideContentUrl(); 1217 GURL input_view_url;
1218 if (GetActiveIMEState()) {
1219 input_view_url =
1220 GetActiveIMEState()->GetCurrentInputMethod().input_view_url();
1221 }
1222 GURL url = input_view_url.is_empty() ? keyboard::GetOverrideContentUrl()
1223 : input_view_url;
1218 1224
1219 // If fails to find ref or tag "id" in the ref, it means the current IME is 1225 // If fails to find ref or tag "id" in the ref, it means the current IME is
1220 // not system IME, and we don't support show emoji, handwriting or voice 1226 // not system IME, and we don't support show emoji, handwriting or voice
1221 // input for such IME extension. 1227 // input for such IME extension.
1222 if (!url.has_ref()) 1228 if (!url.has_ref())
1223 return; 1229 return;
1224 std::string overridden_ref = url.ref(); 1230 std::string overridden_ref = url.ref();
1231
1225 auto i = overridden_ref.find("id="); 1232 auto i = overridden_ref.find("id=");
1226 if (i == std::string::npos) 1233 if (i == std::string::npos)
1227 return; 1234 return;
1228 1235
1229 if (keyset.empty()) { 1236 if (keyset.empty()) {
1230 // Resets the url as the input method default url and notify the hash 1237 // Resets the url as the input method default url and notify the hash
1231 // changed to VK. 1238 // changed to VK.
1232 keyboard::SetOverrideContentUrl( 1239 keyboard::SetOverrideContentUrl(input_view_url);
1233 GetActiveIMEState()->GetCurrentInputMethod().input_view_url());
1234 keyboard::KeyboardController* keyboard_controller = 1240 keyboard::KeyboardController* keyboard_controller =
1235 keyboard::KeyboardController::GetInstance(); 1241 keyboard::KeyboardController::GetInstance();
1236 if (keyboard_controller) 1242 if (keyboard_controller)
1237 keyboard_controller->Reload(); 1243 keyboard_controller->Reload();
1238 return; 1244 return;
1239 } 1245 }
1240 1246
1241 // For system IME extension, the input view url is overridden as: 1247 // For system IME extension, the input view url is overridden as:
1242 // chrome-extension://${extension_id}/inputview.html#id=us.compact.qwerty 1248 // chrome-extension://${extension_id}/inputview.html#id=us.compact.qwerty
1243 // &language=en-US&passwordLayout=us.compact.qwerty&name=keyboard_us 1249 // &language=en-US&passwordLayout=us.compact.qwerty&name=keyboard_us
1244 // Fow emoji, handwriting and voice input, we append the keyset to the end of 1250 // Fow emoji, handwriting and voice input, we append the keyset to the end of
1245 // id like: id=${keyset}.emoji/hwt/voice. 1251 // id like: id=${keyset}.emoji/hwt/voice.
1246 auto j = overridden_ref.find("&", i + 1); 1252 auto j = overridden_ref.find("&", i + 1);
1247 if (j == std::string::npos) { 1253 if (j == std::string::npos) {
1248 overridden_ref += "." + keyset; 1254 overridden_ref += "." + keyset;
1249 } else { 1255 } else {
1250 overridden_ref.replace(j, 0, "." + keyset); 1256 overridden_ref.replace(j, 0, "." + keyset);
1251 } 1257 }
1252 1258
1253 GURL::Replacements replacements; 1259 GURL::Replacements replacements;
1254 replacements.SetRefStr(overridden_ref); 1260 replacements.SetRefStr(overridden_ref);
1255 keyboard::SetOverrideContentUrl(url.ReplaceComponents(replacements)); 1261 keyboard::SetOverrideContentUrl(url.ReplaceComponents(replacements));
1262
1263 keyboard::KeyboardController* keyboard_controller =
1264 keyboard::KeyboardController::GetInstance();
1265 if (keyboard_controller)
1266 keyboard_controller->Reload();
1256 } 1267 }
1257 1268
1258 bool InputMethodManagerImpl::IsEmojiHandwritingVoiceOnImeMenuEnabled() { 1269 bool InputMethodManagerImpl::IsEmojiHandwritingVoiceOnImeMenuEnabled() {
1259 return base::FeatureList::IsEnabled(features::kEHVInputOnImeMenu); 1270 return base::FeatureList::IsEnabled(features::kEHVInputOnImeMenu);
1260 } 1271 }
1261 1272
1262 } // namespace input_method 1273 } // namespace input_method
1263 } // namespace chromeos 1274 } // namespace chromeos
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/ime_menu/ime_menu_tray.cc ('k') | ui/keyboard/keyboard_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698