 Chromium Code Reviews
 Chromium Code Reviews Issue 2484793002:
  Remove access to WebContents in RWHVA::SynchronousFrameMetadata()  (Closed)
    
  
    Issue 2484793002:
  Remove access to WebContents in RWHVA::SynchronousFrameMetadata()  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/renderer_host/render_widget_host_view_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 
| 6 | 6 | 
| 7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> | 
| 8 | 8 | 
| 9 #include <utility> | 9 #include <utility> | 
| 10 | 10 | 
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 428 while (RenderWidgetHost* widget = widgets->GetNextHost()) { | 428 while (RenderWidgetHost* widget = widgets->GetNextHost()) { | 
| 429 if (widget->GetView()) { | 429 if (widget->GetView()) { | 
| 430 static_cast<RenderWidgetHostViewAndroid*>(widget->GetView()) | 430 static_cast<RenderWidgetHostViewAndroid*>(widget->GetView()) | 
| 431 ->OnLostResources(); | 431 ->OnLostResources(); | 
| 432 } | 432 } | 
| 433 } | 433 } | 
| 434 } | 434 } | 
| 435 | 435 | 
| 436 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( | 436 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( | 
| 437 RenderWidgetHostImpl* widget_host, | 437 RenderWidgetHostImpl* widget_host, | 
| 438 ContentViewCoreImpl* content_view_core) | 438 ContentViewCoreImpl* content_view_core, | 
| 439 RenderWidgetHostViewAndroidDelegate* delegate) | |
| 439 : host_(widget_host), | 440 : host_(widget_host), | 
| 440 outstanding_vsync_requests_(0), | 441 outstanding_vsync_requests_(0), | 
| 441 is_showing_(!widget_host->is_hidden()), | 442 is_showing_(!widget_host->is_hidden()), | 
| 442 is_window_visible_(true), | 443 is_window_visible_(true), | 
| 443 is_window_activity_started_(true), | 444 is_window_activity_started_(true), | 
| 444 content_view_core_(nullptr), | 445 content_view_core_(nullptr), | 
| 445 ime_adapter_android_(this), | 446 ime_adapter_android_(this), | 
| 446 cached_background_color_(SK_ColorWHITE), | 447 cached_background_color_(SK_ColorWHITE), | 
| 447 last_compositor_frame_sink_id_(kUndefinedCompositorFrameSinkId), | 448 last_compositor_frame_sink_id_(kUndefinedCompositorFrameSinkId), | 
| 448 gesture_provider_(ui::GetGestureProviderConfig( | 449 gesture_provider_(ui::GetGestureProviderConfig( | 
| 449 ui::GestureProviderConfigType::CURRENT_PLATFORM), | 450 ui::GestureProviderConfigType::CURRENT_PLATFORM), | 
| 450 this), | 451 this), | 
| 451 stylus_text_selector_(this), | 452 stylus_text_selector_(this), | 
| 452 using_browser_compositor_(CompositorImpl::IsInitialized()), | 453 using_browser_compositor_(CompositorImpl::IsInitialized()), | 
| 453 frame_evictor_(new DelegatedFrameEvictor(this)), | 454 frame_evictor_(new DelegatedFrameEvictor(this)), | 
| 455 delegate_(delegate), | |
| 454 locks_on_frame_count_(0), | 456 locks_on_frame_count_(0), | 
| 455 observing_root_window_(false), | 457 observing_root_window_(false), | 
| 456 weak_ptr_factory_(this) { | 458 weak_ptr_factory_(this) { | 
| 457 // Set the layer which will hold the content layer for this view. The content | 459 // Set the layer which will hold the content layer for this view. The content | 
| 458 // layer is managed by the DelegatedFrameHost. | 460 // layer is managed by the DelegatedFrameHost. | 
| 459 view_.SetLayer(cc::Layer::Create()); | 461 view_.SetLayer(cc::Layer::Create()); | 
| 460 if (using_browser_compositor_) { | 462 if (using_browser_compositor_) { | 
| 461 delegated_frame_host_.reset(new ui::DelegatedFrameHostAndroid( | 463 delegated_frame_host_.reset(new ui::DelegatedFrameHostAndroid( | 
| 462 &view_, cached_background_color_, | 464 &view_, cached_background_color_, | 
| 463 base::Bind(&RenderWidgetHostViewAndroid::ReturnResources, | 465 base::Bind(&RenderWidgetHostViewAndroid::ReturnResources, | 
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 594 RenderWidgetHostViewAndroid::GetNativeViewAccessible() { | 596 RenderWidgetHostViewAndroid::GetNativeViewAccessible() { | 
| 595 NOTIMPLEMENTED(); | 597 NOTIMPLEMENTED(); | 
| 596 return NULL; | 598 return NULL; | 
| 597 } | 599 } | 
| 598 | 600 | 
| 599 void RenderWidgetHostViewAndroid::Focus() { | 601 void RenderWidgetHostViewAndroid::Focus() { | 
| 600 host_->Focus(); | 602 host_->Focus(); | 
| 601 if (overscroll_controller_) | 603 if (overscroll_controller_) | 
| 602 overscroll_controller_->Enable(); | 604 overscroll_controller_->Enable(); | 
| 603 if (content_view_core_) { | 605 if (content_view_core_) { | 
| 604 WebContentsImpl* web_contents_impl = | 606 if (delegate_->ShowingInterstitialPage()) | 
| 605 static_cast<WebContentsImpl*>(content_view_core_->GetWebContents()); | |
| 606 if (web_contents_impl->ShowingInterstitialPage()) | |
| 607 content_view_core_->ForceUpdateImeAdapter(GetNativeImeAdapter()); | 607 content_view_core_->ForceUpdateImeAdapter(GetNativeImeAdapter()); | 
| 
boliu
2016/11/07 18:44:36
I think this can move to WebContentsViewAndroid, m
 
Jinsuk Kim
2016/11/07 23:26:36
Done.
 | |
| 608 } | 608 } | 
| 609 } | 609 } | 
| 610 | 610 | 
| 611 bool RenderWidgetHostViewAndroid::HasFocus() const { | 611 bool RenderWidgetHostViewAndroid::HasFocus() const { | 
| 612 if (!content_view_core_) | 612 if (!content_view_core_) | 
| 613 return false; // ContentViewCore not created yet. | 613 return false; // ContentViewCore not created yet. | 
| 614 | 614 | 
| 615 return content_view_core_->HasFocus(); | 615 return content_view_core_->HasFocus(); | 
| 616 } | 616 } | 
| 617 | 617 | 
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1184 if (host_ && host_->input_router()) { | 1184 if (host_ && host_->input_router()) { | 
| 1185 host_->input_router()->NotifySiteIsMobileOptimized( | 1185 host_->input_router()->NotifySiteIsMobileOptimized( | 
| 1186 is_mobile_optimized); | 1186 is_mobile_optimized); | 
| 1187 } | 1187 } | 
| 1188 | 1188 | 
| 1189 // This is a subset of OnSwapCompositorFrame() used in the synchronous | 1189 // This is a subset of OnSwapCompositorFrame() used in the synchronous | 
| 1190 // compositor flow. | 1190 // compositor flow. | 
| 1191 OnFrameMetadataUpdated(frame_metadata.Clone(), false); | 1191 OnFrameMetadataUpdated(frame_metadata.Clone(), false); | 
| 1192 | 1192 | 
| 1193 // DevTools ScreenCast support for Android WebView. | 1193 // DevTools ScreenCast support for Android WebView. | 
| 1194 WebContents* web_contents = content_view_core_->GetWebContents(); | 1194 scoped_refptr<DevToolsAgentHost> dtah = delegate_->GetDevToolsAgentHost(); | 
| 1195 if (DevToolsAgentHost::HasFor(web_contents)) { | 1195 if (dtah) { | 
| 1196 scoped_refptr<DevToolsAgentHost> dtah = | |
| 1197 DevToolsAgentHost::GetOrCreateFor(web_contents); | |
| 1198 // Unblock the compositor. | 1196 // Unblock the compositor. | 
| 1199 BrowserThread::PostTask( | 1197 BrowserThread::PostTask( | 
| 1200 BrowserThread::UI, FROM_HERE, | 1198 BrowserThread::UI, FROM_HERE, | 
| 1201 base::Bind( | 1199 base::Bind( | 
| 1202 &RenderFrameDevToolsAgentHost::SynchronousSwapCompositorFrame, | 1200 &RenderFrameDevToolsAgentHost::SynchronousSwapCompositorFrame, | 
| 1203 static_cast<RenderFrameDevToolsAgentHost*>(dtah.get()), | 1201 static_cast<RenderFrameDevToolsAgentHost*>(dtah.get()), | 
| 1204 base::Passed(&frame_metadata))); | 1202 base::Passed(&frame_metadata))); | 
| 1205 } | 1203 } | 
| 1206 } | 1204 } | 
| 1207 | 1205 | 
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1784 selection_controller_ = CreateSelectionController(this, content_view_core_); | 1782 selection_controller_ = CreateSelectionController(this, content_view_core_); | 
| 1785 | 1783 | 
| 1786 if (!overscroll_controller_ && | 1784 if (!overscroll_controller_ && | 
| 1787 view_.GetWindowAndroid()->GetCompositor()) { | 1785 view_.GetWindowAndroid()->GetCompositor()) { | 
| 1788 overscroll_controller_ = CreateOverscrollController( | 1786 overscroll_controller_ = CreateOverscrollController( | 
| 1789 content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); | 1787 content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); | 
| 1790 } | 1788 } | 
| 1791 | 1789 | 
| 1792 if (!sync_compositor_) { | 1790 if (!sync_compositor_) { | 
| 1793 sync_compositor_ = SynchronousCompositorHost::Create( | 1791 sync_compositor_ = SynchronousCompositorHost::Create( | 
| 1794 this, content_view_core_->GetWebContents()); | 1792 this, content_view_core_->GetWebContents()); | 
| 
boliu
2016/11/07 18:44:36
you missed this one. along with the DevToolsAgentH
 
Jinsuk Kim
2016/11/07 23:26:36
Modified so that SynchronousCompositorClient is pa
 | |
| 1795 } | 1793 } | 
| 1796 } | 1794 } | 
| 1797 | 1795 | 
| 1798 void RenderWidgetHostViewAndroid::RunAckCallbacks() { | 1796 void RenderWidgetHostViewAndroid::RunAckCallbacks() { | 
| 1799 while (!ack_callbacks_.empty()) { | 1797 while (!ack_callbacks_.empty()) { | 
| 1800 ack_callbacks_.front().Run(); | 1798 ack_callbacks_.front().Run(); | 
| 1801 ack_callbacks_.pop(); | 1799 ack_callbacks_.pop(); | 
| 1802 } | 1800 } | 
| 1803 } | 1801 } | 
| 1804 | 1802 | 
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1966 case ui::MotionEvent::ACTION_UP: | 1964 case ui::MotionEvent::ACTION_UP: | 
| 1967 case ui::MotionEvent::ACTION_POINTER_UP: | 1965 case ui::MotionEvent::ACTION_POINTER_UP: | 
| 1968 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 1966 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 
| 1969 delta.InMicroseconds(), 1, 1000000, 50); | 1967 delta.InMicroseconds(), 1, 1000000, 50); | 
| 1970 default: | 1968 default: | 
| 1971 return; | 1969 return; | 
| 1972 } | 1970 } | 
| 1973 } | 1971 } | 
| 1974 | 1972 | 
| 1975 } // namespace content | 1973 } // namespace content | 
| OLD | NEW |