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

Side by Side Diff: android_webview/native/aw_web_contents_view_delegate.cc

Issue 11471040: [Android WebView] Convert context menu callback to long press (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add comments. Ready for review/submit. Created 8 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "android_webview/native/aw_web_contents_view_delegate.h"
6
7 #include "android_webview/browser/aw_web_contents_view_delegate_factory.h"
8 #include "android_webview/native/aw_contents.h"
9 #include "base/android/jni_android.h"
10 #include "content/public/browser/android/content_view_core.h"
11 #include "content/public/browser/web_contents.h"
12 #include "content/public/common/context_menu_params.h"
13 #include "jni/AwWebContentsViewDelegate_jni.h"
14
15 namespace android_webview {
16
17 content::WebContentsViewDelegate* CreateAwWebContentsViewDelegate(
18 content::WebContents* web_contents) {
19 return new AwWebContentsViewDelegate(web_contents);
20 }
21
22 AwWebContentsViewDelegate::AwWebContentsViewDelegate(
23 content::WebContents* web_contents)
24 : web_contents_(web_contents) {
25 // Cannot instantiate web_contents_view_delegate_ here because
26 // AwContents::SetWebDelegate is not called yet.
27 }
28
29 AwWebContentsViewDelegate::~AwWebContentsViewDelegate() {}
30
31 content::WebDragDestDelegate* AwWebContentsViewDelegate::GetDragDestDelegate() {
32 // GetDragDestDelegate is a pure virtual method from WebContentsViewDelegate
33 // and must have an implementation although android doesn't use it.
34 NOTREACHED();
35 return NULL;
36 }
37
38 void AwWebContentsViewDelegate::ShowContextMenu(
39 const content::ContextMenuParams& params,
40 content::ContextMenuSourceType type) {
41 // Display paste pop-up only when selection is empty and editable.
42 if (params.is_editable && params.selection_text.empty()) {
43 content::ContentViewCore* content_view_core =
44 web_contents_->GetContentNativeView();
45 if (content_view_core) {
46 content_view_core->ShowPastePopup(params.selection_start.x(),
47 params.selection_start.y());
48 return;
49 }
50 }
joth 2012/12/11 01:22:11 this code is identical to ChromeWebContentsViewDel
boliu 2012/12/11 02:25:33 Added a TODO
51
52 // Lazy create Java object.
53 if (web_contents_view_delegate_.is_null()) {
54 AwContents* aw_contents = AwContents::FromWebContents(web_contents_);
55 if (!aw_contents)
56 return;
57
58 web_contents_view_delegate_.Reset(
59 aw_contents->CreateAwWebContentsViewDelegate(this));
60 }
61
62 // More hackery can be done to combine |params| with the rest of the
63 // hit test methods if context menus are not working.
64 JNIEnv* env = base::android::AttachCurrentThread();
65 Java_AwWebContentsViewDelegate_onShowContextMenu(
66 env,
67 web_contents_view_delegate_.obj());
68 }
69
70 bool RegisterAwWebContentsViewDelegate(JNIEnv* env) {
71 return RegisterNativesImpl(env) >= 0;
72 }
73
74 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698