Add device_type to SharedPageState as a prelude to removing user_agent_type from...
[chromium-blink-merge.git] / android_webview / native / aw_web_contents_view_delegate.cc
blob94f582aab962264549fb4be713e9058f55ea998c
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 "android_webview/native/aw_web_contents_view_delegate.h"
7 #include "content/public/browser/android/content_view_core.h"
8 #include "content/public/browser/web_contents.h"
9 #include "content/public/common/context_menu_params.h"
11 namespace android_webview {
13 // static
14 content::WebContentsViewDelegate* AwWebContentsViewDelegate::Create(
15 content::WebContents* web_contents) {
16 return new AwWebContentsViewDelegate(web_contents);
19 AwWebContentsViewDelegate::AwWebContentsViewDelegate(
20 content::WebContents* web_contents)
21 : web_contents_(web_contents) {
22 // Cannot instantiate web_contents_view_delegate_ here because
23 // AwContents::SetWebDelegate is not called yet.
26 AwWebContentsViewDelegate::~AwWebContentsViewDelegate() {}
28 content::WebDragDestDelegate* AwWebContentsViewDelegate::GetDragDestDelegate() {
29 // GetDragDestDelegate is a pure virtual method from WebContentsViewDelegate
30 // and must have an implementation although android doesn't use it.
31 NOTREACHED();
32 return NULL;
35 void AwWebContentsViewDelegate::ShowContextMenu(
36 content::RenderFrameHost* render_frame_host,
37 const content::ContextMenuParams& params) {
38 // TODO(boliu): Large blocks of this function are identical with
39 // ChromeWebContentsViewDelegateAndroid::ShowContextMenu. De-dup this if
40 // possible.
42 // Display paste pop-up only when selection is empty and editable.
43 if (params.is_editable && params.selection_text.empty()) {
44 content::ContentViewCore* content_view_core =
45 content::ContentViewCore::FromWebContents(web_contents_);
46 if (content_view_core) {
47 content_view_core->ShowPastePopup(params.selection_start.x(),
48 params.selection_start.y());
53 } // namespace android_webview