Update V8 to version 4.6.61.
[chromium-blink-merge.git] / content / renderer / render_view_impl_android.cc
blob9ba176cfcb5597c9f7aae642b995e65e10ff9004
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
3 // found in the LICENSE file.
5 #include "content/renderer/render_view_impl.h"
7 #include "base/command_line.h"
8 #include "base/message_loop/message_loop.h"
9 #include "cc/trees/layer_tree_host.h"
10 #include "content/common/view_messages.h"
11 #include "content/renderer/gpu/render_widget_compositor.h"
12 #include "third_party/WebKit/public/web/WebView.h"
14 namespace content {
16 // Check content::TopControlsState, and blink::WebWidget::TopControlsState
17 // are kept in sync.
18 static_assert(
19 int(TOP_CONTROLS_STATE_SHOWN) == int(blink::WebTopControlsShown),
20 "mismatching enums: SHOWN");
21 static_assert(
22 int(TOP_CONTROLS_STATE_HIDDEN) == int(blink::WebTopControlsHidden),
23 "mismatching enums: HIDDEN");
24 static_assert(
25 int(TOP_CONTROLS_STATE_BOTH) == int(blink::WebTopControlsBoth),
26 "mismatching enums: BOTH");
28 blink::WebTopControlsState ContentToBlink(
29 TopControlsState state) {
30 return static_cast<blink::WebTopControlsState>(state);
34 // TODO(mvanouwerkerk): Stop calling this code path and delete it.
35 void RenderViewImpl::OnUpdateTopControlsState(bool enable_hiding,
36 bool enable_showing,
37 bool animate) {
38 // TODO(tedchoc): Investigate why messages are getting here before the
39 // compositor has been initialized.
40 LOG_IF(WARNING, !compositor_) << "OnUpdateTopControlsState was unhandled.";
41 TopControlsState constraints = TOP_CONTROLS_STATE_BOTH;
42 if (!enable_showing)
43 constraints = TOP_CONTROLS_STATE_HIDDEN;
44 if (!enable_hiding)
45 constraints = TOP_CONTROLS_STATE_SHOWN;
46 TopControlsState current = TOP_CONTROLS_STATE_BOTH;
48 UpdateTopControlsState(constraints, current, animate);
51 void RenderViewImpl::UpdateTopControlsState(TopControlsState constraints,
52 TopControlsState current,
53 bool animate) {
54 if (webwidget())
55 webwidget()->updateTopControlsState(ContentToBlink(constraints),
56 ContentToBlink(current),
57 animate);
59 top_controls_constraints_ = constraints;
62 void RenderViewImpl::didScrollWithKeyboard(const blink::WebSize& delta) {
63 if (delta.height == 0)
64 return;
66 TopControlsState current = delta.height < 0 ? TOP_CONTROLS_STATE_SHOWN
67 : TOP_CONTROLS_STATE_HIDDEN;
69 UpdateTopControlsState(top_controls_constraints_, current, true);
72 void RenderViewImpl::OnExtractSmartClipData(const gfx::Rect& rect) {
73 blink::WebString clip_text;
74 blink::WebString clip_html;
75 blink::WebRect clip_rect;
76 webview()->extractSmartClipData(rect, clip_text, clip_html, clip_rect);
77 Send(new ViewHostMsg_SmartClipDataExtracted(
78 routing_id_, clip_text, clip_html, clip_rect));
81 } // namespace content