Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 1873783003: Convert //content/renderer from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_frame_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/auto_reset.h" 12 #include "base/auto_reset.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/debug/alias.h" 14 #include "base/debug/alias.h"
15 #include "base/debug/asan_invalid_access.h" 15 #include "base/debug/asan_invalid_access.h"
16 #include "base/debug/crash_logging.h" 16 #include "base/debug/crash_logging.h"
17 #include "base/debug/dump_without_crashing.h" 17 #include "base/debug/dump_without_crashing.h"
18 #include "base/files/file.h" 18 #include "base/files/file.h"
19 #include "base/i18n/char_iterator.h" 19 #include "base/i18n/char_iterator.h"
20 #include "base/logging.h" 20 #include "base/logging.h"
21 #include "base/macros.h" 21 #include "base/macros.h"
22 #include "base/memory/ptr_util.h"
22 #include "base/memory/shared_memory.h" 23 #include "base/memory/shared_memory.h"
23 #include "base/memory/weak_ptr.h" 24 #include "base/memory/weak_ptr.h"
24 #include "base/metrics/field_trial.h" 25 #include "base/metrics/field_trial.h"
25 #include "base/metrics/histogram.h" 26 #include "base/metrics/histogram.h"
26 #include "base/process/process.h" 27 #include "base/process/process.h"
27 #include "base/stl_util.h" 28 #include "base/stl_util.h"
28 #include "base/strings/string16.h" 29 #include "base/strings/string16.h"
29 #include "base/strings/utf_string_conversions.h" 30 #include "base/strings/utf_string_conversions.h"
30 #include "base/thread_task_runner_handle.h" 31 #include "base/thread_task_runner_handle.h"
31 #include "base/time/time.h" 32 #include "base/time/time.h"
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 #endif // ADDRESS_SANITIZER || SYZYASAN 500 #endif // ADDRESS_SANITIZER || SYZYASAN
500 } 501 }
501 502
502 // Returns false unless this is a top-level navigation. 503 // Returns false unless this is a top-level navigation.
503 bool IsTopLevelNavigation(WebFrame* frame) { 504 bool IsTopLevelNavigation(WebFrame* frame) {
504 return frame->parent() == NULL; 505 return frame->parent() == NULL;
505 } 506 }
506 507
507 WebURLRequest CreateURLRequestForNavigation( 508 WebURLRequest CreateURLRequestForNavigation(
508 const CommonNavigationParams& common_params, 509 const CommonNavigationParams& common_params,
509 scoped_ptr<StreamOverrideParameters> stream_override, 510 std::unique_ptr<StreamOverrideParameters> stream_override,
510 bool is_view_source_mode_enabled) { 511 bool is_view_source_mode_enabled) {
511 WebURLRequest request(common_params.url); 512 WebURLRequest request(common_params.url);
512 if (is_view_source_mode_enabled) 513 if (is_view_source_mode_enabled)
513 request.setCachePolicy(WebCachePolicy::ReturnCacheDataElseLoad); 514 request.setCachePolicy(WebCachePolicy::ReturnCacheDataElseLoad);
514 515
515 if (common_params.referrer.url.is_valid()) { 516 if (common_params.referrer.url.is_valid()) {
516 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader( 517 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader(
517 common_params.referrer.policy, 518 common_params.referrer.policy,
518 common_params.url, 519 common_params.url,
519 WebString::fromUTF8(common_params.referrer.url.spec())); 520 WebString::fromUTF8(common_params.referrer.url.spec()));
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 } 1477 }
1477 1478
1478 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); 1479 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current();
1479 // Can be NULL in tests. 1480 // Can be NULL in tests.
1480 if (render_thread_impl) 1481 if (render_thread_impl)
1481 render_thread_impl->GetRendererScheduler()->OnNavigationStarted(); 1482 render_thread_impl->GetRendererScheduler()->OnNavigationStarted();
1482 DCHECK(!IsBrowserSideNavigationEnabled()); 1483 DCHECK(!IsBrowserSideNavigationEnabled());
1483 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_, 1484 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_,
1484 "url", common_params.url.possibly_invalid_spec()); 1485 "url", common_params.url.possibly_invalid_spec());
1485 NavigateInternal(common_params, start_params, request_params, 1486 NavigateInternal(common_params, start_params, request_params,
1486 scoped_ptr<StreamOverrideParameters>()); 1487 std::unique_ptr<StreamOverrideParameters>());
1487 } 1488 }
1488 1489
1489 void RenderFrameImpl::BindServiceRegistry( 1490 void RenderFrameImpl::BindServiceRegistry(
1490 mojo::shell::mojom::InterfaceProviderRequest services, 1491 mojo::shell::mojom::InterfaceProviderRequest services,
1491 mojo::shell::mojom::InterfaceProviderPtr exposed_services) { 1492 mojo::shell::mojom::InterfaceProviderPtr exposed_services) {
1492 service_registry_.Bind(std::move(services)); 1493 service_registry_.Bind(std::move(services));
1493 service_registry_.BindRemoteServiceProvider(std::move(exposed_services)); 1494 service_registry_.BindRemoteServiceProvider(std::move(exposed_services));
1494 } 1495 }
1495 1496
1496 ManifestManager* RenderFrameImpl::manifest_manager() { 1497 ManifestManager* RenderFrameImpl::manifest_manager() {
1497 return manifest_manager_; 1498 return manifest_manager_;
1498 } 1499 }
1499 1500
1500 void RenderFrameImpl::SetPendingNavigationParams( 1501 void RenderFrameImpl::SetPendingNavigationParams(
1501 scoped_ptr<NavigationParams> navigation_params) { 1502 std::unique_ptr<NavigationParams> navigation_params) {
1502 pending_navigation_params_ = std::move(navigation_params); 1503 pending_navigation_params_ = std::move(navigation_params);
1503 } 1504 }
1504 1505
1505 void RenderFrameImpl::OnBeforeUnload() { 1506 void RenderFrameImpl::OnBeforeUnload() {
1506 TRACE_EVENT1("navigation", "RenderFrameImpl::OnBeforeUnload", 1507 TRACE_EVENT1("navigation", "RenderFrameImpl::OnBeforeUnload",
1507 "id", routing_id_); 1508 "id", routing_id_);
1508 // TODO(creis): Right now, this is only called on the main frame. Make the 1509 // TODO(creis): Right now, this is only called on the main frame. Make the
1509 // browser process send dispatchBeforeUnloadEvent to every frame that needs 1510 // browser process send dispatchBeforeUnloadEvent to every frame that needs
1510 // it. 1511 // it.
1511 CHECK(!frame_->parent()); 1512 CHECK(!frame_->parent());
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 void RenderFrameImpl::OnJavaScriptExecuteRequestForTests( 1812 void RenderFrameImpl::OnJavaScriptExecuteRequestForTests(
1812 const base::string16& jscript, 1813 const base::string16& jscript,
1813 int id, 1814 int id,
1814 bool notify_result, 1815 bool notify_result,
1815 bool has_user_gesture) { 1816 bool has_user_gesture) {
1816 TRACE_EVENT_INSTANT0("test_tracing", "OnJavaScriptExecuteRequestForTests", 1817 TRACE_EVENT_INSTANT0("test_tracing", "OnJavaScriptExecuteRequestForTests",
1817 TRACE_EVENT_SCOPE_THREAD); 1818 TRACE_EVENT_SCOPE_THREAD);
1818 1819
1819 // A bunch of tests expect to run code in the context of a user gesture, which 1820 // A bunch of tests expect to run code in the context of a user gesture, which
1820 // can grant additional privileges (e.g. the ability to create popups). 1821 // can grant additional privileges (e.g. the ability to create popups).
1821 scoped_ptr<blink::WebScopedUserGesture> gesture( 1822 std::unique_ptr<blink::WebScopedUserGesture> gesture(
1822 has_user_gesture ? new blink::WebScopedUserGesture : nullptr); 1823 has_user_gesture ? new blink::WebScopedUserGesture : nullptr);
1823 v8::HandleScope handle_scope(blink::mainThreadIsolate()); 1824 v8::HandleScope handle_scope(blink::mainThreadIsolate());
1824 v8::Local<v8::Value> result = 1825 v8::Local<v8::Value> result =
1825 frame_->executeScriptAndReturnValue(WebScriptSource(jscript)); 1826 frame_->executeScriptAndReturnValue(WebScriptSource(jscript));
1826 1827
1827 HandleJavascriptExecutionResult(jscript, id, notify_result, result); 1828 HandleJavascriptExecutionResult(jscript, id, notify_result, result);
1828 } 1829 }
1829 1830
1830 void RenderFrameImpl::OnJavaScriptExecuteRequestInIsolatedWorld( 1831 void RenderFrameImpl::OnJavaScriptExecuteRequestInIsolatedWorld(
1831 const base::string16& jscript, 1832 const base::string16& jscript,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1880 // here. V8ValueConverterImpl shouldn't actually care about the 1881 // here. V8ValueConverterImpl shouldn't actually care about the
1881 // context scope, and it switches to v8::Object's creation context 1882 // context scope, and it switches to v8::Object's creation context
1882 // when encountered. (from extensions/renderer/script_injection.cc) 1883 // when encountered. (from extensions/renderer/script_injection.cc)
1883 v8::Local<v8::Context> context = 1884 v8::Local<v8::Context> context =
1884 render_frame_impl_.get()->frame_->mainWorldScriptContext(); 1885 render_frame_impl_.get()->frame_->mainWorldScriptContext();
1885 v8::Context::Scope context_scope(context); 1886 v8::Context::Scope context_scope(context);
1886 V8ValueConverterImpl converter; 1887 V8ValueConverterImpl converter;
1887 converter.SetDateAllowed(true); 1888 converter.SetDateAllowed(true);
1888 converter.SetRegExpAllowed(true); 1889 converter.SetRegExpAllowed(true);
1889 for (const auto& value : result) { 1890 for (const auto& value : result) {
1890 scoped_ptr<base::Value> result_value( 1891 std::unique_ptr<base::Value> result_value(
1891 converter.FromV8Value(value, context)); 1892 converter.FromV8Value(value, context));
1892 list.Append(result_value ? std::move(result_value) 1893 list.Append(result_value ? std::move(result_value)
1893 : base::Value::CreateNullValue()); 1894 : base::Value::CreateNullValue());
1894 } 1895 }
1895 } else { 1896 } else {
1896 list.Set(0, base::Value::CreateNullValue()); 1897 list.Set(0, base::Value::CreateNullValue());
1897 } 1898 }
1898 render_frame_impl_.get()->Send( 1899 render_frame_impl_.get()->Send(
1899 new FrameHostMsg_JavaScriptExecuteResponse(routing_id_, id_, list)); 1900 new FrameHostMsg_JavaScriptExecuteResponse(routing_id_, id_, list));
1900 } 1901 }
1901 1902
1902 delete this; 1903 delete this;
1903 } 1904 }
1904 1905
1905 void RenderFrameImpl::HandleJavascriptExecutionResult( 1906 void RenderFrameImpl::HandleJavascriptExecutionResult(
1906 const base::string16& jscript, 1907 const base::string16& jscript,
1907 int id, 1908 int id,
1908 bool notify_result, 1909 bool notify_result,
1909 v8::Local<v8::Value> result) { 1910 v8::Local<v8::Value> result) {
1910 if (notify_result) { 1911 if (notify_result) {
1911 base::ListValue list; 1912 base::ListValue list;
1912 if (!result.IsEmpty()) { 1913 if (!result.IsEmpty()) {
1913 v8::Local<v8::Context> context = frame_->mainWorldScriptContext(); 1914 v8::Local<v8::Context> context = frame_->mainWorldScriptContext();
1914 v8::Context::Scope context_scope(context); 1915 v8::Context::Scope context_scope(context);
1915 V8ValueConverterImpl converter; 1916 V8ValueConverterImpl converter;
1916 converter.SetDateAllowed(true); 1917 converter.SetDateAllowed(true);
1917 converter.SetRegExpAllowed(true); 1918 converter.SetRegExpAllowed(true);
1918 scoped_ptr<base::Value> result_value( 1919 std::unique_ptr<base::Value> result_value(
1919 converter.FromV8Value(result, context)); 1920 converter.FromV8Value(result, context));
1920 list.Set(0, result_value ? std::move(result_value) 1921 list.Set(0, result_value ? std::move(result_value)
1921 : base::Value::CreateNullValue()); 1922 : base::Value::CreateNullValue());
1922 } else { 1923 } else {
1923 list.Set(0, base::Value::CreateNullValue()); 1924 list.Set(0, base::Value::CreateNullValue());
1924 } 1925 }
1925 Send(new FrameHostMsg_JavaScriptExecuteResponse(routing_id_, id, list)); 1926 Send(new FrameHostMsg_JavaScriptExecuteResponse(routing_id_, id, list));
1926 } 1927 }
1927 } 1928 }
1928 1929
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
2067 base::ThreadTaskRunnerHandle::Get().get()); 2068 base::ThreadTaskRunnerHandle::Get().get());
2068 2069
2069 WebSerializedScriptValue serialized_script_value; 2070 WebSerializedScriptValue serialized_script_value;
2070 if (params.is_data_raw_string) { 2071 if (params.is_data_raw_string) {
2071 v8::HandleScope handle_scope(blink::mainThreadIsolate()); 2072 v8::HandleScope handle_scope(blink::mainThreadIsolate());
2072 v8::Local<v8::Context> context = frame_->mainWorldScriptContext(); 2073 v8::Local<v8::Context> context = frame_->mainWorldScriptContext();
2073 v8::Context::Scope context_scope(context); 2074 v8::Context::Scope context_scope(context);
2074 V8ValueConverterImpl converter; 2075 V8ValueConverterImpl converter;
2075 converter.SetDateAllowed(true); 2076 converter.SetDateAllowed(true);
2076 converter.SetRegExpAllowed(true); 2077 converter.SetRegExpAllowed(true);
2077 scoped_ptr<base::Value> value(new base::StringValue(params.data)); 2078 std::unique_ptr<base::Value> value(new base::StringValue(params.data));
2078 v8::Local<v8::Value> result_value = converter.ToV8Value(value.get(), 2079 v8::Local<v8::Value> result_value = converter.ToV8Value(value.get(),
2079 context); 2080 context);
2080 serialized_script_value = WebSerializedScriptValue::serialize(result_value); 2081 serialized_script_value = WebSerializedScriptValue::serialize(result_value);
2081 } else { 2082 } else {
2082 serialized_script_value = WebSerializedScriptValue::fromString(params.data); 2083 serialized_script_value = WebSerializedScriptValue::fromString(params.data);
2083 } 2084 }
2084 2085
2085 // We must pass in the target_origin to do the security check on this side, 2086 // We must pass in the target_origin to do the security check on this side,
2086 // since it may have changed since the original postMessage call was made. 2087 // since it may have changed since the original postMessage call was made.
2087 WebSecurityOrigin target_origin; 2088 WebSecurityOrigin target_origin;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
2233 } 2234 }
2234 2235
2235 blink::WebNode RenderFrameImpl::GetContextMenuNode() const { 2236 blink::WebNode RenderFrameImpl::GetContextMenuNode() const {
2236 return context_menu_node_; 2237 return context_menu_node_;
2237 } 2238 }
2238 2239
2239 blink::WebPlugin* RenderFrameImpl::CreatePlugin( 2240 blink::WebPlugin* RenderFrameImpl::CreatePlugin(
2240 blink::WebFrame* frame, 2241 blink::WebFrame* frame,
2241 const WebPluginInfo& info, 2242 const WebPluginInfo& info,
2242 const blink::WebPluginParams& params, 2243 const blink::WebPluginParams& params,
2243 scoped_ptr<content::PluginInstanceThrottler> throttler) { 2244 std::unique_ptr<content::PluginInstanceThrottler> throttler) {
2244 DCHECK_EQ(frame_, frame); 2245 DCHECK_EQ(frame_, frame);
2245 #if defined(ENABLE_PLUGINS) 2246 #if defined(ENABLE_PLUGINS)
2246 if (info.type == WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN) { 2247 if (info.type == WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN) {
2247 return BrowserPluginManager::Get()->CreateBrowserPlugin( 2248 return BrowserPluginManager::Get()->CreateBrowserPlugin(
2248 this, GetContentClient() 2249 this, GetContentClient()
2249 ->renderer() 2250 ->renderer()
2250 ->CreateBrowserPluginDelegate(this, params.mimeType.utf8(), 2251 ->CreateBrowserPluginDelegate(this, params.mimeType.utf8(),
2251 GURL(params.url)) 2252 GURL(params.url))
2252 ->GetWeakPtr()); 2253 ->GetWeakPtr());
2253 } 2254 }
2254 2255
2255 bool pepper_plugin_was_registered = false; 2256 bool pepper_plugin_was_registered = false;
2256 scoped_refptr<PluginModule> pepper_module(PluginModule::Create( 2257 scoped_refptr<PluginModule> pepper_module(PluginModule::Create(
2257 this, info, &pepper_plugin_was_registered)); 2258 this, info, &pepper_plugin_was_registered));
2258 if (pepper_plugin_was_registered) { 2259 if (pepper_plugin_was_registered) {
2259 if (pepper_module.get()) { 2260 if (pepper_module.get()) {
2260 return new PepperWebPluginImpl( 2261 return new PepperWebPluginImpl(
2261 pepper_module.get(), params, this, 2262 pepper_module.get(), params, this,
2262 make_scoped_ptr( 2263 base::WrapUnique(
2263 static_cast<PluginInstanceThrottlerImpl*>(throttler.release()))); 2264 static_cast<PluginInstanceThrottlerImpl*>(throttler.release())));
2264 } 2265 }
2265 } 2266 }
2266 #if defined(OS_CHROMEOS) 2267 #if defined(OS_CHROMEOS)
2267 LOG(WARNING) << "Pepper module/plugin creation failed."; 2268 LOG(WARNING) << "Pepper module/plugin creation failed.";
2268 #endif 2269 #endif
2269 #endif 2270 #endif
2270 return NULL; 2271 return NULL;
2271 } 2272 }
2272 2273
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
2456 initial_cdm, media_surface_manager_, media_session); 2457 initial_cdm, media_surface_manager_, media_session);
2457 2458
2458 #if defined(OS_ANDROID) 2459 #if defined(OS_ANDROID)
2459 if (GetContentClient()->renderer()->ShouldUseMediaPlayerForURL(url) || 2460 if (GetContentClient()->renderer()->ShouldUseMediaPlayerForURL(url) ||
2460 !UseWebMediaPlayerImpl(url)) { 2461 !UseWebMediaPlayerImpl(url)) {
2461 return CreateAndroidWebMediaPlayer(client, encrypted_client, params); 2462 return CreateAndroidWebMediaPlayer(client, encrypted_client, params);
2462 } 2463 }
2463 #endif // defined(OS_ANDROID) 2464 #endif // defined(OS_ANDROID)
2464 2465
2465 #if defined(ENABLE_MOJO_RENDERER) 2466 #if defined(ENABLE_MOJO_RENDERER)
2466 scoped_ptr<media::RendererFactory> media_renderer_factory( 2467 std::unique_ptr<media::RendererFactory> media_renderer_factory(
2467 new media::MojoRendererFactory(GetMediaInterfaceProvider())); 2468 new media::MojoRendererFactory(GetMediaInterfaceProvider()));
2468 #else 2469 #else
2469 scoped_ptr<media::RendererFactory> media_renderer_factory = 2470 std::unique_ptr<media::RendererFactory> media_renderer_factory =
2470 GetContentClient()->renderer()->CreateMediaRendererFactory( 2471 GetContentClient()->renderer()->CreateMediaRendererFactory(
2471 this, render_thread->GetGpuFactories(), media_log); 2472 this, render_thread->GetGpuFactories(), media_log);
2472 2473
2473 if (!media_renderer_factory.get()) { 2474 if (!media_renderer_factory.get()) {
2474 media_renderer_factory.reset(new media::DefaultRendererFactory( 2475 media_renderer_factory.reset(new media::DefaultRendererFactory(
2475 media_log, GetDecoderFactory(), 2476 media_log, GetDecoderFactory(),
2476 base::Bind(&RenderThreadImpl::GetGpuFactories, 2477 base::Bind(&RenderThreadImpl::GetGpuFactories,
2477 base::Unretained(render_thread)), 2478 base::Unretained(render_thread)),
2478 *render_thread->GetAudioHardwareConfig())); 2479 *render_thread->GetAudioHardwareConfig()));
2479 } 2480 }
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after
3724 request.setCachePolicy(internal_data->cache_policy_override()); 3725 request.setCachePolicy(internal_data->cache_policy_override());
3725 3726
3726 // The request's extra data may indicate that we should set a custom user 3727 // The request's extra data may indicate that we should set a custom user
3727 // agent. This needs to be done here, after WebKit is through with setting the 3728 // agent. This needs to be done here, after WebKit is through with setting the
3728 // user agent on its own. Similarly, it may indicate that we should set an 3729 // user agent on its own. Similarly, it may indicate that we should set an
3729 // X-Requested-With header. This must be done here to avoid breaking CORS 3730 // X-Requested-With header. This must be done here to avoid breaking CORS
3730 // checks. 3731 // checks.
3731 // PlzNavigate: there may also be a stream url associated with the request. 3732 // PlzNavigate: there may also be a stream url associated with the request.
3732 WebString custom_user_agent; 3733 WebString custom_user_agent;
3733 WebString requested_with; 3734 WebString requested_with;
3734 scoped_ptr<StreamOverrideParameters> stream_override; 3735 std::unique_ptr<StreamOverrideParameters> stream_override;
3735 if (request.getExtraData()) { 3736 if (request.getExtraData()) {
3736 RequestExtraData* old_extra_data = 3737 RequestExtraData* old_extra_data =
3737 static_cast<RequestExtraData*>(request.getExtraData()); 3738 static_cast<RequestExtraData*>(request.getExtraData());
3738 3739
3739 custom_user_agent = old_extra_data->custom_user_agent(); 3740 custom_user_agent = old_extra_data->custom_user_agent();
3740 if (!custom_user_agent.isNull()) { 3741 if (!custom_user_agent.isNull()) {
3741 if (custom_user_agent.isEmpty()) 3742 if (custom_user_agent.isEmpty())
3742 request.clearHTTPHeaderField("User-Agent"); 3743 request.clearHTTPHeaderField("User-Agent");
3743 else 3744 else
3744 request.setHTTPHeaderField("User-Agent", custom_user_agent); 3745 request.setHTTPHeaderField("User-Agent", custom_user_agent);
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
4607 4608
4608 // PlzNavigate 4609 // PlzNavigate
4609 void RenderFrameImpl::OnCommitNavigation( 4610 void RenderFrameImpl::OnCommitNavigation(
4610 const ResourceResponseHead& response, 4611 const ResourceResponseHead& response,
4611 const GURL& stream_url, 4612 const GURL& stream_url,
4612 const CommonNavigationParams& common_params, 4613 const CommonNavigationParams& common_params,
4613 const RequestNavigationParams& request_params) { 4614 const RequestNavigationParams& request_params) {
4614 CHECK(IsBrowserSideNavigationEnabled()); 4615 CHECK(IsBrowserSideNavigationEnabled());
4615 // This will override the url requested by the WebURLLoader, as well as 4616 // This will override the url requested by the WebURLLoader, as well as
4616 // provide it with the response to the request. 4617 // provide it with the response to the request.
4617 scoped_ptr<StreamOverrideParameters> stream_override( 4618 std::unique_ptr<StreamOverrideParameters> stream_override(
4618 new StreamOverrideParameters()); 4619 new StreamOverrideParameters());
4619 stream_override->stream_url = stream_url; 4620 stream_override->stream_url = stream_url;
4620 stream_override->response = response; 4621 stream_override->response = response;
4621 4622
4622 NavigateInternal(common_params, StartNavigationParams(), request_params, 4623 NavigateInternal(common_params, StartNavigationParams(), request_params,
4623 std::move(stream_override)); 4624 std::move(stream_override));
4624 } 4625 }
4625 4626
4626 // PlzNavigate 4627 // PlzNavigate
4627 void RenderFrameImpl::OnFailedNavigation( 4628 void RenderFrameImpl::OnFailedNavigation(
(...skipping 20 matching lines...) Expand all
4648 4649
4649 // Inform the browser of the start of the provisional load. This is needed so 4650 // Inform the browser of the start of the provisional load. This is needed so
4650 // that the load is properly tracked by the WebNavigation API. 4651 // that the load is properly tracked by the WebNavigation API.
4651 Send(new FrameHostMsg_DidStartProvisionalLoad( 4652 Send(new FrameHostMsg_DidStartProvisionalLoad(
4652 routing_id_, common_params.url, common_params.navigation_start)); 4653 routing_id_, common_params.url, common_params.navigation_start));
4653 4654
4654 // Send the provisional load failure. 4655 // Send the provisional load failure.
4655 blink::WebURLError error = 4656 blink::WebURLError error =
4656 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); 4657 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code);
4657 WebURLRequest failed_request = CreateURLRequestForNavigation( 4658 WebURLRequest failed_request = CreateURLRequestForNavigation(
4658 common_params, scoped_ptr<StreamOverrideParameters>(), 4659 common_params, std::unique_ptr<StreamOverrideParameters>(),
4659 frame_->isViewSourceModeEnabled()); 4660 frame_->isViewSourceModeEnabled());
4660 SendFailedProvisionalLoad(failed_request, error, frame_); 4661 SendFailedProvisionalLoad(failed_request, error, frame_);
4661 4662
4662 // This check should have been done on the browser side already. 4663 // This check should have been done on the browser side already.
4663 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { 4664 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) {
4664 NOTREACHED(); 4665 NOTREACHED();
4665 return; 4666 return;
4666 } 4667 }
4667 4668
4668 // Make sure errors are not shown in view source mode. 4669 // Make sure errors are not shown in view source mode.
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
5209 params.frame_unique_name = frame_->uniqueName().utf8(); 5210 params.frame_unique_name = frame_->uniqueName().utf8();
5210 } 5211 }
5211 5212
5212 Send(new FrameHostMsg_OpenURL(routing_id_, params)); 5213 Send(new FrameHostMsg_OpenURL(routing_id_, params));
5213 } 5214 }
5214 5215
5215 void RenderFrameImpl::NavigateInternal( 5216 void RenderFrameImpl::NavigateInternal(
5216 const CommonNavigationParams& common_params, 5217 const CommonNavigationParams& common_params,
5217 const StartNavigationParams& start_params, 5218 const StartNavigationParams& start_params,
5218 const RequestNavigationParams& request_params, 5219 const RequestNavigationParams& request_params,
5219 scoped_ptr<StreamOverrideParameters> stream_params) { 5220 std::unique_ptr<StreamOverrideParameters> stream_params) {
5220 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); 5221 bool browser_side_navigation = IsBrowserSideNavigationEnabled();
5221 5222
5222 // Lower bound for browser initiated navigation start time. 5223 // Lower bound for browser initiated navigation start time.
5223 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); 5224 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now();
5224 bool is_reload = IsReload(common_params.navigation_type); 5225 bool is_reload = IsReload(common_params.navigation_type);
5225 bool is_history_navigation = request_params.page_state.IsValid(); 5226 bool is_history_navigation = request_params.page_state.IsValid();
5226 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy; 5227 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy;
5227 RenderFrameImpl::PrepareRenderViewForNavigation( 5228 RenderFrameImpl::PrepareRenderViewForNavigation(
5228 common_params.url, request_params); 5229 common_params.url, request_params);
5229 5230
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
5309 request = frame_->requestForReload(load_type, override_url); 5310 request = frame_->requestForReload(load_type, override_url);
5310 } 5311 }
5311 should_load_request = true; 5312 should_load_request = true;
5312 } else if (is_history_navigation) { 5313 } else if (is_history_navigation) {
5313 // We must know the page ID of the page we are navigating back to. 5314 // We must know the page ID of the page we are navigating back to.
5314 DCHECK_NE(request_params.page_id, -1); 5315 DCHECK_NE(request_params.page_id, -1);
5315 // We must know the nav entry ID of the page we are navigating back to, 5316 // We must know the nav entry ID of the page we are navigating back to,
5316 // which should be the case because history navigations are routed via the 5317 // which should be the case because history navigations are routed via the
5317 // browser. 5318 // browser.
5318 DCHECK_NE(0, request_params.nav_entry_id); 5319 DCHECK_NE(0, request_params.nav_entry_id);
5319 scoped_ptr<HistoryEntry> entry = 5320 std::unique_ptr<HistoryEntry> entry =
5320 PageStateToHistoryEntry(request_params.page_state); 5321 PageStateToHistoryEntry(request_params.page_state);
5321 if (entry) { 5322 if (entry) {
5322 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { 5323 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) {
5323 // By default, tell the HistoryController to go the deserialized 5324 // By default, tell the HistoryController to go the deserialized
5324 // HistoryEntry. This only works if all frames are in the same 5325 // HistoryEntry. This only works if all frames are in the same
5325 // process. 5326 // process.
5326 DCHECK(!frame_->parent()); 5327 DCHECK(!frame_->parent());
5327 DCHECK(!browser_side_navigation); 5328 DCHECK(!browser_side_navigation);
5328 scoped_ptr<NavigationParams> navigation_params( 5329 std::unique_ptr<NavigationParams> navigation_params(
5329 new NavigationParams(*pending_navigation_params_.get())); 5330 new NavigationParams(*pending_navigation_params_.get()));
5330 has_history_navigation_in_frame = 5331 has_history_navigation_in_frame =
5331 render_view_->history_controller()->GoToEntry( 5332 render_view_->history_controller()->GoToEntry(
5332 frame_, std::move(entry), std::move(navigation_params), 5333 frame_, std::move(entry), std::move(navigation_params),
5333 cache_policy); 5334 cache_policy);
5334 } else { 5335 } else {
5335 // In --site-per-process, the browser process sends a single 5336 // In --site-per-process, the browser process sends a single
5336 // WebHistoryItem destined for this frame. 5337 // WebHistoryItem destined for this frame.
5337 // TODO(creis): Change PageState to FrameState. In the meantime, we 5338 // TODO(creis): Change PageState to FrameState. In the meantime, we
5338 // store the relevant frame's WebHistoryItem in the root of the 5339 // store the relevant frame's WebHistoryItem in the root of the
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
5509 } 5510 }
5510 5511
5511 void RenderFrameImpl::InitializeUserMediaClient() { 5512 void RenderFrameImpl::InitializeUserMediaClient() {
5512 if (!RenderThreadImpl::current()) // Will be NULL during unit tests. 5513 if (!RenderThreadImpl::current()) // Will be NULL during unit tests.
5513 return; 5514 return;
5514 5515
5515 #if defined(ENABLE_WEBRTC) 5516 #if defined(ENABLE_WEBRTC)
5516 DCHECK(!web_user_media_client_); 5517 DCHECK(!web_user_media_client_);
5517 web_user_media_client_ = new UserMediaClientImpl( 5518 web_user_media_client_ = new UserMediaClientImpl(
5518 this, RenderThreadImpl::current()->GetPeerConnectionDependencyFactory(), 5519 this, RenderThreadImpl::current()->GetPeerConnectionDependencyFactory(),
5519 make_scoped_ptr(new MediaStreamDispatcher(this))); 5520 base::WrapUnique(new MediaStreamDispatcher(this)));
5520 #endif 5521 #endif
5521 } 5522 }
5522 5523
5523 WebMediaPlayer* RenderFrameImpl::CreateWebMediaPlayerForMediaStream( 5524 WebMediaPlayer* RenderFrameImpl::CreateWebMediaPlayerForMediaStream(
5524 WebMediaPlayerClient* client, 5525 WebMediaPlayerClient* client,
5525 const WebString& sink_id, 5526 const WebString& sink_id,
5526 const WebSecurityOrigin& security_origin) { 5527 const WebSecurityOrigin& security_origin) {
5527 #if defined(ENABLE_WEBRTC) 5528 #if defined(ENABLE_WEBRTC)
5528 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) 5529 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL)
5529 const bool found_neon = 5530 const bool found_neon =
(...skipping 11 matching lines...) Expand all
5541 frame_, client, GetWebMediaPlayerDelegate()->AsWeakPtr(), 5542 frame_, client, GetWebMediaPlayerDelegate()->AsWeakPtr(),
5542 new RenderMediaLog(), CreateRendererFactory(), compositor_task_runner, 5543 new RenderMediaLog(), CreateRendererFactory(), compositor_task_runner,
5543 render_thread->GetMediaThreadTaskRunner(), 5544 render_thread->GetMediaThreadTaskRunner(),
5544 render_thread->GetWorkerTaskRunner(), render_thread->GetGpuFactories(), 5545 render_thread->GetWorkerTaskRunner(), render_thread->GetGpuFactories(),
5545 sink_id, security_origin); 5546 sink_id, security_origin);
5546 #else 5547 #else
5547 return NULL; 5548 return NULL;
5548 #endif // defined(ENABLE_WEBRTC) 5549 #endif // defined(ENABLE_WEBRTC)
5549 } 5550 }
5550 5551
5551 scoped_ptr<MediaStreamRendererFactory> 5552 std::unique_ptr<MediaStreamRendererFactory>
5552 RenderFrameImpl::CreateRendererFactory() { 5553 RenderFrameImpl::CreateRendererFactory() {
5553 scoped_ptr<MediaStreamRendererFactory> factory = 5554 std::unique_ptr<MediaStreamRendererFactory> factory =
5554 GetContentClient()->renderer()->CreateMediaStreamRendererFactory(); 5555 GetContentClient()->renderer()->CreateMediaStreamRendererFactory();
5555 if (factory.get()) 5556 if (factory.get())
5556 return factory; 5557 return factory;
5557 #if defined(ENABLE_WEBRTC) 5558 #if defined(ENABLE_WEBRTC)
5558 return scoped_ptr<MediaStreamRendererFactory>( 5559 return std::unique_ptr<MediaStreamRendererFactory>(
5559 new MediaStreamRendererFactoryImpl()); 5560 new MediaStreamRendererFactoryImpl());
5560 #else 5561 #else
5561 return scoped_ptr<MediaStreamRendererFactory>( 5562 return std::unique_ptr<MediaStreamRendererFactory>(
5562 static_cast<MediaStreamRendererFactory*>(NULL)); 5563 static_cast<MediaStreamRendererFactory*>(NULL));
5563 #endif 5564 #endif
5564 } 5565 }
5565 5566
5566 void RenderFrameImpl::PrepareRenderViewForNavigation( 5567 void RenderFrameImpl::PrepareRenderViewForNavigation(
5567 const GURL& url, 5568 const GURL& url,
5568 const RequestNavigationParams& request_params) { 5569 const RequestNavigationParams& request_params) {
5569 DCHECK(render_view_->webview()); 5570 DCHECK(render_view_->webview());
5570 5571
5571 MaybeHandleDebugURL(url); 5572 MaybeHandleDebugURL(url);
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
6024 int match_count, 6025 int match_count,
6025 int ordinal, 6026 int ordinal,
6026 const WebRect& selection_rect, 6027 const WebRect& selection_rect,
6027 bool final_status_update) { 6028 bool final_status_update) {
6028 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, 6029 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count,
6029 selection_rect, ordinal, 6030 selection_rect, ordinal,
6030 final_status_update)); 6031 final_status_update));
6031 } 6032 }
6032 6033
6033 } // namespace content 6034 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_frame_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698