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/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 4808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4819 CHECK_EQ(request_params.page_id, -1); | 4819 CHECK_EQ(request_params.page_id, -1); |
4820 | 4820 |
4821 should_load_request = true; | 4821 should_load_request = true; |
4822 } | 4822 } |
4823 | 4823 |
4824 if (should_load_request) { | 4824 if (should_load_request) { |
4825 // Sanitize navigation start now that we know the load_type. | 4825 // Sanitize navigation start now that we know the load_type. |
4826 pending_navigation_params_->common_params.navigation_start = | 4826 pending_navigation_params_->common_params.navigation_start = |
4827 SanitizeNavigationTiming(load_type, common_params.navigation_start, | 4827 SanitizeNavigationTiming(load_type, common_params.navigation_start, |
4828 renderer_navigation_start); | 4828 renderer_navigation_start); |
4829 // Perform a navigation to a data url if needed. | 4829 if (!common_params.data_url_with_base_url.is_empty()) { |
4830 if (!common_params.base_url_for_data_url.is_empty() || | 4830 LoadDataWithBaseURL(common_params, frame_); |
4831 (browser_side_navigation && | 4831 } else if (browser_side_navigation && |
4832 common_params.url.SchemeIs(url::kDataScheme))) { | 4832 common_params.url.SchemeIs(url::kDataScheme)) { |
| 4833 // Perform a navigation to a data url if needed. |
4833 LoadDataURL(common_params, frame_); | 4834 LoadDataURL(common_params, frame_); |
4834 } else { | 4835 } else { |
4835 // Load the request. | 4836 // Load the request. |
4836 frame_->toWebLocalFrame()->load(request, load_type, | 4837 frame_->toWebLocalFrame()->load(request, load_type, |
4837 item_for_history_navigation); | 4838 item_for_history_navigation); |
4838 } | 4839 } |
4839 } | 4840 } |
4840 | 4841 |
4841 // In case LoadRequest failed before didCreateDataSource was called. | 4842 // In case LoadRequest failed before didCreateDataSource was called. |
4842 pending_navigation_params_.reset(); | 4843 pending_navigation_params_.reset(); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5067 request->skipServiceWorker(), | 5068 request->skipServiceWorker(), |
5068 GetRequestContextTypeForWebURLRequest(*request)), | 5069 GetRequestContextTypeForWebURLRequest(*request)), |
5069 GetRequestBodyForWebURLRequest(*request))); | 5070 GetRequestBodyForWebURLRequest(*request))); |
5070 } | 5071 } |
5071 | 5072 |
5072 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params, | 5073 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params, |
5073 WebFrame* frame) { | 5074 WebFrame* frame) { |
5074 // A loadData request with a specified base URL. | 5075 // A loadData request with a specified base URL. |
5075 std::string mime_type, charset, data; | 5076 std::string mime_type, charset, data; |
5076 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { | 5077 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { |
5077 const GURL base_url = params.base_url_for_data_url.is_empty() ? | 5078 const GURL base_url; |
5078 params.url : params.base_url_for_data_url; | 5079 frame->loadData(WebData(data.c_str(), data.length()), |
| 5080 WebString::fromUTF8(mime_type), |
| 5081 WebString::fromUTF8(charset), |
| 5082 GURL(), // base_url |
| 5083 GURL(), // history_url |
| 5084 false); |
| 5085 } else { |
| 5086 CHECK(false) << "Invalid URL passed: " |
| 5087 << params.url.possibly_invalid_spec(); |
| 5088 } |
| 5089 } |
| 5090 |
| 5091 void RenderFrameImpl::LoadDataWithBaseURL(const CommonNavigationParams& params, |
| 5092 WebFrame* frame) { |
| 5093 std::string mime_type, charset, data; |
| 5094 if (net::DataURL::Parse(params.data_url_with_base_url, &mime_type, &charset, |
| 5095 &data)) { |
5079 frame->loadData( | 5096 frame->loadData( |
5080 WebData(data.c_str(), data.length()), | 5097 WebData(data.c_str(), data.length()), |
5081 WebString::fromUTF8(mime_type), | 5098 WebString::fromUTF8(mime_type), |
5082 WebString::fromUTF8(charset), | 5099 WebString::fromUTF8(charset), |
5083 base_url, | 5100 params.url, // base_url |
| 5101 // Needed to not identify only changing history url as reload. |
5084 params.history_url_for_data_url, | 5102 params.history_url_for_data_url, |
5085 false); | 5103 false); |
5086 } else { | 5104 } else { |
5087 CHECK(false) << "Invalid URL passed: " | 5105 CHECK(false) << "Invalid URL passed: " |
5088 << params.url.possibly_invalid_spec(); | 5106 << params.url.possibly_invalid_spec(); |
5089 } | 5107 } |
5090 } | 5108 } |
5091 | 5109 |
5092 void RenderFrameImpl::SendUpdateState() { | 5110 void RenderFrameImpl::SendUpdateState() { |
5093 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); | 5111 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5139 if (RenderThreadImpl::current() && | 5157 if (RenderThreadImpl::current() && |
5140 RenderThreadImpl::current()->layout_test_mode()) { | 5158 RenderThreadImpl::current()->layout_test_mode()) { |
5141 return false; | 5159 return false; |
5142 } | 5160 } |
5143 | 5161 |
5144 return true; | 5162 return true; |
5145 } | 5163 } |
5146 | 5164 |
5147 GURL RenderFrameImpl::GetLoadingUrl() const { | 5165 GURL RenderFrameImpl::GetLoadingUrl() const { |
5148 WebDataSource* ds = frame_->dataSource(); | 5166 WebDataSource* ds = frame_->dataSource(); |
| 5167 |
5149 if (ds->hasUnreachableURL()) | 5168 if (ds->hasUnreachableURL()) |
5150 return ds->unreachableURL(); | 5169 return ds->unreachableURL(); |
5151 | 5170 |
5152 const WebURLRequest& request = ds->request(); | 5171 const WebURLRequest& request = ds->request(); |
5153 return request.url(); | 5172 return request.url(); |
5154 } | 5173 } |
5155 | 5174 |
5156 void RenderFrameImpl::PopulateDocumentStateFromPending( | 5175 void RenderFrameImpl::PopulateDocumentStateFromPending( |
5157 DocumentState* document_state) { | 5176 DocumentState* document_state) { |
5158 document_state->set_request_time( | 5177 document_state->set_request_time( |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5373 media::ConvertToSwitchOutputDeviceCB(web_callbacks); | 5392 media::ConvertToSwitchOutputDeviceCB(web_callbacks); |
5374 scoped_refptr<media::AudioOutputDevice> device = | 5393 scoped_refptr<media::AudioOutputDevice> device = |
5375 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), | 5394 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), |
5376 security_origin); | 5395 security_origin); |
5377 media::OutputDeviceStatus status = device->GetDeviceStatus(); | 5396 media::OutputDeviceStatus status = device->GetDeviceStatus(); |
5378 device->Stop(); | 5397 device->Stop(); |
5379 callback.Run(status); | 5398 callback.Run(status); |
5380 } | 5399 } |
5381 | 5400 |
5382 } // namespace content | 5401 } // namespace content |
OLD | NEW |