| 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 "content/browser/browser_plugin/test_guest_manager_delegate.h" | 5 #include "content/browser/browser_plugin/test_guest_manager_delegate.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "content/public/browser/site_instance.h" | 9 #include "content/public/browser/site_instance.h" |
| 10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 } | 36 } |
| 37 | 37 |
| 38 void TestGuestManagerDelegate::RemoveGuest( | 38 void TestGuestManagerDelegate::RemoveGuest( |
| 39 int guest_instance_id) { | 39 int guest_instance_id) { |
| 40 GuestInstanceMap::iterator it = | 40 GuestInstanceMap::iterator it = |
| 41 guest_web_contents_by_instance_id_.find(guest_instance_id); | 41 guest_web_contents_by_instance_id_.find(guest_instance_id); |
| 42 DCHECK(it != guest_web_contents_by_instance_id_.end()); | 42 DCHECK(it != guest_web_contents_by_instance_id_.end()); |
| 43 guest_web_contents_by_instance_id_.erase(it); | 43 guest_web_contents_by_instance_id_.erase(it); |
| 44 } | 44 } |
| 45 | 45 |
| 46 WebContents* TestGuestManagerDelegate::GetGuestByInstanceID( | 46 void TestGuestManagerDelegate::MaybeGetGuestByInstanceIDOrKill( |
| 47 int guest_instance_id, | 47 int guest_instance_id, |
| 48 int embedder_render_process_id) { | 48 int embedder_render_process_id, |
| 49 const GuestByInstanceIDCallback& callback) { |
| 49 GuestInstanceMap::const_iterator it = | 50 GuestInstanceMap::const_iterator it = |
| 50 guest_web_contents_by_instance_id_.find(guest_instance_id); | 51 guest_web_contents_by_instance_id_.find(guest_instance_id); |
| 51 if (it == guest_web_contents_by_instance_id_.end()) | 52 if (it == guest_web_contents_by_instance_id_.end()) { |
| 52 return NULL; | 53 callback.Run(NULL); |
| 53 return it->second; | 54 return; |
| 54 } | 55 } |
| 55 | 56 callback.Run(it->second); |
| 56 bool TestGuestManagerDelegate::CanEmbedderAccessInstanceIDMaybeKill( | |
| 57 int embedder_render_process_id, | |
| 58 int guest_instance_id) { | |
| 59 return true; | |
| 60 } | |
| 61 | |
| 62 bool TestGuestManagerDelegate::CanEmbedderAccessInstanceID( | |
| 63 int embedder_render_process_id, | |
| 64 int guest_instance_id) { | |
| 65 return true; | |
| 66 } | 57 } |
| 67 | 58 |
| 68 SiteInstance* TestGuestManagerDelegate::GetGuestSiteInstance( | 59 SiteInstance* TestGuestManagerDelegate::GetGuestSiteInstance( |
| 69 const GURL& guest_site) { | 60 const GURL& guest_site) { |
| 70 for (GuestInstanceMap::const_iterator it = | 61 for (GuestInstanceMap::const_iterator it = |
| 71 guest_web_contents_by_instance_id_.begin(); | 62 guest_web_contents_by_instance_id_.begin(); |
| 72 it != guest_web_contents_by_instance_id_.end(); ++it) { | 63 it != guest_web_contents_by_instance_id_.end(); ++it) { |
| 73 if (it->second->GetSiteInstance()->GetSiteURL() == guest_site) | 64 if (it->second->GetSiteInstance()->GetSiteURL() == guest_site) |
| 74 return it->second->GetSiteInstance(); | 65 return it->second->GetSiteInstance(); |
| 75 } | 66 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 86 if (embedder_web_contents != guest->GetEmbedderWebContents()) | 77 if (embedder_web_contents != guest->GetEmbedderWebContents()) |
| 87 continue; | 78 continue; |
| 88 | 79 |
| 89 if (callback.Run(guest)) | 80 if (callback.Run(guest)) |
| 90 return true; | 81 return true; |
| 91 } | 82 } |
| 92 return false; | 83 return false; |
| 93 } | 84 } |
| 94 | 85 |
| 95 } // namespace content | 86 } // namespace content |
| OLD | NEW |