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/frame_messages.h" |
| 12 #include "content/public/browser/browser_context.h" |
10 #include "content/public/common/content_constants.h" | 13 #include "content/public/common/content_constants.h" |
11 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
12 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
13 #include "ui/gfx/text_elider.h" | 16 #include "ui/gfx/text_elider.h" |
14 | 17 |
15 // Use this to get a new unique ID for a NavigationEntry during construction. | 18 // 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). | 19 // The returned ID is guaranteed to be nonzero (which is the "no ID" indicator). |
17 static int GetUniqueIDInConstructor() { | 20 static int GetUniqueIDInConstructor() { |
18 static int unique_id_counter = 0; | 21 static int unique_id_counter = 0; |
19 return ++unique_id_counter; | 22 return ++unique_id_counter; |
20 } | 23 } |
21 | 24 |
22 namespace content { | 25 namespace content { |
23 | 26 |
| 27 namespace { |
| 28 |
| 29 FrameMsg_Navigate_Type::Value GetNavigationType( |
| 30 BrowserContext* browser_context, const NavigationEntryImpl* entry, |
| 31 NavigationController::ReloadType reload_type) { |
| 32 switch (reload_type) { |
| 33 case NavigationControllerImpl::RELOAD: |
| 34 return FrameMsg_Navigate_Type::RELOAD; |
| 35 case NavigationControllerImpl::RELOAD_IGNORING_CACHE: |
| 36 return FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE; |
| 37 case NavigationControllerImpl::RELOAD_ORIGINAL_REQUEST_URL: |
| 38 return FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; |
| 39 case NavigationControllerImpl::NO_RELOAD: |
| 40 break; // Fall through to rest of function. |
| 41 } |
| 42 |
| 43 // |RenderViewImpl::PopulateStateFromPendingNavigationParams| differentiates |
| 44 // between |RESTORE_WITH_POST| and |RESTORE|. |
| 45 if (entry->restore_type() == |
| 46 NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY) { |
| 47 if (entry->GetHasPostData()) |
| 48 return FrameMsg_Navigate_Type::RESTORE_WITH_POST; |
| 49 return FrameMsg_Navigate_Type::RESTORE; |
| 50 } |
| 51 |
| 52 return FrameMsg_Navigate_Type::NORMAL; |
| 53 } |
| 54 |
| 55 } // namespace |
| 56 |
24 int NavigationEntryImpl::kInvalidBindings = -1; | 57 int NavigationEntryImpl::kInvalidBindings = -1; |
25 | 58 |
26 NavigationEntry* NavigationEntry::Create() { | 59 NavigationEntry* NavigationEntry::Create() { |
27 return new NavigationEntryImpl(); | 60 return new NavigationEntryImpl(); |
28 } | 61 } |
29 | 62 |
30 NavigationEntry* NavigationEntry::Create(const NavigationEntry& copy) { | 63 NavigationEntry* NavigationEntry::Create(const NavigationEntry& copy) { |
31 return new NavigationEntryImpl(static_cast<const NavigationEntryImpl&>(copy)); | 64 return new NavigationEntryImpl(static_cast<const NavigationEntryImpl&>(copy)); |
32 } | 65 } |
33 | 66 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 set_frame_tree_node_id(-1); | 382 set_frame_tree_node_id(-1); |
350 } | 383 } |
351 | 384 |
352 void NavigationEntryImpl::SetScreenshotPNGData( | 385 void NavigationEntryImpl::SetScreenshotPNGData( |
353 scoped_refptr<base::RefCountedBytes> png_data) { | 386 scoped_refptr<base::RefCountedBytes> png_data) { |
354 screenshot_ = png_data; | 387 screenshot_ = png_data; |
355 if (screenshot_.get()) | 388 if (screenshot_.get()) |
356 UMA_HISTOGRAM_MEMORY_KB("Overscroll.ScreenshotSize", screenshot_->size()); | 389 UMA_HISTOGRAM_MEMORY_KB("Overscroll.ScreenshotSize", screenshot_->size()); |
357 } | 390 } |
358 | 391 |
| 392 void NavigationEntryImpl::MakeNavigateParams( |
| 393 const NavigationControllerImpl& controller, |
| 394 NavigationController::ReloadType reload_type, |
| 395 base::TimeTicks navigation_start, |
| 396 FrameMsg_Navigate_Params* params) const { |
| 397 params->page_id = GetPageID(); |
| 398 params->should_clear_history_list = should_clear_history_list(); |
| 399 params->should_replace_current_entry = should_replace_entry(); |
| 400 if (should_clear_history_list()) { |
| 401 // Set the history list related parameters to the same values a |
| 402 // NavigationController would return before its first navigation. This will |
| 403 // fully clear the RenderView's view of the session history. |
| 404 params->pending_history_list_offset = -1; |
| 405 params->current_history_list_offset = -1; |
| 406 params->current_history_list_length = 0; |
| 407 } else { |
| 408 params->pending_history_list_offset = controller.GetIndexOfEntry(this); |
| 409 params->current_history_list_offset = |
| 410 controller.GetLastCommittedEntryIndex(); |
| 411 params->current_history_list_length = controller.GetEntryCount(); |
| 412 } |
| 413 params->url = GetURL(); |
| 414 if (!GetBaseURLForDataURL().is_empty()) { |
| 415 params->base_url_for_data_url = GetBaseURLForDataURL(); |
| 416 params->history_url_for_data_url = GetVirtualURL(); |
| 417 } |
| 418 params->referrer = GetReferrer(); |
| 419 params->transition = GetTransitionType(); |
| 420 params->page_state = GetPageState(); |
| 421 params->navigation_type = |
| 422 GetNavigationType(controller.GetBrowserContext(), this, reload_type); |
| 423 params->request_time = base::Time::Now(); |
| 424 params->extra_headers = extra_headers(); |
| 425 params->transferred_request_child_id = |
| 426 transferred_global_request_id().child_id; |
| 427 params->transferred_request_request_id = |
| 428 transferred_global_request_id().request_id; |
| 429 params->is_overriding_user_agent = GetIsOverridingUserAgent(); |
| 430 // Avoid downloading when in view-source mode. |
| 431 params->allow_download = !IsViewSourceMode(); |
| 432 params->is_post = GetHasPostData(); |
| 433 if (GetBrowserInitiatedPostData()) { |
| 434 params->browser_initiated_post_data.assign( |
| 435 GetBrowserInitiatedPostData()->front(), |
| 436 GetBrowserInitiatedPostData()->front() + |
| 437 GetBrowserInitiatedPostData()->size()); |
| 438 } |
| 439 |
| 440 // Set the redirect chain to the navigation's redirects, unless we are |
| 441 // returning to a completed navigation (whose previous redirects don't apply). |
| 442 if (PageTransitionIsNewNavigation(params->transition)) { |
| 443 params->redirects = GetRedirectChain(); |
| 444 } else { |
| 445 params->redirects.clear(); |
| 446 } |
| 447 |
| 448 params->can_load_local_resources = GetCanLoadLocalResources(); |
| 449 params->frame_to_navigate = GetFrameToNavigate(); |
| 450 params->browser_navigation_start = navigation_start; |
| 451 } |
| 452 |
359 } // namespace content | 453 } // namespace content |
OLD | NEW |