| 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 /* | 5 /* |
| 6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
| 10 * | 10 * |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 pending_entry_index_(-1), | 219 pending_entry_index_(-1), |
| 220 transient_entry_index_(-1), | 220 transient_entry_index_(-1), |
| 221 delegate_(delegate), | 221 delegate_(delegate), |
| 222 max_restored_page_id_(-1), | 222 max_restored_page_id_(-1), |
| 223 ssl_manager_(this), | 223 ssl_manager_(this), |
| 224 needs_reload_(false), | 224 needs_reload_(false), |
| 225 is_initial_navigation_(true), | 225 is_initial_navigation_(true), |
| 226 in_navigate_to_pending_entry_(false), | 226 in_navigate_to_pending_entry_(false), |
| 227 pending_reload_(ReloadType::NONE), | 227 pending_reload_(ReloadType::NONE), |
| 228 get_timestamp_callback_(base::Bind(&base::Time::Now)), | 228 get_timestamp_callback_(base::Bind(&base::Time::Now)), |
| 229 screenshot_manager_(new NavigationEntryScreenshotManager(this)) { | 229 screenshot_manager_(new NavigationEntryScreenshotManager(this)), |
| 230 last_committed_reload_type_(ReloadType::NONE) { |
| 230 DCHECK(browser_context_); | 231 DCHECK(browser_context_); |
| 231 } | 232 } |
| 232 | 233 |
| 233 NavigationControllerImpl::~NavigationControllerImpl() { | 234 NavigationControllerImpl::~NavigationControllerImpl() { |
| 234 DiscardNonCommittedEntriesInternal(); | 235 DiscardNonCommittedEntriesInternal(); |
| 235 } | 236 } |
| 236 | 237 |
| 237 WebContents* NavigationControllerImpl::GetWebContents() const { | 238 WebContents* NavigationControllerImpl::GetWebContents() const { |
| 238 return delegate_->GetWebContents(); | 239 return delegate_->GetWebContents(); |
| 239 } | 240 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 if (current_index != -1) { | 323 if (current_index != -1) { |
| 323 entry = GetEntryAtIndex(current_index); | 324 entry = GetEntryAtIndex(current_index); |
| 324 } | 325 } |
| 325 } | 326 } |
| 326 | 327 |
| 327 // If we are no where, then we can't reload. TODO(darin): We should add a | 328 // If we are no where, then we can't reload. TODO(darin): We should add a |
| 328 // CanReload method. | 329 // CanReload method. |
| 329 if (!entry) | 330 if (!entry) |
| 330 return; | 331 return; |
| 331 | 332 |
| 333 // Check if previous navigation was a reload to track consecutive reload |
| 334 // operations. |
| 335 if (last_committed_reload_type_ != ReloadType::NONE) { |
| 336 DCHECK(!last_committed_reload_time_.is_null()); |
| 337 base::Time now = |
| 338 time_smoother_.GetSmoothedTime(get_timestamp_callback_.Run()); |
| 339 DCHECK_GT(now, last_committed_reload_time_); |
| 340 if (!last_committed_reload_time_.is_null() && |
| 341 now > last_committed_reload_time_) { |
| 342 base::TimeDelta delta = now - last_committed_reload_time_; |
| 343 UMA_HISTOGRAM_MEDIUM_TIMES("Navigation.Reload.ReloadToReloadDuration", |
| 344 delta); |
| 345 if (last_committed_reload_type_ == ReloadType::MAIN_RESOURCE) { |
| 346 UMA_HISTOGRAM_MEDIUM_TIMES( |
| 347 "Navigation.Reload.ReloadMainResourceToReloadDuration", delta); |
| 348 } |
| 349 } |
| 350 } |
| 351 |
| 352 // Set ReloadType for |entry| in order to check it at commit time. |
| 353 entry->set_reload_type(reload_type); |
| 354 |
| 332 if (g_check_for_repost && check_for_repost && | 355 if (g_check_for_repost && check_for_repost && |
| 333 entry->GetHasPostData()) { | 356 entry->GetHasPostData()) { |
| 334 // The user is asking to reload a page with POST data. Prompt to make sure | 357 // The user is asking to reload a page with POST data. Prompt to make sure |
| 335 // they really want to do this. If they do, the dialog will call us back | 358 // they really want to do this. If they do, the dialog will call us back |
| 336 // with check_for_repost = false. | 359 // with check_for_repost = false. |
| 337 delegate_->NotifyBeforeFormRepostWarningShow(); | 360 delegate_->NotifyBeforeFormRepostWarningShow(); |
| 338 | 361 |
| 339 pending_reload_ = reload_type; | 362 pending_reload_ = reload_type; |
| 340 delegate_->ActivateAndShowRepostFormWarningDialog(); | 363 delegate_->ActivateAndShowRepostFormWarningDialog(); |
| 341 } else { | 364 } else { |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 | 818 |
| 796 // The renderer tells us whether the navigation replaces the current entry. | 819 // The renderer tells us whether the navigation replaces the current entry. |
| 797 details->did_replace_entry = params.should_replace_current_entry; | 820 details->did_replace_entry = params.should_replace_current_entry; |
| 798 | 821 |
| 799 // Do navigation-type specific actions. These will make and commit an entry. | 822 // Do navigation-type specific actions. These will make and commit an entry. |
| 800 details->type = ClassifyNavigation(rfh, params); | 823 details->type = ClassifyNavigation(rfh, params); |
| 801 | 824 |
| 802 // is_in_page must be computed before the entry gets committed. | 825 // is_in_page must be computed before the entry gets committed. |
| 803 details->is_in_page = is_navigation_within_page; | 826 details->is_in_page = is_navigation_within_page; |
| 804 | 827 |
| 828 // Save reload type and timestamp for a reload navigation to detect |
| 829 // consecutive reloads when the next reload is requested. |
| 830 if (PendingEntryMatchesHandle(rfh->navigation_handle())) { |
| 831 if (pending_entry_->reload_type() != ReloadType::NONE) { |
| 832 last_committed_reload_type_ = pending_entry_->reload_type(); |
| 833 last_committed_reload_time_ = |
| 834 time_smoother_.GetSmoothedTime(get_timestamp_callback_.Run()); |
| 835 } else if (!pending_entry_->is_renderer_initiated() || |
| 836 params.gesture == NavigationGestureUser) { |
| 837 last_committed_reload_type_ = ReloadType::NONE; |
| 838 last_committed_reload_time_ = base::Time(); |
| 839 } |
| 840 } |
| 841 |
| 805 switch (details->type) { | 842 switch (details->type) { |
| 806 case NAVIGATION_TYPE_NEW_PAGE: | 843 case NAVIGATION_TYPE_NEW_PAGE: |
| 807 RendererDidNavigateToNewPage(rfh, params, details->is_in_page, | 844 RendererDidNavigateToNewPage(rfh, params, details->is_in_page, |
| 808 details->did_replace_entry); | 845 details->did_replace_entry); |
| 809 break; | 846 break; |
| 810 case NAVIGATION_TYPE_EXISTING_PAGE: | 847 case NAVIGATION_TYPE_EXISTING_PAGE: |
| 811 details->did_replace_entry = details->is_in_page; | 848 details->did_replace_entry = details->is_in_page; |
| 812 RendererDidNavigateToExistingPage(rfh, params, details->is_in_page); | 849 RendererDidNavigateToExistingPage(rfh, params, details->is_in_page); |
| 813 break; | 850 break; |
| 814 case NAVIGATION_TYPE_SAME_PAGE: | 851 case NAVIGATION_TYPE_SAME_PAGE: |
| (...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2104 } | 2141 } |
| 2105 } | 2142 } |
| 2106 } | 2143 } |
| 2107 | 2144 |
| 2108 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 2145 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
| 2109 const base::Callback<base::Time()>& get_timestamp_callback) { | 2146 const base::Callback<base::Time()>& get_timestamp_callback) { |
| 2110 get_timestamp_callback_ = get_timestamp_callback; | 2147 get_timestamp_callback_ = get_timestamp_callback; |
| 2111 } | 2148 } |
| 2112 | 2149 |
| 2113 } // namespace content | 2150 } // namespace content |
| OLD | NEW |