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 #include "content/browser/frame_host/navigation_entry_impl.h" | 5 #include "content/browser/frame_host/navigation_entry_impl.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/browser/frame_host/navigation_controller_impl.h" | |
11 #include "content/common/navigation_params.h" | |
10 #include "content/public/common/content_constants.h" | 12 #include "content/public/common/content_constants.h" |
11 #include "content/public/common/url_constants.h" | 13 #include "content/public/common/url_constants.h" |
12 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
13 #include "ui/gfx/text_elider.h" | 15 #include "ui/gfx/text_elider.h" |
14 | 16 |
15 // Use this to get a new unique ID for a NavigationEntry during construction. | 17 // Use this to get a new unique ID for a NavigationEntry during construction. |
16 // The returned ID is guaranteed to be nonzero (which is the "no ID" indicator). | 18 // The returned ID is guaranteed to be nonzero (which is the "no ID" indicator). |
17 static int GetUniqueIDInConstructor() { | 19 static int GetUniqueIDInConstructor() { |
18 static int unique_id_counter = 0; | 20 static int unique_id_counter = 0; |
19 return ++unique_id_counter; | 21 return ++unique_id_counter; |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 scoped_refptr<base::RefCountedBytes> png_data) { | 350 scoped_refptr<base::RefCountedBytes> png_data) { |
349 screenshot_ = png_data; | 351 screenshot_ = png_data; |
350 if (screenshot_.get()) | 352 if (screenshot_.get()) |
351 UMA_HISTOGRAM_MEMORY_KB("Overscroll.ScreenshotSize", screenshot_->size()); | 353 UMA_HISTOGRAM_MEMORY_KB("Overscroll.ScreenshotSize", screenshot_->size()); |
352 } | 354 } |
353 | 355 |
354 GURL NavigationEntryImpl::GetHistoryURLForDataURL() const { | 356 GURL NavigationEntryImpl::GetHistoryURLForDataURL() const { |
355 return GetBaseURLForDataURL().is_empty() ? GURL() : GetVirtualURL(); | 357 return GetBaseURLForDataURL().is_empty() ? GURL() : GetVirtualURL(); |
356 } | 358 } |
357 | 359 |
360 CommonNavigationParams NavigationEntryImpl::ConstructCommonNavigationParams( | |
361 FrameMsg_Navigate_Type::Value navigation_type) const { | |
362 FrameMsg_UILoadMetricsReportType::Value report_type = | |
363 FrameMsg_UILoadMetricsReportType::NO_REPORT; | |
364 base::TimeTicks ui_timestamp = base::TimeTicks(); | |
365 #if defined(OS_ANDROID) | |
366 if (!intent_received_timestamp().is_null()) | |
367 report_type = FrameMsg_UILoadMetricsReportType::REPORT_INTENT; | |
368 ui_timestamp = intent_received_timestamp(); | |
369 #endif | |
370 | |
371 return CommonNavigationParams( | |
372 GetURL(), GetReferrer(), GetTransitionType(), navigation_type, | |
Charlie Reis
2015/03/17 04:01:03
This is where things get awkward for --site-per-pr
| |
373 !IsViewSourceMode(), ui_timestamp, report_type, GetBaseURLForDataURL(), | |
374 GetHistoryURLForDataURL()); | |
375 } | |
376 | |
377 CommitNavigationParams NavigationEntryImpl::ConstructCommitNavigationParams( | |
378 base::TimeTicks navigation_start) const { | |
379 // Set the redirect chain to the navigation's redirects, unless returning to a | |
380 // completed navigation (whose previous redirects don't apply). | |
381 std::vector<GURL> redirects; | |
382 if (ui::PageTransitionIsNewNavigation(GetTransitionType())) { | |
383 redirects = GetRedirectChain(); | |
384 } | |
385 | |
386 return CommitNavigationParams(GetIsOverridingUserAgent(), navigation_start, | |
387 redirects, GetCanLoadLocalResources(), | |
388 GetFrameToNavigate(), base::Time::Now()); | |
389 } | |
390 | |
391 HistoryNavigationParams NavigationEntryImpl::ConstructHistoryNavigationParams( | |
392 NavigationControllerImpl* controller) const { | |
393 int pending_history_list_offset = controller->GetIndexOfEntry(this); | |
394 int current_history_list_offset = controller->GetLastCommittedEntryIndex(); | |
395 int current_history_list_length = controller->GetEntryCount(); | |
396 if (should_clear_history_list()) { | |
397 // Set the history list related parameters to the same values a | |
398 // NavigationController would return before its first navigation. This will | |
399 // fully clear the RenderView's view of the session history. | |
400 pending_history_list_offset = -1; | |
401 current_history_list_offset = -1; | |
402 current_history_list_length = 0; | |
403 } | |
404 return HistoryNavigationParams( | |
405 GetPageState(), GetPageID(), pending_history_list_offset, | |
406 current_history_list_offset, current_history_list_length, | |
407 should_clear_history_list()); | |
408 } | |
409 | |
410 StartNavigationParams NavigationEntryImpl::ConstructStartNavigationParams() | |
411 const { | |
412 std::vector<unsigned char> browser_initiated_post_data; | |
413 if (GetBrowserInitiatedPostData()) { | |
414 browser_initiated_post_data.assign( | |
415 GetBrowserInitiatedPostData()->front(), | |
416 GetBrowserInitiatedPostData()->front() + | |
417 GetBrowserInitiatedPostData()->size()); | |
418 } | |
419 | |
420 return StartNavigationParams( | |
421 GetHasPostData(), extra_headers(), browser_initiated_post_data, | |
422 should_replace_entry(), transferred_global_request_id().child_id, | |
423 transferred_global_request_id().request_id); | |
424 } | |
425 | |
358 } // namespace content | 426 } // namespace content |
OLD | NEW |