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/browser_plugin/browser_plugin_embedder.h" | 5 #include "content/browser/browser_plugin/browser_plugin_embedder.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 BrowserPluginGuest* BrowserPluginEmbedder::GetGuestByInstanceID( | 63 BrowserPluginGuest* BrowserPluginEmbedder::GetGuestByInstanceID( |
64 int instance_id) const { | 64 int instance_id) const { |
65 ContainerInstanceMap::const_iterator it = | 65 ContainerInstanceMap::const_iterator it = |
66 guest_web_contents_by_instance_id_.find(instance_id); | 66 guest_web_contents_by_instance_id_.find(instance_id); |
67 if (it != guest_web_contents_by_instance_id_.end()) | 67 if (it != guest_web_contents_by_instance_id_.end()) |
68 return static_cast<WebContentsImpl*>(it->second)->GetBrowserPluginGuest(); | 68 return static_cast<WebContentsImpl*>(it->second)->GetBrowserPluginGuest(); |
69 return NULL; | 69 return NULL; |
70 } | 70 } |
71 | 71 |
72 void BrowserPluginEmbedder::AddGuest(int instance_id, | 72 void BrowserPluginEmbedder::AddGuest(int instance_id, |
73 WebContents* guest_web_contents, | 73 WebContents* guest_web_contents) { |
74 int64 frame_id) { | |
75 DCHECK(guest_web_contents_by_instance_id_.find(instance_id) == | 74 DCHECK(guest_web_contents_by_instance_id_.find(instance_id) == |
76 guest_web_contents_by_instance_id_.end()); | 75 guest_web_contents_by_instance_id_.end()); |
77 guest_web_contents_by_instance_id_[instance_id] = guest_web_contents; | 76 guest_web_contents_by_instance_id_[instance_id] = guest_web_contents; |
78 } | 77 } |
79 | 78 |
80 void BrowserPluginEmbedder::NavigateGuest(RenderViewHost* render_view_host, | 79 void BrowserPluginEmbedder::NavigateGuest(RenderViewHost* render_view_host, |
81 int instance_id, | 80 int instance_id, |
82 int64 frame_id, | |
83 const std::string& src, | 81 const std::string& src, |
84 const gfx::Size& size) { | 82 const gfx::Size& size) { |
85 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); | 83 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); |
86 WebContentsImpl* guest_web_contents = NULL; | 84 WebContentsImpl* guest_web_contents = NULL; |
87 GURL url(src); | 85 GURL url(src); |
88 if (!guest) { | 86 if (!guest) { |
89 const std::string& host = | 87 const std::string& host = |
90 render_view_host->GetSiteInstance()->GetSite().host(); | 88 render_view_host->GetSiteInstance()->GetSite().host(); |
91 guest_web_contents = WebContentsImpl::CreateGuest( | 89 guest_web_contents = WebContentsImpl::CreateGuest( |
92 web_contents()->GetBrowserContext(), | 90 web_contents()->GetBrowserContext(), |
93 host, | 91 host, |
94 instance_id); | 92 instance_id); |
95 | 93 |
96 guest = guest_web_contents->GetBrowserPluginGuest(); | 94 guest = guest_web_contents->GetBrowserPluginGuest(); |
97 guest->set_embedder_render_process_host( | 95 guest->set_embedder_render_process_host( |
98 render_view_host->GetProcess()); | 96 render_view_host->GetProcess()); |
99 | 97 |
100 guest_web_contents->GetMutableRendererPrefs()-> | 98 guest_web_contents->GetMutableRendererPrefs()-> |
101 throttle_input_events = false; | 99 throttle_input_events = false; |
102 AddGuest(instance_id, guest_web_contents, frame_id); | 100 AddGuest(instance_id, guest_web_contents); |
103 guest_web_contents->SetDelegate(guest); | 101 guest_web_contents->SetDelegate(guest); |
104 } else { | 102 } else { |
105 guest_web_contents = | 103 guest_web_contents = |
106 static_cast<WebContentsImpl*>(guest->GetWebContents()); | 104 static_cast<WebContentsImpl*>(guest->GetWebContents()); |
107 } | 105 } |
108 | 106 |
109 // We ignore loading empty urls in web_contents. | 107 // We ignore loading empty urls in web_contents. |
110 // If a guest sets empty src attribute after it has navigated to some | 108 // If a guest sets empty src attribute after it has navigated to some |
111 // non-empty page, the action is considered no-op. | 109 // non-empty page, the action is considered no-op. |
112 // TODO(lazyboy): The js shim for browser-plugin might need to reflect empty | 110 // TODO(lazyboy): The js shim for browser-plugin might need to reflect empty |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 bool visible = *Details<bool>(details).ptr(); | 233 bool visible = *Details<bool>(details).ptr(); |
236 WebContentsVisibilityChanged(visible); | 234 WebContentsVisibilityChanged(visible); |
237 break; | 235 break; |
238 } | 236 } |
239 default: | 237 default: |
240 NOTREACHED() << "Unexpected notification type: " << type; | 238 NOTREACHED() << "Unexpected notification type: " << type; |
241 } | 239 } |
242 } | 240 } |
243 | 241 |
244 } // namespace content | 242 } // namespace content |
OLD | NEW |