OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "content/browser/android/content_view_core_impl.h" | 5 #include "content/browser/android/content_view_core_impl.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "cc/layers/layer.h" | 17 #include "cc/layers/layer.h" |
18 #include "cc/layers/solid_color_layer.h" | 18 #include "cc/layers/solid_color_layer.h" |
19 #include "cc/output/begin_frame_args.h" | 19 #include "cc/output/begin_frame_args.h" |
20 #include "content/browser/android/gesture_event_type.h" | 20 #include "content/browser/android/gesture_event_type.h" |
21 #include "content/browser/android/interstitial_page_delegate_android.h" | 21 #include "content/browser/android/interstitial_page_delegate_android.h" |
22 #include "content/browser/android/java/gin_java_bridge_dispatcher_host.h" | 22 #include "content/browser/android/java/gin_java_bridge_dispatcher_host.h" |
23 #include "content/browser/android/load_url_params.h" | 23 #include "content/browser/android/load_url_params.h" |
24 #include "content/browser/frame_host/interstitial_page_impl.h" | 24 #include "content/browser/frame_host/interstitial_page_impl.h" |
25 #include "content/browser/frame_host/navigation_controller_impl.h" | 25 #include "content/browser/frame_host/navigation_controller_impl.h" |
26 #include "content/browser/frame_host/navigation_entry_impl.h" | 26 #include "content/browser/frame_host/navigation_entry_impl.h" |
27 #include "content/browser/geolocation/geolocation_dispatcher_host.h" | 27 #include "content/browser/geolocation/geolocation_dispatcher_host.h" |
28 #include "content/browser/media/media_web_contents_observer.h" | 28 #include "content/browser/media/media_web_contents_observer.h" |
29 #include "content/browser/message_port_service.h" | |
29 #include "content/browser/renderer_host/compositor_impl_android.h" | 30 #include "content/browser/renderer_host/compositor_impl_android.h" |
30 #include "content/browser/renderer_host/input/motion_event_android.h" | 31 #include "content/browser/renderer_host/input/motion_event_android.h" |
31 #include "content/browser/renderer_host/input/web_input_event_builders_android.h " | 32 #include "content/browser/renderer_host/input/web_input_event_builders_android.h " |
32 #include "content/browser/renderer_host/input/web_input_event_util.h" | 33 #include "content/browser/renderer_host/input/web_input_event_util.h" |
33 #include "content/browser/renderer_host/render_view_host_impl.h" | 34 #include "content/browser/renderer_host/render_view_host_impl.h" |
34 #include "content/browser/renderer_host/render_widget_host_impl.h" | 35 #include "content/browser/renderer_host/render_widget_host_impl.h" |
35 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 36 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
36 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host. h" | 37 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host. h" |
37 #include "content/browser/ssl/ssl_host_state.h" | 38 #include "content/browser/ssl/ssl_host_state.h" |
38 #include "content/browser/transition_request_manager.h" | 39 #include "content/browser/transition_request_manager.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 return -1; | 152 return -1; |
152 }; | 153 }; |
153 } | 154 } |
154 | 155 |
155 float GetPrimaryDisplayDeviceScaleFactor() { | 156 float GetPrimaryDisplayDeviceScaleFactor() { |
156 const gfx::Display& display = | 157 const gfx::Display& display = |
157 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 158 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
158 return display.device_scale_factor(); | 159 return display.device_scale_factor(); |
159 } | 160 } |
160 | 161 |
162 void CreateMessageChannelOnIOThread( | |
163 MessagePortMessageFilter* filter, | |
164 int routing_id, | |
165 int* port1, int* port2) { | |
166 | |
167 *port1 = 0; | |
168 *port2 = 0; | |
169 MessagePortService* msp = MessagePortService::GetInstance(); | |
170 msp->Create(routing_id, filter, port1); | |
171 msp->Create(routing_id, filter, port2); | |
172 msp->QueueMessages(*port1); | |
173 msp->QueueMessages(*port2); | |
174 } | |
175 | |
176 void OnMessageChannelCreated( | |
177 ScopedJavaGlobalRef<jobject>* callback, | |
178 int* port1, int* port2) { | |
179 JNIEnv* env = AttachCurrentThread(); | |
180 Java_ContentViewCore_onMessageChannelCreated(env, *port1, *port2, | |
181 callback->obj()); | |
182 } | |
183 | |
161 } // namespace | 184 } // namespace |
162 | 185 |
163 // Enables a callback when the underlying WebContents is destroyed, to enable | 186 // Enables a callback when the underlying WebContents is destroyed, to enable |
164 // nulling the back-pointer. | 187 // nulling the back-pointer. |
165 class ContentViewCoreImpl::ContentViewUserData | 188 class ContentViewCoreImpl::ContentViewUserData |
166 : public base::SupportsUserData::Data { | 189 : public base::SupportsUserData::Data { |
167 public: | 190 public: |
168 explicit ContentViewUserData(ContentViewCoreImpl* content_view_core) | 191 explicit ContentViewUserData(ContentViewCoreImpl* content_view_core) |
169 : content_view_core_(content_view_core) { | 192 : content_view_core_(content_view_core) { |
170 } | 193 } |
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1416 ScopedJavaGlobalRef<jobject> j_callback; | 1439 ScopedJavaGlobalRef<jobject> j_callback; |
1417 j_callback.Reset(env, callback); | 1440 j_callback.Reset(env, callback); |
1418 content::RenderFrameHost::JavaScriptResultCallback c_callback = | 1441 content::RenderFrameHost::JavaScriptResultCallback c_callback = |
1419 base::Bind(&JavaScriptResultCallback, j_callback); | 1442 base::Bind(&JavaScriptResultCallback, j_callback); |
1420 | 1443 |
1421 web_contents_->GetMainFrame()->ExecuteJavaScript( | 1444 web_contents_->GetMainFrame()->ExecuteJavaScript( |
1422 ConvertJavaStringToUTF16(env, script), | 1445 ConvertJavaStringToUTF16(env, script), |
1423 c_callback); | 1446 c_callback); |
1424 } | 1447 } |
1425 | 1448 |
1449 void ContentViewCoreImpl::CreateMessageChannel(JNIEnv* env, jobject obj, | |
1450 jobject callback) { | |
1451 | |
1452 ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>(); | |
1453 j_callback->Reset(env, callback); | |
1454 RenderProcessHostImpl* rph = | |
1455 static_cast<RenderProcessHostImpl*>( | |
1456 web_contents_->GetRenderProcessHost()); | |
1457 MessagePortMessageFilter* mf = rph->message_port_message_filter(); | |
1458 | |
1459 int port1; | |
Yaron
2014/07/18 21:54:00
These are stack allocated and are passing to anoth
sgurun-gerrit only
2014/10/28 00:41:10
Done.
| |
1460 int port2; | |
1461 // Create message channel on IO thread | |
1462 BrowserThread::PostTaskAndReply( | |
1463 BrowserThread::IO, | |
1464 FROM_HERE, | |
1465 base::Bind(&CreateMessageChannelOnIOThread, | |
1466 mf, | |
1467 GetWebContents()->GetRoutingID(), | |
1468 &port1, &port2), | |
1469 base::Bind(&OnMessageChannelCreated, | |
1470 base::Owned(j_callback), | |
1471 &port1, &port2)); | |
1472 } | |
1473 | |
1426 bool ContentViewCoreImpl::GetUseDesktopUserAgent( | 1474 bool ContentViewCoreImpl::GetUseDesktopUserAgent( |
1427 JNIEnv* env, jobject obj) { | 1475 JNIEnv* env, jobject obj) { |
1428 NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry(); | 1476 NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry(); |
1429 return entry && entry->GetIsOverridingUserAgent(); | 1477 return entry && entry->GetIsOverridingUserAgent(); |
1430 } | 1478 } |
1431 | 1479 |
1432 void ContentViewCoreImpl::UpdateImeAdapter(long native_ime_adapter, | 1480 void ContentViewCoreImpl::UpdateImeAdapter(long native_ime_adapter, |
1433 int text_input_type, | 1481 int text_input_type, |
1434 const std::string& text, | 1482 const std::string& text, |
1435 int selection_start, | 1483 int selection_start, |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1657 reinterpret_cast<ui::WindowAndroid*>(window_android), | 1705 reinterpret_cast<ui::WindowAndroid*>(window_android), |
1658 retained_objects_set); | 1706 retained_objects_set); |
1659 return reinterpret_cast<intptr_t>(view); | 1707 return reinterpret_cast<intptr_t>(view); |
1660 } | 1708 } |
1661 | 1709 |
1662 bool RegisterContentViewCore(JNIEnv* env) { | 1710 bool RegisterContentViewCore(JNIEnv* env) { |
1663 return RegisterNativesImpl(env); | 1711 return RegisterNativesImpl(env); |
1664 } | 1712 } |
1665 | 1713 |
1666 } // namespace content | 1714 } // namespace content |
OLD | NEW |