Chromium Code Reviews| 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" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 java_ref_(env, obj), | 163 java_ref_(env, obj), |
| 164 web_contents_(static_cast<WebContentsImpl*>(web_contents)), | 164 web_contents_(static_cast<WebContentsImpl*>(web_contents)), |
| 165 root_layer_(cc::Layer::Create()), | 165 root_layer_(cc::Layer::Create()), |
| 166 tab_crashed_(false), | 166 tab_crashed_(false), |
| 167 vsync_interval_(base::TimeDelta::FromMicroseconds( | 167 vsync_interval_(base::TimeDelta::FromMicroseconds( |
| 168 kDefaultVSyncIntervalMicros)), | 168 kDefaultVSyncIntervalMicros)), |
| 169 expected_browser_composite_time_(base::TimeDelta::FromMicroseconds( | 169 expected_browser_composite_time_(base::TimeDelta::FromMicroseconds( |
| 170 kDefaultVSyncIntervalMicros * kDefaultBrowserCompositeVSyncFraction)), | 170 kDefaultVSyncIntervalMicros * kDefaultBrowserCompositeVSyncFraction)), |
| 171 view_android_(view_android), | 171 view_android_(view_android), |
| 172 window_android_(window_android), | 172 window_android_(window_android), |
| 173 device_orientation_(0) { | 173 device_orientation_(0), |
| 174 compositor_(NULL) { | |
| 174 CHECK(web_contents) << | 175 CHECK(web_contents) << |
| 175 "A ContentViewCoreImpl should be created with a valid WebContents."; | 176 "A ContentViewCoreImpl should be created with a valid WebContents."; |
| 176 | 177 |
| 177 // When a tab is restored (from a saved state), it does not have a renderer | 178 // When a tab is restored (from a saved state), it does not have a renderer |
| 178 // process. We treat it like the tab is crashed. If the content is loaded | 179 // process. We treat it like the tab is crashed. If the content is loaded |
| 179 // when the tab is shown, tab_crashed_ will be reset. | 180 // when the tab is shown, tab_crashed_ will be reset. |
| 180 UpdateTabCrashedFlag(); | 181 UpdateTabCrashedFlag(); |
| 181 | 182 |
| 182 // TODO(leandrogracia): make use of the hardware_accelerated argument. | 183 // TODO(leandrogracia): make use of the hardware_accelerated argument. |
| 183 | 184 |
| (...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1588 } | 1589 } |
| 1589 | 1590 |
| 1590 void ContentViewCoreImpl::SendOrientationChangeEventInternal() { | 1591 void ContentViewCoreImpl::SendOrientationChangeEventInternal() { |
| 1591 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); | 1592 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
| 1592 if (rwhv) | 1593 if (rwhv) |
| 1593 rwhv->UpdateScreenInfo(rwhv->GetNativeView()); | 1594 rwhv->UpdateScreenInfo(rwhv->GetNativeView()); |
| 1594 | 1595 |
| 1595 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( | 1596 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( |
| 1596 web_contents_->GetRenderViewHost()); | 1597 web_contents_->GetRenderViewHost()); |
| 1597 rvhi->SendOrientationChangeEvent(device_orientation_); | 1598 rvhi->SendOrientationChangeEvent(device_orientation_); |
| 1599 | |
| 1600 void ContentViewCoreImpl::SetCompositor(Compositor* compositor) { | |
| 1601 compositor_ = compositor; | |
| 1602 if (web_contents_) { | |
| 1603 // Calling SetContentViewCore triggers the call set the ContentViewCore on | |
|
jdduke (slow)
2013/10/16 23:12:26
Nit: "triggers the call to set"
powei
2013/10/19 00:05:18
Done. Remove.
| |
| 1604 // RenderWidgetHostView, which also allows RenderWidgetHostView to attach | |
| 1605 // itsetlf as an observer on the compositor. | |
| 1606 static_cast<WebContentsViewAndroid*>(web_contents_->GetView()) | |
| 1607 ->SetContentViewCore(this); | |
|
no sievers
2013/10/16 23:34:23
Can we avoid piggy-backing on this other function?
powei
2013/10/19 00:05:18
Done.
| |
| 1608 } | |
|
jdduke (slow)
2013/10/16 23:12:26
So, the desired effect here is simply to trigger R
powei
2013/10/19 00:05:18
Done.
| |
| 1598 } | 1609 } |
| 1599 | 1610 |
| 1600 // This is called for each ContentView. | 1611 // This is called for each ContentView. |
| 1601 jint Init(JNIEnv* env, jobject obj, | 1612 jint Init(JNIEnv* env, jobject obj, |
| 1602 jboolean hardware_accelerated, | 1613 jboolean hardware_accelerated, |
| 1603 jint native_web_contents, | 1614 jint native_web_contents, |
| 1604 jint view_android, | 1615 jint view_android, |
| 1605 jint window_android) { | 1616 jint window_android) { |
| 1606 ContentViewCoreImpl* view = new ContentViewCoreImpl( | 1617 ContentViewCoreImpl* view = new ContentViewCoreImpl( |
| 1607 env, obj, hardware_accelerated, | 1618 env, obj, hardware_accelerated, |
| 1608 reinterpret_cast<WebContents*>(native_web_contents), | 1619 reinterpret_cast<WebContents*>(native_web_contents), |
| 1609 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1620 reinterpret_cast<ui::ViewAndroid*>(view_android), |
| 1610 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1621 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
| 1611 return reinterpret_cast<jint>(view); | 1622 return reinterpret_cast<jint>(view); |
| 1612 } | 1623 } |
| 1613 | 1624 |
| 1614 bool RegisterContentViewCore(JNIEnv* env) { | 1625 bool RegisterContentViewCore(JNIEnv* env) { |
| 1615 return RegisterNativesImpl(env); | 1626 return RegisterNativesImpl(env); |
| 1616 } | 1627 } |
| 1617 | 1628 |
| 1629 | |
|
powei
2013/10/16 22:42:35
empty lines to be removed.
powei
2013/10/19 00:05:18
Done.
| |
| 1630 | |
| 1618 } // namespace content | 1631 } // namespace content |
| OLD | NEW |