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

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

Issue 1142863002: Remove support for custom menu items in context menus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « chrome/browser/ui/android/context_menu_helper.h ('k') | 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 "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h" 9 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h"
10 #include "content/public/browser/android/content_view_core.h" 10 #include "content/public/browser/android/content_view_core.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 JNIEnv* env = base::android::AttachCurrentThread(); 51 JNIEnv* env = base::android::AttachCurrentThread();
52 context_menu_params_ = params; 52 context_menu_params_ = params;
53 Java_ContextMenuHelper_showContextMenu( 53 Java_ContextMenuHelper_showContextMenu(
54 env, 54 env,
55 java_obj_.obj(), 55 java_obj_.obj(),
56 jcontent_view_core.obj(), 56 jcontent_view_core.obj(),
57 ContextMenuHelper::CreateJavaContextMenuParams(params).obj()); 57 ContextMenuHelper::CreateJavaContextMenuParams(params).obj());
58 } 58 }
59 59
60 // Called to show a custom context menu. Used by the NTP.
61 void ContextMenuHelper::ShowCustomContextMenu(
62 const content::ContextMenuParams& params,
63 const base::Callback<void(int)>& callback) {
64 context_menu_callback_ = callback;
65 ShowContextMenu(params);
66 }
67
68 void ContextMenuHelper::SetPopulator(jobject jpopulator) { 60 void ContextMenuHelper::SetPopulator(jobject jpopulator) {
69 JNIEnv* env = base::android::AttachCurrentThread(); 61 JNIEnv* env = base::android::AttachCurrentThread();
70 Java_ContextMenuHelper_setPopulator(env, java_obj_.obj(), jpopulator); 62 Java_ContextMenuHelper_setPopulator(env, java_obj_.obj(), jpopulator);
71 } 63 }
72 64
73 base::android::ScopedJavaLocalRef<jobject> 65 base::android::ScopedJavaLocalRef<jobject>
74 ContextMenuHelper::CreateJavaContextMenuParams( 66 ContextMenuHelper::CreateJavaContextMenuParams(
75 const content::ContextMenuParams& params) { 67 const content::ContextMenuParams& params) {
76 GURL sanitizedReferrer = (params.frame_url.is_empty() ? 68 GURL sanitizedReferrer = (params.frame_url.is_empty() ?
77 params.page_url : params.frame_url).GetAsReferrer(); 69 params.page_url : params.frame_url).GetAsReferrer();
(...skipping 14 matching lines...) Expand all
92 ConvertUTF16ToJavaString(env, params.link_text).obj(), 84 ConvertUTF16ToJavaString(env, params.link_text).obj(),
93 ConvertUTF8ToJavaString(env, params.unfiltered_link_url.spec()).obj(), 85 ConvertUTF8ToJavaString(env, params.unfiltered_link_url.spec()).obj(),
94 ConvertUTF8ToJavaString(env, params.src_url.spec()).obj(), 86 ConvertUTF8ToJavaString(env, params.src_url.spec()).obj(),
95 ConvertUTF16ToJavaString(env, params.selection_text).obj(), 87 ConvertUTF16ToJavaString(env, params.selection_text).obj(),
96 ConvertUTF16ToJavaString(env, params.title_text).obj(), 88 ConvertUTF16ToJavaString(env, params.title_text).obj(),
97 image_was_fetched_lo_fi, 89 image_was_fetched_lo_fi,
98 params.is_editable, 90 params.is_editable,
99 ConvertUTF8ToJavaString(env, sanitizedReferrer.spec()).obj(), 91 ConvertUTF8ToJavaString(env, sanitizedReferrer.spec()).obj(),
100 params.referrer_policy); 92 params.referrer_policy);
101 93
102 std::vector<content::MenuItem>::const_iterator i;
103 for (i = params.custom_items.begin(); i != params.custom_items.end(); ++i) {
104 ContextMenuParamsAndroid::Java_ContextMenuParams_addCustomItem(
105 env,
106 jmenu_info.obj(),
107 ConvertUTF16ToJavaString(env, i->label).obj(),
108 i->action);
109 }
110
111 return jmenu_info; 94 return jmenu_info;
112 } 95 }
113 96
114 void ContextMenuHelper::OnCustomItemSelected(JNIEnv* env,
115 jobject obj,
116 jint action) {
117 if (!context_menu_callback_.is_null()) {
118 context_menu_callback_.Run(action);
119 context_menu_callback_.Reset();
120 }
121 }
122
123 void ContextMenuHelper::OnStartDownload(JNIEnv* env, 97 void ContextMenuHelper::OnStartDownload(JNIEnv* env,
124 jobject obj, 98 jobject obj,
125 jboolean jis_link) { 99 jboolean jis_link) {
126 content::DownloadControllerAndroid::Get()->StartContextMenuDownload( 100 content::DownloadControllerAndroid::Get()->StartContextMenuDownload(
127 context_menu_params_, 101 context_menu_params_,
128 web_contents_, 102 web_contents_,
129 jis_link); 103 jis_link);
130 } 104 }
131 105
132 bool RegisterContextMenuHelper(JNIEnv* env) { 106 bool RegisterContextMenuHelper(JNIEnv* env) {
133 return RegisterNativesImpl(env) && 107 return RegisterNativesImpl(env) &&
134 ContextMenuParamsAndroid::RegisterNativesImpl(env); 108 ContextMenuParamsAndroid::RegisterNativesImpl(env);
135 } 109 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/context_menu_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698