Chromium Code Reviews| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 486 // stored in render_(view|frame)_message_source_. | 486 // stored in render_(view|frame)_message_source_. |
| 487 if (render_frame_host) | 487 if (render_frame_host) |
| 488 render_frame_message_source_ = render_frame_host; | 488 render_frame_message_source_ = render_frame_host; |
| 489 else | 489 else |
| 490 render_view_message_source_ = render_view_host; | 490 render_view_message_source_ = render_view_host; |
| 491 | 491 |
| 492 bool handled = true; | 492 bool handled = true; |
| 493 IPC_BEGIN_MESSAGE_MAP(WebContentsImpl, message) | 493 IPC_BEGIN_MESSAGE_MAP(WebContentsImpl, message) |
| 494 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) | 494 IPC_MESSAGE_HANDLER(FrameHostMsg_PepperPluginHung, OnPepperPluginHung) |
| 495 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) | 495 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginCrashed, OnPluginCrashed) |
| 496 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginContentOriginAllowed, | |
| 497 OnPluginContentOriginAllowed) | |
| 496 IPC_MESSAGE_HANDLER(FrameHostMsg_DomOperationResponse, | 498 IPC_MESSAGE_HANDLER(FrameHostMsg_DomOperationResponse, |
| 497 OnDomOperationResponse) | 499 OnDomOperationResponse) |
| 498 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeThemeColor, | 500 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeThemeColor, |
| 499 OnThemeColorChanged) | 501 OnThemeColorChanged) |
| 500 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishDocumentLoad, | 502 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishDocumentLoad, |
| 501 OnDocumentLoadedInFrame) | 503 OnDocumentLoadedInFrame) |
| 502 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishLoad, OnDidFinishLoad) | 504 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFinishLoad, OnDidFinishLoad) |
| 503 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartLoading, OnDidStartLoading) | 505 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartLoading, OnDidStartLoading) |
| 504 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStopLoading, OnDidStopLoading) | 506 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStopLoading, OnDidStopLoading) |
| 505 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeLoadProgress, | 507 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeLoadProgress, |
| (...skipping 2386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2892 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2894 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2893 PluginHungStatusChanged(plugin_child_id, path, is_hung)); | 2895 PluginHungStatusChanged(plugin_child_id, path, is_hung)); |
| 2894 } | 2896 } |
| 2895 | 2897 |
| 2896 void WebContentsImpl::OnPluginCrashed(const base::FilePath& plugin_path, | 2898 void WebContentsImpl::OnPluginCrashed(const base::FilePath& plugin_path, |
| 2897 base::ProcessId plugin_pid) { | 2899 base::ProcessId plugin_pid) { |
| 2898 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2900 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2899 PluginCrashed(plugin_path, plugin_pid)); | 2901 PluginCrashed(plugin_path, plugin_pid)); |
| 2900 } | 2902 } |
| 2901 | 2903 |
| 2904 void WebContentsImpl::OnPluginContentOriginAllowed(const GURL& content_origin) { | |
| 2905 DCHECK(render_frame_message_source_); | |
| 2906 DCHECK(!render_view_message_source_); | |
| 2907 | |
| 2908 plugin_content_origin_whitelist_[render_frame_message_source_].insert( | |
| 2909 content_origin); | |
| 2910 | |
| 2911 SendToAllFrames(new FrameMsg_UpdatePluginContentOriginWhitelist( | |
| 2912 MSG_ROUTING_NONE, GetPluginContentOriginWhitelist())); | |
| 2913 } | |
| 2914 | |
| 2902 void WebContentsImpl::OnDomOperationResponse(const std::string& json_string, | 2915 void WebContentsImpl::OnDomOperationResponse(const std::string& json_string, |
| 2903 int automation_id) { | 2916 int automation_id) { |
| 2904 DomOperationNotificationDetails details(json_string, automation_id); | 2917 DomOperationNotificationDetails details(json_string, automation_id); |
| 2905 NotificationService::current()->Notify( | 2918 NotificationService::current()->Notify( |
| 2906 NOTIFICATION_DOM_OPERATION_RESPONSE, | 2919 NOTIFICATION_DOM_OPERATION_RESPONSE, |
| 2907 Source<WebContents>(this), | 2920 Source<WebContents>(this), |
| 2908 Details<DomOperationNotificationDetails>(&details)); | 2921 Details<DomOperationNotificationDetails>(&details)); |
| 2909 } | 2922 } |
| 2910 | 2923 |
| 2911 void WebContentsImpl::OnAppCacheAccessed(const GURL& manifest_url, | 2924 void WebContentsImpl::OnAppCacheAccessed(const GURL& manifest_url, |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3325 return GetLastCommittedURL(); | 3338 return GetLastCommittedURL(); |
| 3326 } | 3339 } |
| 3327 | 3340 |
| 3328 void WebContentsImpl::RenderFrameCreated(RenderFrameHost* render_frame_host) { | 3341 void WebContentsImpl::RenderFrameCreated(RenderFrameHost* render_frame_host) { |
| 3329 // Note this is only for subframes, the notification for the main frame | 3342 // Note this is only for subframes, the notification for the main frame |
| 3330 // happens in RenderViewCreated. | 3343 // happens in RenderViewCreated. |
| 3331 FOR_EACH_OBSERVER(WebContentsObserver, | 3344 FOR_EACH_OBSERVER(WebContentsObserver, |
| 3332 observers_, | 3345 observers_, |
| 3333 RenderFrameCreated(render_frame_host)); | 3346 RenderFrameCreated(render_frame_host)); |
| 3334 SetAccessibilityModeOnFrame(accessibility_mode_, render_frame_host); | 3347 SetAccessibilityModeOnFrame(accessibility_mode_, render_frame_host); |
| 3348 | |
| 3349 if (!plugin_content_origin_whitelist_.empty()) { | |
| 3350 Send(new FrameMsg_UpdatePluginContentOriginWhitelist( | |
| 3351 render_frame_host->GetRoutingID(), GetPluginContentOriginWhitelist())); | |
| 3352 } | |
| 3335 } | 3353 } |
| 3336 | 3354 |
| 3337 void WebContentsImpl::RenderFrameDeleted(RenderFrameHost* render_frame_host) { | 3355 void WebContentsImpl::RenderFrameDeleted(RenderFrameHost* render_frame_host) { |
| 3338 ClearPowerSaveBlockers(render_frame_host); | 3356 if (!is_being_destroyed_) { |
| 3357 ClearPowerSaveBlockers(render_frame_host); | |
|
Lei Zhang
2014/10/29 09:26:47
This was fine before. Leave it alone?
tommycli
2014/10/29 19:59:23
Done.
| |
| 3358 | |
| 3359 size_t erased = plugin_content_origin_whitelist_.erase(render_frame_host); | |
| 3360 if (erased > 0) { | |
| 3361 SendToAllFrames(new FrameMsg_UpdatePluginContentOriginWhitelist( | |
|
Lei Zhang
2014/10/29 09:26:47
Do we have to do this? Imagine a web page with sma
tommycli
2014/10/29 19:59:23
Done.
| |
| 3362 MSG_ROUTING_NONE, GetPluginContentOriginWhitelist())); | |
| 3363 } | |
| 3364 } | |
| 3365 | |
| 3339 FOR_EACH_OBSERVER(WebContentsObserver, | 3366 FOR_EACH_OBSERVER(WebContentsObserver, |
| 3340 observers_, | 3367 observers_, |
| 3341 RenderFrameDeleted(render_frame_host)); | 3368 RenderFrameDeleted(render_frame_host)); |
| 3342 } | 3369 } |
| 3343 | 3370 |
| 3344 void WebContentsImpl::WorkerCrashed(RenderFrameHost* render_frame_host) { | 3371 void WebContentsImpl::WorkerCrashed(RenderFrameHost* render_frame_host) { |
| 3345 if (delegate_) | 3372 if (delegate_) |
| 3346 delegate_->WorkerCrashed(this); | 3373 delegate_->WorkerCrashed(this); |
| 3347 } | 3374 } |
| 3348 | 3375 |
| (...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4313 void WebContentsImpl::RemoveAllMediaPlayerEntries( | 4340 void WebContentsImpl::RemoveAllMediaPlayerEntries( |
| 4314 RenderFrameHost* render_frame_host, | 4341 RenderFrameHost* render_frame_host, |
| 4315 ActiveMediaPlayerMap* player_map) { | 4342 ActiveMediaPlayerMap* player_map) { |
| 4316 ActiveMediaPlayerMap::iterator it = | 4343 ActiveMediaPlayerMap::iterator it = |
| 4317 player_map->find(reinterpret_cast<uintptr_t>(render_frame_host)); | 4344 player_map->find(reinterpret_cast<uintptr_t>(render_frame_host)); |
| 4318 if (it == player_map->end()) | 4345 if (it == player_map->end()) |
| 4319 return; | 4346 return; |
| 4320 player_map->erase(it); | 4347 player_map->erase(it); |
| 4321 } | 4348 } |
| 4322 | 4349 |
| 4350 std::set<GURL> WebContentsImpl::GetPluginContentOriginWhitelist() { | |
| 4351 std::set<GURL> whitelisted_origins; | |
| 4352 for (const auto& whitelist_for_frame : plugin_content_origin_whitelist_) { | |
| 4353 for (const auto& origin : whitelist_for_frame.second) { | |
| 4354 whitelisted_origins.insert(origin); | |
| 4355 } | |
| 4356 } | |
| 4357 return whitelisted_origins; | |
| 4358 } | |
| 4359 | |
| 4323 void WebContentsImpl::ResumeResponseDeferredAtStart() { | 4360 void WebContentsImpl::ResumeResponseDeferredAtStart() { |
| 4324 FrameTreeNode* node = frame_tree_.root(); | 4361 FrameTreeNode* node = frame_tree_.root(); |
| 4325 node->render_manager()->ResumeResponseDeferredAtStart(); | 4362 node->render_manager()->ResumeResponseDeferredAtStart(); |
| 4326 } | 4363 } |
| 4327 | 4364 |
| 4328 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4365 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
| 4329 force_disable_overscroll_content_ = force_disable; | 4366 force_disable_overscroll_content_ = force_disable; |
| 4330 if (view_) | 4367 if (view_) |
| 4331 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4368 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 4332 } | 4369 } |
| 4333 | 4370 |
| 4334 } // namespace content | 4371 } // namespace content |
| OLD | NEW |