Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/guest_view/guest_view_manager.h" | 5 #include "chrome/browser/guest_view/guest_view_manager.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
| 8 #include "chrome/browser/guest_view/guest_view_base.h" | 8 #include "chrome/browser/guest_view/guest_view_base.h" |
| 9 #include "chrome/browser/guest_view/guest_view_constants.h" | 9 #include "chrome/browser/guest_view/guest_view_constants.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 | 90 |
| 91 void GuestViewManager::RemoveGuest(int guest_instance_id) { | 91 void GuestViewManager::RemoveGuest(int guest_instance_id) { |
| 92 GuestInstanceMap::iterator it = | 92 GuestInstanceMap::iterator it = |
| 93 guest_web_contents_by_instance_id_.find(guest_instance_id); | 93 guest_web_contents_by_instance_id_.find(guest_instance_id); |
| 94 DCHECK(it != guest_web_contents_by_instance_id_.end()); | 94 DCHECK(it != guest_web_contents_by_instance_id_.end()); |
| 95 render_process_host_id_multiset_.erase( | 95 render_process_host_id_multiset_.erase( |
| 96 it->second->GetRenderProcessHost()->GetID()); | 96 it->second->GetRenderProcessHost()->GetID()); |
| 97 guest_web_contents_by_instance_id_.erase(it); | 97 guest_web_contents_by_instance_id_.erase(it); |
| 98 } | 98 } |
| 99 | 99 |
| 100 content::WebContents* GuestViewManager::GetGuestByInstanceID( | 100 void GuestViewManager::MaybeGetGuestByInstanceIDOrKill( |
| 101 int guest_instance_id, | |
| 102 int embedder_render_process_id, | |
| 103 const GuestByInstanceIDCallback& callback) { | |
| 104 if (!CanEmbedderAccessInstanceIDMaybeKill(embedder_render_process_id, | |
| 105 guest_instance_id)) { | |
| 106 // If we kill the embedder, then don't bother calling back. | |
| 107 return; | |
| 108 } | |
| 109 content::WebContents* guest_web_contents = | |
| 110 GetGuestByInstanceID(guest_instance_id, embedder_render_process_id); | |
| 111 callback.Run(guest_web_contents); | |
| 112 } | |
| 113 | |
| 114 content::WebContents* GuestViewManager::GetGuestByInstanceIDSafely( | |
| 101 int guest_instance_id, | 115 int guest_instance_id, |
| 102 int embedder_render_process_id) { | 116 int embedder_render_process_id) { |
| 103 if (!CanEmbedderAccessInstanceIDMaybeKill(embedder_render_process_id, | 117 if (!CanEmbedderAccessInstanceIDMaybeKill(embedder_render_process_id, |
| 104 guest_instance_id)) { | 118 guest_instance_id)) { |
| 105 return NULL; | 119 return NULL; |
| 106 } | 120 } |
| 121 return GetGuestByInstanceID(guest_instance_id, embedder_render_process_id); | |
| 122 } | |
| 123 | |
| 124 content::WebContents* GuestViewManager::GetGuestByInstanceID( | |
|
lazyboy
2014/05/01 23:27:58
Rearrange placement of this function so it matches
Fady Samuel
2014/05/06 16:51:36
Done.
| |
| 125 int guest_instance_id, | |
| 126 int embedder_render_process_id) { | |
| 107 GuestInstanceMap::const_iterator it = | 127 GuestInstanceMap::const_iterator it = |
| 108 guest_web_contents_by_instance_id_.find(guest_instance_id); | 128 guest_web_contents_by_instance_id_.find(guest_instance_id); |
| 109 if (it == guest_web_contents_by_instance_id_.end()) | 129 if (it == guest_web_contents_by_instance_id_.end()) |
| 110 return NULL; | 130 return NULL; |
| 111 return it->second; | 131 return it->second; |
| 112 } | 132 } |
| 113 | 133 |
| 114 bool GuestViewManager::CanEmbedderAccessInstanceIDMaybeKill( | 134 bool GuestViewManager::CanEmbedderAccessInstanceIDMaybeKill( |
| 115 int embedder_render_process_id, | 135 int embedder_render_process_id, |
| 116 int guest_instance_id) { | 136 int guest_instance_id) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 return false; | 214 return false; |
| 195 | 215 |
| 196 return embedder_render_process_id == | 216 return embedder_render_process_id == |
| 197 guest->GetOpener()->GetEmbedderWebContents()->GetRenderProcessHost()-> | 217 guest->GetOpener()->GetEmbedderWebContents()->GetRenderProcessHost()-> |
| 198 GetID(); | 218 GetID(); |
| 199 } | 219 } |
| 200 | 220 |
| 201 return embedder_render_process_id == | 221 return embedder_render_process_id == |
| 202 guest->embedder_web_contents()->GetRenderProcessHost()->GetID(); | 222 guest->embedder_web_contents()->GetRenderProcessHost()->GetID(); |
| 203 } | 223 } |
| OLD | NEW |