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 "components/guest_view/browser/guest_view_manager.h" | 5 #include "components/guest_view/browser/guest_view_manager.h" |
6 | 6 |
7 #include <tuple> | 7 #include <tuple> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 WebContents* GuestViewManager::GetFullPageGuest( | 232 WebContents* GuestViewManager::GetFullPageGuest( |
233 WebContents* embedder_web_contents) { | 233 WebContents* embedder_web_contents) { |
234 WebContents* result = nullptr; | 234 WebContents* result = nullptr; |
235 ForEachGuest(embedder_web_contents, | 235 ForEachGuest(embedder_web_contents, |
236 base::Bind(&GuestViewManager::GetFullPageGuestHelper, &result)); | 236 base::Bind(&GuestViewManager::GetFullPageGuestHelper, &result)); |
237 return result; | 237 return result; |
238 } | 238 } |
239 | 239 |
240 void GuestViewManager::AddGuest(int guest_instance_id, | 240 void GuestViewManager::AddGuest(int guest_instance_id, |
241 WebContents* guest_web_contents) { | 241 WebContents* guest_web_contents) { |
242 CHECK(!ContainsKey(guest_web_contents_by_instance_id_, guest_instance_id)); | 242 CHECK(!base::ContainsKey(guest_web_contents_by_instance_id_, |
| 243 guest_instance_id)); |
243 CHECK(CanUseGuestInstanceID(guest_instance_id)); | 244 CHECK(CanUseGuestInstanceID(guest_instance_id)); |
244 guest_web_contents_by_instance_id_[guest_instance_id] = guest_web_contents; | 245 guest_web_contents_by_instance_id_[guest_instance_id] = guest_web_contents; |
245 | 246 |
246 delegate_->OnGuestAdded(guest_web_contents); | 247 delegate_->OnGuestAdded(guest_web_contents); |
247 } | 248 } |
248 | 249 |
249 void GuestViewManager::RemoveGuest(int guest_instance_id) { | 250 void GuestViewManager::RemoveGuest(int guest_instance_id) { |
250 auto it = guest_web_contents_by_instance_id_.find(guest_instance_id); | 251 auto it = guest_web_contents_by_instance_id_.find(guest_instance_id); |
251 DCHECK(it != guest_web_contents_by_instance_id_.end()); | 252 DCHECK(it != guest_web_contents_by_instance_id_.end()); |
252 guest_web_contents_by_instance_id_.erase(it); | 253 guest_web_contents_by_instance_id_.erase(it); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 content::RenderProcessHost::FromID(embedder_render_process_id) | 416 content::RenderProcessHost::FromID(embedder_render_process_id) |
416 ->Shutdown(content::RESULT_CODE_KILLED_BAD_MESSAGE, false); | 417 ->Shutdown(content::RESULT_CODE_KILLED_BAD_MESSAGE, false); |
417 return false; | 418 return false; |
418 } | 419 } |
419 return true; | 420 return true; |
420 } | 421 } |
421 | 422 |
422 bool GuestViewManager::CanUseGuestInstanceID(int guest_instance_id) { | 423 bool GuestViewManager::CanUseGuestInstanceID(int guest_instance_id) { |
423 if (guest_instance_id <= last_instance_id_removed_) | 424 if (guest_instance_id <= last_instance_id_removed_) |
424 return false; | 425 return false; |
425 return !ContainsKey(removed_instance_ids_, guest_instance_id); | 426 return !base::ContainsKey(removed_instance_ids_, guest_instance_id); |
426 } | 427 } |
427 | 428 |
428 // static | 429 // static |
429 bool GuestViewManager::GetFullPageGuestHelper( | 430 bool GuestViewManager::GetFullPageGuestHelper( |
430 content::WebContents** result, | 431 content::WebContents** result, |
431 content::WebContents* guest_web_contents) { | 432 content::WebContents* guest_web_contents) { |
432 auto* guest_view = GuestViewBase::FromWebContents(guest_web_contents); | 433 auto* guest_view = GuestViewBase::FromWebContents(guest_web_contents); |
433 if (guest_view && guest_view->is_full_page_plugin()) { | 434 if (guest_view && guest_view->is_full_page_plugin()) { |
434 *result = guest_web_contents; | 435 *result = guest_web_contents; |
435 return true; | 436 return true; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 const GuestViewCreateFunction& create_function, | 495 const GuestViewCreateFunction& create_function, |
495 const GuestViewCleanUpFunction& cleanup_function) | 496 const GuestViewCleanUpFunction& cleanup_function) |
496 : create_function(create_function), cleanup_function(cleanup_function) {} | 497 : create_function(create_function), cleanup_function(cleanup_function) {} |
497 | 498 |
498 GuestViewManager::GuestViewData::GuestViewData(const GuestViewData& other) = | 499 GuestViewManager::GuestViewData::GuestViewData(const GuestViewData& other) = |
499 default; | 500 default; |
500 | 501 |
501 GuestViewManager::GuestViewData::~GuestViewData() {} | 502 GuestViewManager::GuestViewData::~GuestViewData() {} |
502 | 503 |
503 } // namespace guest_view | 504 } // namespace guest_view |
OLD | NEW |