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"
16 // Check content::TopControlsState, and blink::WebWidget::TopControlsState
19 int(TOP_CONTROLS_STATE_SHOWN
) == int(blink::WebTopControlsShown
),
20 "mismatching enums: SHOWN");
22 int(TOP_CONTROLS_STATE_HIDDEN
) == int(blink::WebTopControlsHidden
),
23 "mismatching enums: HIDDEN");
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
,
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
;
43 constraints
= TOP_CONTROLS_STATE_HIDDEN
;
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
,
55 webwidget()->updateTopControlsState(ContentToBlink(constraints
),
56 ContentToBlink(current
),
59 top_controls_constraints_
= constraints
;
62 void RenderViewImpl::didScrollWithKeyboard(const blink::WebSize
& delta
) {
63 if (delta
.height
== 0)
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