OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/common/navigation_params.h" | 5 #include "content/common/navigation_params.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
| 9 #include "content/common/service_worker/service_worker_types.h" |
9 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
10 | 11 |
11 namespace content { | 12 namespace content { |
12 | 13 |
13 // PlzNavigate | 14 // PlzNavigate |
14 bool ShouldMakeNetworkRequestForURL(const GURL& url) { | 15 bool ShouldMakeNetworkRequestForURL(const GURL& url) { |
15 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 16 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
16 switches::kEnableBrowserSideNavigation)); | 17 switches::kEnableBrowserSideNavigation)); |
17 | 18 |
18 // Data URLs, Javascript URLs and about:blank should not send a request to the | 19 // Data URLs, Javascript URLs and about:blank should not send a request to the |
19 // network stack. | 20 // network stack. |
20 // TODO(clamy): same document navigations should not send requests to the | 21 // TODO(clamy): same document navigations should not send requests to the |
21 // network stack. Neither should pushState/popState. | 22 // network stack. Neither should pushState/popState. |
22 return !url.SchemeIs(url::kDataScheme) && url != GURL(url::kAboutBlankURL) && | 23 return !url.SchemeIs(url::kDataScheme) && url != GURL(url::kAboutBlankURL) && |
23 !url.SchemeIs(url::kJavaScriptScheme); | 24 !url.SchemeIs(url::kJavaScriptScheme); |
24 } | 25 } |
25 | 26 |
26 CommonNavigationParams::CommonNavigationParams() | 27 CommonNavigationParams::CommonNavigationParams() |
27 : transition(ui::PAGE_TRANSITION_LINK), | 28 : transition(ui::PAGE_TRANSITION_LINK), |
28 navigation_type(FrameMsg_Navigate_Type::NORMAL), | 29 navigation_type(FrameMsg_Navigate_Type::NORMAL), |
29 allow_download(true), | 30 allow_download(true), |
30 should_replace_current_entry(false), | 31 should_replace_current_entry(false), |
31 report_type(FrameMsg_UILoadMetricsReportType::NO_REPORT) { | 32 report_type(FrameMsg_UILoadMetricsReportType::NO_REPORT), |
| 33 service_worker_provider_id(kInvalidServiceWorkerProviderId) { |
32 } | 34 } |
33 | 35 |
34 CommonNavigationParams::CommonNavigationParams( | 36 CommonNavigationParams::CommonNavigationParams( |
35 const GURL& url, | 37 const GURL& url, |
36 const Referrer& referrer, | 38 const Referrer& referrer, |
37 ui::PageTransition transition, | 39 ui::PageTransition transition, |
38 FrameMsg_Navigate_Type::Value navigation_type, | 40 FrameMsg_Navigate_Type::Value navigation_type, |
39 bool allow_download, | 41 bool allow_download, |
40 bool should_replace_current_entry, | 42 bool should_replace_current_entry, |
41 base::TimeTicks ui_timestamp, | 43 base::TimeTicks ui_timestamp, |
42 FrameMsg_UILoadMetricsReportType::Value report_type, | 44 FrameMsg_UILoadMetricsReportType::Value report_type, |
43 const GURL& base_url_for_data_url, | 45 const GURL& base_url_for_data_url, |
44 const GURL& history_url_for_data_url) | 46 const GURL& history_url_for_data_url, |
| 47 int service_worker_provider_id) |
45 : url(url), | 48 : url(url), |
46 referrer(referrer), | 49 referrer(referrer), |
47 transition(transition), | 50 transition(transition), |
48 navigation_type(navigation_type), | 51 navigation_type(navigation_type), |
49 allow_download(allow_download), | 52 allow_download(allow_download), |
50 should_replace_current_entry(should_replace_current_entry), | 53 should_replace_current_entry(should_replace_current_entry), |
51 ui_timestamp(ui_timestamp), | 54 ui_timestamp(ui_timestamp), |
52 report_type(report_type), | 55 report_type(report_type), |
53 base_url_for_data_url(base_url_for_data_url), | 56 base_url_for_data_url(base_url_for_data_url), |
54 history_url_for_data_url(history_url_for_data_url) { | 57 history_url_for_data_url(history_url_for_data_url), |
| 58 service_worker_provider_id(service_worker_provider_id) { |
55 } | 59 } |
56 | 60 |
57 CommonNavigationParams::~CommonNavigationParams() { | 61 CommonNavigationParams::~CommonNavigationParams() { |
58 } | 62 } |
59 | 63 |
60 BeginNavigationParams::BeginNavigationParams() | 64 BeginNavigationParams::BeginNavigationParams() |
61 : load_flags(0), has_user_gesture(false) { | 65 : load_flags(0), |
| 66 has_user_gesture(false), |
| 67 skip_service_worker(false), |
| 68 fetch_request_mode(FETCH_REQUEST_MODE_NO_CORS), |
| 69 fetch_credentials_mode(FETCH_CREDENTIALS_MODE_SAME_ORIGIN), |
| 70 fetch_redirect_mode(FetchRedirectMode::FOLLOW_MODE), |
| 71 request_context_type(REQUEST_CONTEXT_TYPE_LOCATION), |
| 72 frame_type(REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL) { |
62 } | 73 } |
63 | 74 |
64 BeginNavigationParams::BeginNavigationParams(std::string method, | 75 BeginNavigationParams::BeginNavigationParams( |
65 std::string headers, | 76 std::string method, |
66 int load_flags, | 77 std::string headers, |
67 bool has_user_gesture) | 78 int load_flags, |
| 79 bool has_user_gesture, |
| 80 bool skip_service_worker, |
| 81 FetchRequestMode fetch_request_mode, |
| 82 FetchCredentialsMode fetch_credentials_mode, |
| 83 FetchRedirectMode fetch_redirect_mode, |
| 84 RequestContextType request_context_type, |
| 85 RequestContextFrameType frame_type) |
68 : method(method), | 86 : method(method), |
69 headers(headers), | 87 headers(headers), |
70 load_flags(load_flags), | 88 load_flags(load_flags), |
71 has_user_gesture(has_user_gesture) { | 89 has_user_gesture(has_user_gesture), |
| 90 skip_service_worker(skip_service_worker), |
| 91 fetch_request_mode(fetch_request_mode), |
| 92 fetch_credentials_mode(fetch_credentials_mode), |
| 93 fetch_redirect_mode(fetch_redirect_mode), |
| 94 request_context_type(request_context_type), |
| 95 frame_type(frame_type) { |
72 } | 96 } |
73 | 97 |
74 StartNavigationParams::StartNavigationParams() | 98 StartNavigationParams::StartNavigationParams() |
75 : is_post(false), | 99 : is_post(false), |
76 #if defined(OS_ANDROID) | 100 #if defined(OS_ANDROID) |
77 has_user_gesture(false), | 101 has_user_gesture(false), |
78 #endif | 102 #endif |
79 transferred_request_child_id(-1), | 103 transferred_request_child_id(-1), |
80 transferred_request_request_id(-1) { | 104 transferred_request_request_id(-1) { |
81 } | 105 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 const RequestNavigationParams& request_params) | 184 const RequestNavigationParams& request_params) |
161 : common_params(common_params), | 185 : common_params(common_params), |
162 start_params(start_params), | 186 start_params(start_params), |
163 request_params(request_params) { | 187 request_params(request_params) { |
164 } | 188 } |
165 | 189 |
166 NavigationParams::~NavigationParams() { | 190 NavigationParams::~NavigationParams() { |
167 } | 191 } |
168 | 192 |
169 } // namespace content | 193 } // namespace content |
OLD | NEW |