Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 return; | 181 return; |
| 182 | 182 |
| 183 JNIEnv* env = base::android::AttachCurrentThread(); | 183 JNIEnv* env = base::android::AttachCurrentThread(); |
| 184 base::android::ScopedJavaLocalRef<jbyteArray> j_bytes = | 184 base::android::ScopedJavaLocalRef<jbyteArray> j_bytes = |
| 185 base::android::ToJavaByteArray(env, thumbnail_data); | 185 base::android::ToJavaByteArray(env, thumbnail_data); |
| 186 | 186 |
| 187 Java_ContextMenuHelper_onShareImageReceived(env, java_obj_, jwindow_android, | 187 Java_ContextMenuHelper_onShareImageReceived(env, java_obj_, jwindow_android, |
| 188 j_bytes); | 188 j_bytes); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void ContextMenuHelper::RetrieveHeaderThumbnail( | |
| 192 JNIEnv* env, | |
| 193 const JavaParamRef<jobject>& obj) { | |
| 194 content::RenderFrameHost* render_frame_host = | |
| 195 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); | |
| 196 if (!render_frame_host) | |
| 197 return; | |
| 198 | |
| 199 chrome::mojom::ThumbnailCapturerPtr thumbnail_capturer; | |
| 200 render_frame_host->GetRemoteInterfaces()->GetInterface(&thumbnail_capturer); | |
| 201 // Bind the InterfacePtr into the callback so that it's kept alive until | |
| 202 // there's either a connection error or a response. | |
| 203 auto* thumbnail_capturer_proxy = thumbnail_capturer.get(); | |
| 204 thumbnail_capturer_proxy->RequestThumbnailForContextNode( | |
| 205 0, gfx::Size(kShareImageMaxWidth, kShareImageMaxHeight), | |
|
David Trainor- moved to gerrit
2017/03/30 05:03:14
Our thumbnail size is the same size as the share?
JJ
2017/03/30 16:00:26
When running this morning I thought about the disp
David Trainor- moved to gerrit
2017/03/30 23:45:14
Should we scale this based on the density then? T
| |
| 206 base::Bind(&ContextMenuHelper::OnHeaderThumbnailReceived, | |
| 207 weak_factory_.GetWeakPtr(), | |
| 208 base::Passed(&thumbnail_capturer))); | |
| 209 } | |
| 210 | |
| 211 void ContextMenuHelper::OnHeaderThumbnailReceived( | |
| 212 chrome::mojom::ThumbnailCapturerPtr thumbnail_capturer, | |
| 213 const std::vector<uint8_t>& thumbnail_data, | |
| 214 const gfx::Size& original_size) { | |
| 215 content::ContentViewCore* content_view_core = | |
| 216 content::ContentViewCore::FromWebContents(web_contents_); | |
| 217 if (!content_view_core) | |
| 218 return; | |
| 219 | |
| 220 base::android::ScopedJavaLocalRef<jobject> jwindow_android( | |
| 221 content_view_core->GetWindowAndroid()->GetJavaObject()); | |
| 222 | |
| 223 if (jwindow_android.is_null()) | |
| 224 return; | |
| 225 | |
| 226 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 227 base::android::ScopedJavaLocalRef<jbyteArray> j_bytes = | |
| 228 base::android::ToJavaByteArray(env, thumbnail_data); | |
| 229 | |
| 230 Java_ContextMenuHelper_onHeaderThumbnailReceived(env, java_obj_, | |
| 231 jwindow_android, j_bytes); | |
| 232 } | |
| 233 | |
| 191 bool RegisterContextMenuHelper(JNIEnv* env) { | 234 bool RegisterContextMenuHelper(JNIEnv* env) { |
| 192 return RegisterNativesImpl(env); | 235 return RegisterNativesImpl(env); |
| 193 } | 236 } |
| OLD | NEW |