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
3 // found in the LICENSE file.
5 #include "content/common/navigation_params.h"
7 #include "base/command_line.h"
8 #include "base/memory/ref_counted_memory.h"
9 #include "content/public/common/content_switches.h"
14 bool ShouldMakeNetworkRequestForURL(const GURL
& url
) {
15 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
16 switches::kEnableBrowserSideNavigation
));
18 // Data URLs, Javascript URLs and about:blank should not send a request to the
20 // TODO(clamy): same document navigations should not send requests to the
21 // network stack. Neither should pushState/popState.
22 return !url
.SchemeIs(url::kDataScheme
) && url
!= GURL(url::kAboutBlankURL
) &&
23 !url
.SchemeIs(url::kJavaScriptScheme
);
26 CommonNavigationParams::CommonNavigationParams()
27 : transition(ui::PAGE_TRANSITION_LINK
),
28 navigation_type(FrameMsg_Navigate_Type::NORMAL
),
30 should_replace_current_entry(false),
31 report_type(FrameMsg_UILoadMetricsReportType::NO_REPORT
) {
34 CommonNavigationParams::CommonNavigationParams(
36 const Referrer
& referrer
,
37 ui::PageTransition transition
,
38 FrameMsg_Navigate_Type::Value navigation_type
,
40 bool should_replace_current_entry
,
41 base::TimeTicks ui_timestamp
,
42 FrameMsg_UILoadMetricsReportType::Value report_type
,
43 const GURL
& base_url_for_data_url
,
44 const GURL
& history_url_for_data_url
)
47 transition(transition
),
48 navigation_type(navigation_type
),
49 allow_download(allow_download
),
50 should_replace_current_entry(should_replace_current_entry
),
51 ui_timestamp(ui_timestamp
),
52 report_type(report_type
),
53 base_url_for_data_url(base_url_for_data_url
),
54 history_url_for_data_url(history_url_for_data_url
) {
57 CommonNavigationParams::~CommonNavigationParams() {
60 BeginNavigationParams::BeginNavigationParams()
61 : load_flags(0), has_user_gesture(false) {
64 BeginNavigationParams::BeginNavigationParams(std::string method
,
67 bool has_user_gesture
)
70 load_flags(load_flags
),
71 has_user_gesture(has_user_gesture
) {
74 StartNavigationParams::StartNavigationParams()
76 transferred_request_child_id(-1),
77 transferred_request_request_id(-1) {
80 StartNavigationParams::StartNavigationParams(
82 const std::string
& extra_headers
,
83 const std::vector
<unsigned char>& browser_initiated_post_data
,
84 int transferred_request_child_id
,
85 int transferred_request_request_id
)
87 extra_headers(extra_headers
),
88 browser_initiated_post_data(browser_initiated_post_data
),
89 transferred_request_child_id(transferred_request_child_id
),
90 transferred_request_request_id(transferred_request_request_id
) {
93 StartNavigationParams::~StartNavigationParams() {
96 RequestNavigationParams::RequestNavigationParams()
97 : is_overriding_user_agent(false),
98 browser_navigation_start(base::TimeTicks::Now()),
99 can_load_local_resources(false),
100 request_time(base::Time::Now()),
103 is_same_document_history_load(false),
104 has_committed_real_load(false),
105 intended_as_new_entry(false),
106 pending_history_list_offset(-1),
107 current_history_list_offset(-1),
108 current_history_list_length(0),
109 should_clear_history_list(false) {
112 RequestNavigationParams::RequestNavigationParams(
113 bool is_overriding_user_agent
,
114 base::TimeTicks navigation_start
,
115 const std::vector
<GURL
>& redirects
,
116 bool can_load_local_resources
,
117 base::Time request_time
,
118 const PageState
& page_state
,
121 bool is_same_document_history_load
,
122 bool has_committed_real_load
,
123 bool intended_as_new_entry
,
124 int pending_history_list_offset
,
125 int current_history_list_offset
,
126 int current_history_list_length
,
127 bool should_clear_history_list
)
128 : is_overriding_user_agent(is_overriding_user_agent
),
129 browser_navigation_start(navigation_start
),
130 redirects(redirects
),
131 can_load_local_resources(can_load_local_resources
),
132 request_time(request_time
),
133 page_state(page_state
),
135 nav_entry_id(nav_entry_id
),
136 is_same_document_history_load(is_same_document_history_load
),
137 has_committed_real_load(has_committed_real_load
),
138 intended_as_new_entry(intended_as_new_entry
),
139 pending_history_list_offset(pending_history_list_offset
),
140 current_history_list_offset(current_history_list_offset
),
141 current_history_list_length(current_history_list_length
),
142 should_clear_history_list(should_clear_history_list
) {
145 RequestNavigationParams::~RequestNavigationParams() {
148 NavigationParams::NavigationParams(
149 const CommonNavigationParams
& common_params
,
150 const StartNavigationParams
& start_params
,
151 const RequestNavigationParams
& request_params
)
152 : common_params(common_params
),
153 start_params(start_params
),
154 request_params(request_params
) {
157 NavigationParams::~NavigationParams() {
160 } // namespace content