| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/web_contents/aura/overscroll_navigation_overlay.h" | 5 #include "content/browser/web_contents/aura/overscroll_navigation_overlay.h" |
| 6 | 6 |
| 7 #include "content/browser/frame_host/navigation_entry_impl.h" | 7 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 8 #include "content/browser/renderer_host/render_view_host_impl.h" | 8 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 9 #include "content/browser/web_contents/aura/image_window_delegate.h" | 9 #include "content/browser/web_contents/aura/image_window_delegate.h" |
| 10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } else { | 149 } else { |
| 150 window_slider_.reset(); | 150 window_slider_.reset(); |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 | 153 |
| 154 void OverscrollNavigationOverlay::SetupForTesting() { | 154 void OverscrollNavigationOverlay::SetupForTesting() { |
| 155 need_paint_update_ = false; | 155 need_paint_update_ = false; |
| 156 } | 156 } |
| 157 | 157 |
| 158 void OverscrollNavigationOverlay::StopObservingIfDone() { | 158 void OverscrollNavigationOverlay::StopObservingIfDone() { |
| 159 // If there is a screenshot displayed in the overlay window, then wait for | 159 if ((need_paint_update_ && !received_paint_update_)) { |
| 160 // the navigated page to complete loading and some paint update before | |
| 161 // hiding the overlay. | |
| 162 // If there is no screenshot in the overlay window, then hide this view | |
| 163 // as soon as there is any new painting notification. | |
| 164 if ((need_paint_update_ && !received_paint_update_) || | |
| 165 (image_delegate_->has_image() && !loading_complete_)) { | |
| 166 return; | 160 return; |
| 167 } | 161 } |
| 168 | 162 |
| 169 // If a slide is in progress, then do not destroy the window or the slide. | 163 // If a slide is in progress, then do not destroy the window or the slide. |
| 170 if (window_slider_.get() && window_slider_->IsSlideInProgress()) | 164 if (window_slider_.get() && window_slider_->IsSlideInProgress()) |
| 171 return; | 165 return; |
| 172 | 166 |
| 173 scoped_ptr<ui::Layer> layer; | 167 scoped_ptr<ui::Layer> layer; |
| 174 if (window_.get()) { | 168 if (window_.get()) { |
| 175 layer.reset(window_->AcquireLayer()); | 169 layer.reset(window_->AcquireLayer()); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 StopObservingIfDone(); | 300 StopObservingIfDone(); |
| 307 } | 301 } |
| 308 } | 302 } |
| 309 | 303 |
| 310 void OverscrollNavigationOverlay::DocumentOnLoadCompletedInMainFrame( | 304 void OverscrollNavigationOverlay::DocumentOnLoadCompletedInMainFrame( |
| 311 int32 page_id) { | 305 int32 page_id) { |
| 312 // Use the last committed entry rather than the active one, in case a | 306 // Use the last committed entry rather than the active one, in case a |
| 313 // pending entry has been created. | 307 // pending entry has been created. |
| 314 int committed_entry_id = | 308 int committed_entry_id = |
| 315 web_contents_->GetController().GetLastCommittedEntry()->GetUniqueID(); | 309 web_contents_->GetController().GetLastCommittedEntry()->GetUniqueID(); |
| 316 // For the purposes of dismissing the overlay - consider the loading completed | 310 // Consider the loading completed once the main frame has loaded. |
| 317 // once the main frame has loaded. | |
| 318 if (committed_entry_id == pending_entry_id_ || !pending_entry_id_) { | 311 if (committed_entry_id == pending_entry_id_ || !pending_entry_id_) { |
| 319 loading_complete_ = true; | 312 loading_complete_ = true; |
| 320 StopObservingIfDone(); | 313 StopObservingIfDone(); |
| 321 } | 314 } |
| 322 } | 315 } |
| 323 | 316 |
| 324 void OverscrollNavigationOverlay::DidFirstVisuallyNonEmptyPaint(int32 page_id) { | 317 void OverscrollNavigationOverlay::DidFirstVisuallyNonEmptyPaint(int32 page_id) { |
| 325 int visible_entry_id = | 318 int visible_entry_id = |
| 326 web_contents_->GetController().GetVisibleEntry()->GetUniqueID(); | 319 web_contents_->GetController().GetVisibleEntry()->GetUniqueID(); |
| 327 if (visible_entry_id == pending_entry_id_ || !pending_entry_id_) { | 320 if (visible_entry_id == pending_entry_id_ || !pending_entry_id_) { |
| 328 received_paint_update_ = true; | 321 received_paint_update_ = true; |
| 329 StopObservingIfDone(); | 322 StopObservingIfDone(); |
| 330 } | 323 } |
| 331 } | 324 } |
| 332 | 325 |
| 333 void OverscrollNavigationOverlay::DidStopLoading(RenderViewHost* host) { | 326 void OverscrollNavigationOverlay::DidStopLoading(RenderViewHost* host) { |
| 334 // Use the last committed entry rather than the active one, in case a | 327 // Use the last committed entry rather than the active one, in case a |
| 335 // pending entry has been created. | 328 // pending entry has been created. |
| 336 int committed_entry_id = | 329 int committed_entry_id = |
| 337 web_contents_->GetController().GetLastCommittedEntry()->GetUniqueID(); | 330 web_contents_->GetController().GetLastCommittedEntry()->GetUniqueID(); |
| 338 if (committed_entry_id == pending_entry_id_ || !pending_entry_id_) { | 331 if (committed_entry_id == pending_entry_id_ || !pending_entry_id_) { |
| 339 loading_complete_ = true; | 332 loading_complete_ = true; |
| 340 if (!received_paint_update_) { | 333 if (!received_paint_update_ && need_paint_update_) { |
| 341 // Force a repaint after the page is loaded. | 334 // Force a repaint after the page is loaded. |
| 342 RenderViewHostImpl* view = static_cast<RenderViewHostImpl*>(host); | 335 RenderViewHostImpl* view = static_cast<RenderViewHostImpl*>(host); |
| 343 view->ScheduleComposite(); | 336 view->ScheduleComposite(); |
| 344 } | 337 } |
| 345 StopObservingIfDone(); | 338 StopObservingIfDone(); |
| 346 } | 339 } |
| 347 } | 340 } |
| 348 | 341 |
| 349 bool OverscrollNavigationOverlay::OnMessageReceived( | 342 bool OverscrollNavigationOverlay::OnMessageReceived( |
| 350 const IPC::Message& message) { | 343 const IPC::Message& message) { |
| 351 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 344 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 352 IPC_BEGIN_MESSAGE_MAP(OverscrollNavigationOverlay, message) | 345 IPC_BEGIN_MESSAGE_MAP(OverscrollNavigationOverlay, message) |
| 353 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) | 346 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) |
| 354 IPC_END_MESSAGE_MAP() | 347 IPC_END_MESSAGE_MAP() |
| 355 return false; | 348 return false; |
| 356 } | 349 } |
| 357 | 350 |
| 358 } // namespace content | 351 } // namespace content |
| OLD | NEW |