OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 #include <utility> | 10 #include <utility> |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 #include "content/public/common/url_utils.h" | 122 #include "content/public/common/url_utils.h" |
123 #include "content/public/common/web_preferences.h" | 123 #include "content/public/common/web_preferences.h" |
124 #include "device/geolocation/geolocation_service_context.h" | 124 #include "device/geolocation/geolocation_service_context.h" |
125 #include "device/nfc/nfc.mojom.h" | 125 #include "device/nfc/nfc.mojom.h" |
126 #include "device/wake_lock/wake_lock_service_context.h" | 126 #include "device/wake_lock/wake_lock_service_context.h" |
127 #include "net/base/url_util.h" | 127 #include "net/base/url_util.h" |
128 #include "net/http/http_cache.h" | 128 #include "net/http/http_cache.h" |
129 #include "net/http/http_transaction_factory.h" | 129 #include "net/http/http_transaction_factory.h" |
130 #include "net/url_request/url_request_context.h" | 130 #include "net/url_request/url_request_context.h" |
131 #include "net/url_request/url_request_context_getter.h" | 131 #include "net/url_request/url_request_context_getter.h" |
| 132 #include "ppapi/features/features.h" |
132 #include "services/service_manager/public/cpp/interface_provider.h" | 133 #include "services/service_manager/public/cpp/interface_provider.h" |
133 #include "third_party/WebKit/public/platform/WebSecurityStyle.h" | 134 #include "third_party/WebKit/public/platform/WebSecurityStyle.h" |
134 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 135 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
135 #include "third_party/skia/include/core/SkBitmap.h" | 136 #include "third_party/skia/include/core/SkBitmap.h" |
136 #include "ui/accessibility/ax_tree_combiner.h" | 137 #include "ui/accessibility/ax_tree_combiner.h" |
137 #include "ui/base/layout.h" | 138 #include "ui/base/layout.h" |
138 #include "ui/events/blink/web_input_event_traits.h" | 139 #include "ui/events/blink/web_input_event_traits.h" |
139 #include "ui/gl/gl_switches.h" | 140 #include "ui/gl/gl_switches.h" |
140 | 141 |
141 #if defined(OS_ANDROID) | 142 #if defined(OS_ANDROID) |
142 #include "content/browser/android/content_video_view.h" | 143 #include "content/browser/android/content_video_view.h" |
143 #include "content/browser/android/date_time_chooser_android.h" | 144 #include "content/browser/android/date_time_chooser_android.h" |
144 #include "content/browser/android/java_interfaces_impl.h" | 145 #include "content/browser/android/java_interfaces_impl.h" |
145 #include "content/browser/media/android/media_web_contents_observer_android.h" | 146 #include "content/browser/media/android/media_web_contents_observer_android.h" |
146 #include "content/browser/web_contents/web_contents_android.h" | 147 #include "content/browser/web_contents/web_contents_android.h" |
147 #endif // OS_ANDROID | 148 #endif // OS_ANDROID |
148 | 149 |
149 #if defined(OS_MACOSX) | 150 #if defined(OS_MACOSX) |
150 #include "base/mac/foundation_util.h" | 151 #include "base/mac/foundation_util.h" |
151 #endif | 152 #endif |
152 | 153 |
153 #if defined(USE_AURA) | 154 #if defined(USE_AURA) |
154 #include "content/browser/web_contents/web_contents_view_mus.h" | 155 #include "content/browser/web_contents/web_contents_view_mus.h" |
155 #include "content/public/common/service_manager_connection.h" | 156 #include "content/public/common/service_manager_connection.h" |
156 #include "ui/aura/mus/mus_util.h" | 157 #include "ui/aura/mus/mus_util.h" |
157 #endif | 158 #endif |
158 | 159 |
159 #if defined(ENABLE_PLUGINS) | 160 #if BUILDFLAG(ENABLE_PLUGINS) |
160 #include "content/browser/media/session/pepper_playback_observer.h" | 161 #include "content/browser/media/session/pepper_playback_observer.h" |
161 #endif // ENABLE_PLUGINS | 162 #endif // ENABLE_PLUGINS |
162 | 163 |
163 namespace content { | 164 namespace content { |
164 namespace { | 165 namespace { |
165 | 166 |
166 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; | 167 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; |
167 const char kDotGoogleDotCom[] = ".google.com"; | 168 const char kDotGoogleDotCom[] = ".google.com"; |
168 | 169 |
169 #if defined(OS_ANDROID) | 170 #if defined(OS_ANDROID) |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 loading_weak_factory_(this), | 458 loading_weak_factory_(this), |
458 weak_factory_(this) { | 459 weak_factory_(this) { |
459 frame_tree_.SetFrameRemoveListener( | 460 frame_tree_.SetFrameRemoveListener( |
460 base::Bind(&WebContentsImpl::OnFrameRemoved, | 461 base::Bind(&WebContentsImpl::OnFrameRemoved, |
461 base::Unretained(this))); | 462 base::Unretained(this))); |
462 #if defined(OS_ANDROID) | 463 #if defined(OS_ANDROID) |
463 media_web_contents_observer_.reset(new MediaWebContentsObserverAndroid(this)); | 464 media_web_contents_observer_.reset(new MediaWebContentsObserverAndroid(this)); |
464 #else | 465 #else |
465 media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); | 466 media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); |
466 #endif | 467 #endif |
467 #if defined (ENABLE_PLUGINS) | 468 #if BUILDFLAG(ENABLE_PLUGINS) |
468 pepper_playback_observer_.reset(new PepperPlaybackObserver(this)); | 469 pepper_playback_observer_.reset(new PepperPlaybackObserver(this)); |
469 #endif | 470 #endif |
470 loader_io_thread_notifier_.reset(new LoaderIOThreadNotifier(this)); | 471 loader_io_thread_notifier_.reset(new LoaderIOThreadNotifier(this)); |
471 wake_lock_service_context_.reset(new device::WakeLockServiceContext( | 472 wake_lock_service_context_.reset(new device::WakeLockServiceContext( |
472 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), | 473 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), |
473 base::Bind(&WebContentsImpl::GetNativeView, base::Unretained(this)))); | 474 base::Bind(&WebContentsImpl::GetNativeView, base::Unretained(this)))); |
474 host_zoom_map_observer_.reset(new HostZoomMapObserver(this)); | 475 host_zoom_map_observer_.reset(new HostZoomMapObserver(this)); |
475 } | 476 } |
476 | 477 |
477 WebContentsImpl::~WebContentsImpl() { | 478 WebContentsImpl::~WebContentsImpl() { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 if (IsBrowserSideNavigationEnabled()) { | 543 if (IsBrowserSideNavigationEnabled()) { |
543 // Do not update state as the WebContents is being destroyed. | 544 // Do not update state as the WebContents is being destroyed. |
544 frame_tree_.root()->ResetNavigationRequest(true); | 545 frame_tree_.root()->ResetNavigationRequest(true); |
545 if (root->speculative_frame_host()) { | 546 if (root->speculative_frame_host()) { |
546 root->speculative_frame_host()->SetRenderFrameCreated(false); | 547 root->speculative_frame_host()->SetRenderFrameCreated(false); |
547 root->speculative_frame_host()->SetNavigationHandle( | 548 root->speculative_frame_host()->SetNavigationHandle( |
548 std::unique_ptr<NavigationHandleImpl>()); | 549 std::unique_ptr<NavigationHandleImpl>()); |
549 } | 550 } |
550 } | 551 } |
551 | 552 |
552 #if defined(ENABLE_PLUGINS) | 553 #if BUILDFLAG(ENABLE_PLUGINS) |
553 // Call this before WebContentsDestroyed() is broadcasted since | 554 // Call this before WebContentsDestroyed() is broadcasted since |
554 // AudioFocusManager will be destroyed after that. | 555 // AudioFocusManager will be destroyed after that. |
555 pepper_playback_observer_.reset(); | 556 pepper_playback_observer_.reset(); |
556 #endif // defined(ENABLED_PLUGINS) | 557 #endif // defined(ENABLED_PLUGINS) |
557 | 558 |
558 for (auto& observer : observers_) | 559 for (auto& observer : observers_) |
559 observer.FrameDeleted(root->current_frame_host()); | 560 observer.FrameDeleted(root->current_frame_host()); |
560 | 561 |
561 if (root->pending_render_view_host()) { | 562 if (root->pending_render_view_host()) { |
562 for (auto& observer : observers_) | 563 for (auto& observer : observers_) |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) | 731 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) |
731 IPC_MESSAGE_HANDLER(FrameHostMsg_RegisterProtocolHandler, | 732 IPC_MESSAGE_HANDLER(FrameHostMsg_RegisterProtocolHandler, |
732 OnRegisterProtocolHandler) | 733 OnRegisterProtocolHandler) |
733 IPC_MESSAGE_HANDLER(FrameHostMsg_UnregisterProtocolHandler, | 734 IPC_MESSAGE_HANDLER(FrameHostMsg_UnregisterProtocolHandler, |
734 OnUnregisterProtocolHandler) | 735 OnUnregisterProtocolHandler) |
735 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdatePageImportanceSignals, | 736 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdatePageImportanceSignals, |
736 OnUpdatePageImportanceSignals) | 737 OnUpdatePageImportanceSignals) |
737 IPC_MESSAGE_HANDLER(FrameHostMsg_Find_Reply, OnFindReply) | 738 IPC_MESSAGE_HANDLER(FrameHostMsg_Find_Reply, OnFindReply) |
738 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) | 739 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) |
739 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) | 740 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) |
740 #if defined(ENABLE_PLUGINS) | 741 #if BUILDFLAG(ENABLE_PLUGINS) |
741 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceCreated, | 742 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceCreated, |
742 OnPepperInstanceCreated) | 743 OnPepperInstanceCreated) |
743 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceDeleted, | 744 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperInstanceDeleted, |
744 OnPepperInstanceDeleted) | 745 OnPepperInstanceDeleted) |
745 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) | 746 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) |
746 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperStartsPlayback, | 747 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperStartsPlayback, |
747 OnPepperStartsPlayback) | 748 OnPepperStartsPlayback) |
748 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperStopsPlayback, | 749 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperStopsPlayback, |
749 OnPepperStopsPlayback) | 750 OnPepperStopsPlayback) |
750 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) | 751 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1601 view_.reset(new WebContentsViewGuest(this, browser_plugin_guest_.get(), | 1602 view_.reset(new WebContentsViewGuest(this, browser_plugin_guest_.get(), |
1602 std::move(view_), | 1603 std::move(view_), |
1603 &render_view_host_delegate_view_)); | 1604 &render_view_host_delegate_view_)); |
1604 } | 1605 } |
1605 CHECK(render_view_host_delegate_view_); | 1606 CHECK(render_view_host_delegate_view_); |
1606 CHECK(view_.get()); | 1607 CHECK(view_.get()); |
1607 | 1608 |
1608 gfx::Size initial_size = params.initial_size; | 1609 gfx::Size initial_size = params.initial_size; |
1609 view_->CreateView(initial_size, params.context); | 1610 view_->CreateView(initial_size, params.context); |
1610 | 1611 |
1611 #if defined(ENABLE_PLUGINS) | 1612 #if BUILDFLAG(ENABLE_PLUGINS) |
1612 plugin_content_origin_whitelist_.reset( | 1613 plugin_content_origin_whitelist_.reset( |
1613 new PluginContentOriginWhitelist(this)); | 1614 new PluginContentOriginWhitelist(this)); |
1614 #endif | 1615 #endif |
1615 | 1616 |
1616 registrar_.Add(this, | 1617 registrar_.Add(this, |
1617 NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | 1618 NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
1618 NotificationService::AllBrowserContextsAndSources()); | 1619 NotificationService::AllBrowserContextsAndSources()); |
1619 | 1620 |
1620 screen_orientation_dispatcher_host_.reset( | 1621 screen_orientation_dispatcher_host_.reset( |
1621 new ScreenOrientationDispatcherHostImpl(this)); | 1622 new ScreenOrientationDispatcherHostImpl(this)); |
(...skipping 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3746 | 3747 |
3747 // This exists for render views that don't have a WebUI, but do have WebUI | 3748 // This exists for render views that don't have a WebUI, but do have WebUI |
3748 // bindings enabled. | 3749 // bindings enabled. |
3749 void WebContentsImpl::OnWebUISend(const GURL& source_url, | 3750 void WebContentsImpl::OnWebUISend(const GURL& source_url, |
3750 const std::string& name, | 3751 const std::string& name, |
3751 const base::ListValue& args) { | 3752 const base::ListValue& args) { |
3752 if (delegate_) | 3753 if (delegate_) |
3753 delegate_->WebUISend(this, source_url, name, args); | 3754 delegate_->WebUISend(this, source_url, name, args); |
3754 } | 3755 } |
3755 | 3756 |
3756 #if defined(ENABLE_PLUGINS) | 3757 #if BUILDFLAG(ENABLE_PLUGINS) |
3757 void WebContentsImpl::OnPepperInstanceCreated(int32_t pp_instance) { | 3758 void WebContentsImpl::OnPepperInstanceCreated(int32_t pp_instance) { |
3758 for (auto& observer : observers_) | 3759 for (auto& observer : observers_) |
3759 observer.PepperInstanceCreated(); | 3760 observer.PepperInstanceCreated(); |
3760 pepper_playback_observer_->PepperInstanceCreated(pp_instance); | 3761 pepper_playback_observer_->PepperInstanceCreated(pp_instance); |
3761 } | 3762 } |
3762 | 3763 |
3763 void WebContentsImpl::OnPepperInstanceDeleted(int32_t pp_instance) { | 3764 void WebContentsImpl::OnPepperInstanceDeleted(int32_t pp_instance) { |
3764 for (auto& observer : observers_) | 3765 for (auto& observer : observers_) |
3765 observer.PepperInstanceDeleted(); | 3766 observer.PepperInstanceDeleted(); |
3766 pepper_playback_observer_->PepperInstanceDeleted(pp_instance); | 3767 pepper_playback_observer_->PepperInstanceDeleted(pp_instance); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3811 bool result) { | 3812 bool result) { |
3812 Send(new ViewMsg_PpapiBrokerPermissionResult(routing_id, result)); | 3813 Send(new ViewMsg_PpapiBrokerPermissionResult(routing_id, result)); |
3813 } | 3814 } |
3814 | 3815 |
3815 void WebContentsImpl::OnBrowserPluginMessage(RenderFrameHost* render_frame_host, | 3816 void WebContentsImpl::OnBrowserPluginMessage(RenderFrameHost* render_frame_host, |
3816 const IPC::Message& message) { | 3817 const IPC::Message& message) { |
3817 CHECK(!browser_plugin_embedder_.get()); | 3818 CHECK(!browser_plugin_embedder_.get()); |
3818 CreateBrowserPluginEmbedderIfNecessary(); | 3819 CreateBrowserPluginEmbedderIfNecessary(); |
3819 browser_plugin_embedder_->OnMessageReceived(message, render_frame_host); | 3820 browser_plugin_embedder_->OnMessageReceived(message, render_frame_host); |
3820 } | 3821 } |
3821 #endif // defined(ENABLE_PLUGINS) | 3822 #endif // BUILDFLAG(ENABLE_PLUGINS) |
3822 | 3823 |
3823 void WebContentsImpl::OnUpdateFaviconURL( | 3824 void WebContentsImpl::OnUpdateFaviconURL( |
3824 const std::vector<FaviconURL>& candidates) { | 3825 const std::vector<FaviconURL>& candidates) { |
3825 // We get updated favicon URLs after the page stops loading. If a cross-site | 3826 // We get updated favicon URLs after the page stops loading. If a cross-site |
3826 // navigation occurs while a page is still loading, the initial page | 3827 // navigation occurs while a page is still loading, the initial page |
3827 // may stop loading and send us updated favicon URLs after the navigation | 3828 // may stop loading and send us updated favicon URLs after the navigation |
3828 // for the new page has committed. | 3829 // for the new page has committed. |
3829 RenderViewHostImpl* rvhi = | 3830 RenderViewHostImpl* rvhi = |
3830 static_cast<RenderViewHostImpl*>(render_view_message_source_); | 3831 static_cast<RenderViewHostImpl*>(render_view_message_source_); |
3831 if (!rvhi->is_active()) | 3832 if (!rvhi->is_active()) |
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5277 dialog_manager_ = dialog_manager; | 5278 dialog_manager_ = dialog_manager; |
5278 } | 5279 } |
5279 | 5280 |
5280 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { | 5281 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { |
5281 auto it = binding_sets_.find(interface_name); | 5282 auto it = binding_sets_.find(interface_name); |
5282 if (it != binding_sets_.end()) | 5283 if (it != binding_sets_.end()) |
5283 binding_sets_.erase(it); | 5284 binding_sets_.erase(it); |
5284 } | 5285 } |
5285 | 5286 |
5286 } // namespace content | 5287 } // namespace content |
OLD | NEW |