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

Side by Side Diff: chrome/browser/ui/android/context_menu_helper.cc

Issue 610913004: [Android] Handle a null java side of CVC in context menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/android/context_menu_helper.h" 5 #include "chrome/browser/ui/android/context_menu_helper.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "content/public/browser/android/content_view_core.h" 9 #include "content/public/browser/android/content_view_core.h"
10 #include "content/public/browser/android/download_controller_android.h" 10 #include "content/public/browser/android/download_controller_android.h"
(...skipping 23 matching lines...) Expand all
34 } 34 }
35 35
36 void ContextMenuHelper::ShowContextMenu( 36 void ContextMenuHelper::ShowContextMenu(
37 const content::ContextMenuParams& params) { 37 const content::ContextMenuParams& params) {
38 content::ContentViewCore* content_view_core = 38 content::ContentViewCore* content_view_core =
39 content::ContentViewCore::FromWebContents(web_contents_); 39 content::ContentViewCore::FromWebContents(web_contents_);
40 40
41 if (!content_view_core) 41 if (!content_view_core)
42 return; 42 return;
43 43
44 base::android::ScopedJavaLocalRef<jobject> jcontent_view_core(
45 content_view_core->GetJavaObject());
46
47 if (jcontent_view_core.is_null())
48 return;
49
44 JNIEnv* env = base::android::AttachCurrentThread(); 50 JNIEnv* env = base::android::AttachCurrentThread();
45 context_menu_params_ = params; 51 context_menu_params_ = params;
46 Java_ContextMenuHelper_showContextMenu( 52 Java_ContextMenuHelper_showContextMenu(
47 env, 53 env,
48 java_obj_.obj(), 54 java_obj_.obj(),
49 content_view_core->GetJavaObject().obj(), 55 jcontent_view_core.obj(),
50 ContextMenuHelper::CreateJavaContextMenuParams(params).obj()); 56 ContextMenuHelper::CreateJavaContextMenuParams(params).obj());
51 } 57 }
52 58
53 // Called to show a custom context menu. Used by the NTP. 59 // Called to show a custom context menu. Used by the NTP.
54 void ContextMenuHelper::ShowCustomContextMenu( 60 void ContextMenuHelper::ShowCustomContextMenu(
55 const content::ContextMenuParams& params, 61 const content::ContextMenuParams& params,
56 const base::Callback<void(int)>& callback) { 62 const base::Callback<void(int)>& callback) {
57 context_menu_callback_ = callback; 63 context_menu_callback_ = callback;
58 ShowContextMenu(params); 64 ShowContextMenu(params);
59 } 65 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 content::DownloadControllerAndroid::Get()->StartContextMenuDownload( 116 content::DownloadControllerAndroid::Get()->StartContextMenuDownload(
111 context_menu_params_, 117 context_menu_params_,
112 web_contents_, 118 web_contents_,
113 jis_link); 119 jis_link);
114 } 120 }
115 121
116 bool RegisterContextMenuHelper(JNIEnv* env) { 122 bool RegisterContextMenuHelper(JNIEnv* env) {
117 return RegisterNativesImpl(env) && 123 return RegisterNativesImpl(env) &&
118 ContextMenuParamsAndroid::RegisterNativesImpl(env); 124 ContextMenuParamsAndroid::RegisterNativesImpl(env);
119 } 125 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698