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

Unified Diff: blimp/engine/session/blimp_engine_session.cc

Issue 1779673003: Added network components for blimp text input feature (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed initial values for tab id in ImeFeature Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: blimp/engine/session/blimp_engine_session.cc
diff --git a/blimp/engine/session/blimp_engine_session.cc b/blimp/engine/session/blimp_engine_session.cc
index eb144b13cd10186e867678411107a8270ce2bde9..fae16ef1a8ea719dfb0fefd43d55f4c9877b9443 100644
--- a/blimp/engine/session/blimp_engine_session.cc
+++ b/blimp/engine/session/blimp_engine_session.cc
@@ -32,6 +32,7 @@
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
+#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "net/base/ip_address.h"
#include "net/base/net_errors.h"
@@ -39,6 +40,8 @@
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
+#include "ui/base/ime/input_method.h"
+#include "ui/base/ime/text_input_client.h"
#include "ui/gfx/geometry/size.h"
#include "ui/wm/core/base_focus_rules.h"
#include "ui/wm/core/default_activation_client.h"
@@ -194,6 +197,8 @@ BlimpEngineSession::BlimpEngineSession(
BlimpEngineSession::~BlimpEngineSession() {
render_widget_feature_.RemoveDelegate(kDummyTabId);
+ window_tree_host_->GetInputMethod()->RemoveObserver(this);
+
// Ensure that all WebContents are torn down first, since teardown will
// trigger RenderViewDeleted callbacks to their observers.
web_contents_.reset();
@@ -223,6 +228,8 @@ void BlimpEngineSession::Initialize() {
capture_client_.reset(
new aura::client::DefaultCaptureClient(window_tree_host_->window()));
+ window_tree_host_->GetInputMethod()->AddObserver(this);
+
window_tree_host_->SetBounds(gfx::Rect(screen_->GetPrimaryDisplay().size()));
RegisterFeatures();
@@ -258,6 +265,9 @@ void BlimpEngineSession::RegisterFeatures() {
render_widget_feature_.set_compositor_message_sender(
thread_pipe_manager_->RegisterFeature(BlimpMessage::COMPOSITOR,
&render_widget_feature_));
+ render_widget_feature_.set_ime_message_sender(
+ thread_pipe_manager_->RegisterFeature(BlimpMessage::IME,
+ &render_widget_feature_));
}
bool BlimpEngineSession::CreateWebContents(const int target_tab_id) {
@@ -342,6 +352,52 @@ void BlimpEngineSession::OnCompositorMessageReceived(
render_widget_host->HandleCompositorProto(message);
}
+void BlimpEngineSession::OnTextInputTypeChanged(
+ const ui::TextInputClient* client) {}
+
+void BlimpEngineSession::OnFocus() {}
+
+void BlimpEngineSession::OnBlur() {}
+
+void BlimpEngineSession::OnCaretBoundsChanged(
+ const ui::TextInputClient* client) {}
+
+// Called when either:
+// - the TextInputClient is changed (e.g. by a change of focus)
+// - the TextInputType of the TextInputClient changes
+void BlimpEngineSession::OnTextInputStateChanged(
+ const ui::TextInputClient* client) {
+ if (!web_contents_->GetRenderWidgetHostView())
+ return;
+
+ ui::TextInputType type =
+ client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE;
+
+ // TODO(shaktisahu): Propagate the new type to the client.
+ // Hide IME, when text input is out of focus, i.e. if the text input type
+ // changes to ui::TEXT_INPUT_TYPE_NONE. For other text input types,
+ // OnShowImeIfNeeded is used instead to send show IME request to client.
+ if (type == ui::TEXT_INPUT_TYPE_NONE)
+ render_widget_feature_.SendHideImeRequest(
+ kDummyTabId,
+ web_contents_->GetRenderWidgetHostView()->GetRenderWidgetHost());
+}
+
+void BlimpEngineSession::OnInputMethodDestroyed(
+ const ui::InputMethod* input_method) {}
+
+// Called when a user input should trigger showing the IME.
+void BlimpEngineSession::OnShowImeIfNeeded() {
+ if (!web_contents_->GetRenderWidgetHostView() ||
+ !window_tree_host_->GetInputMethod()->GetTextInputClient())
+ return;
+
+ render_widget_feature_.SendShowImeRequest(
+ kDummyTabId,
+ web_contents_->GetRenderWidgetHostView()->GetRenderWidgetHost(),
+ window_tree_host_->GetInputMethod()->GetTextInputClient());
+}
+
void BlimpEngineSession::ProcessMessage(
scoped_ptr<BlimpMessage> message,
const net::CompletionCallback& callback) {

Powered by Google App Engine
This is Rietveld 408576698