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 #if defined(OS_ANDROID)
77 has_user_gesture(false),
79 transferred_request_child_id(-1),
80 transferred_request_request_id(-1) {
83 StartNavigationParams::StartNavigationParams(
85 const std::string
& extra_headers
,
86 const std::vector
<unsigned char>& browser_initiated_post_data
,
87 #if defined(OS_ANDROID)
88 bool has_user_gesture
,
90 int transferred_request_child_id
,
91 int transferred_request_request_id
)
93 extra_headers(extra_headers
),
94 browser_initiated_post_data(browser_initiated_post_data
),
95 #if defined(OS_ANDROID)
96 has_user_gesture(has_user_gesture
),
98 transferred_request_child_id(transferred_request_child_id
),
99 transferred_request_request_id(transferred_request_request_id
) {
102 StartNavigationParams::~StartNavigationParams() {
105 RequestNavigationParams::RequestNavigationParams()
106 : is_overriding_user_agent(false),
107 browser_navigation_start(base::TimeTicks::Now()),
108 can_load_local_resources(false),
109 request_time(base::Time::Now()),
112 is_same_document_history_load(false),
113 has_committed_real_load(false),
114 intended_as_new_entry(false),
115 pending_history_list_offset(-1),
116 current_history_list_offset(-1),
117 current_history_list_length(0),
118 should_clear_history_list(false) {
121 RequestNavigationParams::RequestNavigationParams(
122 bool is_overriding_user_agent
,
123 base::TimeTicks navigation_start
,
124 const std::vector
<GURL
>& redirects
,
125 bool can_load_local_resources
,
126 base::Time request_time
,
127 const PageState
& page_state
,
130 bool is_same_document_history_load
,
131 bool has_committed_real_load
,
132 bool intended_as_new_entry
,
133 int pending_history_list_offset
,
134 int current_history_list_offset
,
135 int current_history_list_length
,
136 bool should_clear_history_list
)
137 : is_overriding_user_agent(is_overriding_user_agent
),
138 browser_navigation_start(navigation_start
),
139 redirects(redirects
),
140 can_load_local_resources(can_load_local_resources
),
141 request_time(request_time
),
142 page_state(page_state
),
144 nav_entry_id(nav_entry_id
),
145 is_same_document_history_load(is_same_document_history_load
),
146 has_committed_real_load(has_committed_real_load
),
147 intended_as_new_entry(intended_as_new_entry
),
148 pending_history_list_offset(pending_history_list_offset
),
149 current_history_list_offset(current_history_list_offset
),
150 current_history_list_length(current_history_list_length
),
151 should_clear_history_list(should_clear_history_list
) {
154 RequestNavigationParams::~RequestNavigationParams() {
157 NavigationParams::NavigationParams(
158 const CommonNavigationParams
& common_params
,
159 const StartNavigationParams
& start_params
,
160 const RequestNavigationParams
& request_params
)
161 : common_params(common_params
),
162 start_params(start_params
),
163 request_params(request_params
) {
166 NavigationParams::~NavigationParams() {
169 } // namespace content