| 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 "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/guest_view/guest_view_base.h" | 9 #include "chrome/browser/guest_view/guest_view_base.h" |
| 10 #include "chrome/browser/guest_view/guest_view_constants.h" | 10 #include "chrome/browser/guest_view/guest_view_constants.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 guest_instance_id)) { | 58 guest_instance_id)) { |
| 59 return NULL; | 59 return NULL; |
| 60 } | 60 } |
| 61 return GetGuestByInstanceID(guest_instance_id); | 61 return GetGuestByInstanceID(guest_instance_id); |
| 62 } | 62 } |
| 63 | 63 |
| 64 int GuestViewManager::GetNextInstanceID() { | 64 int GuestViewManager::GetNextInstanceID() { |
| 65 return ++current_instance_id_; | 65 return ++current_instance_id_; |
| 66 } | 66 } |
| 67 | 67 |
| 68 void GuestViewManager::CreateGuest( | 68 void GuestViewManager::CreateGuest(const std::string& view_type, |
| 69 const std::string& view_type, | 69 const std::string& embedder_extension_id, |
| 70 const std::string& embedder_extension_id, | 70 int embedder_render_process_id, |
| 71 int embedder_render_process_id, | 71 content::WebContents* embedder_web_contents, |
| 72 const base::DictionaryValue& create_params, | 72 const base::DictionaryValue& create_params, |
| 73 const WebContentsCreatedCallback& callback) { | 73 const WebContentsCreatedCallback& callback) { |
| 74 int guest_instance_id = GetNextInstanceID(); | 74 int guest_instance_id = GetNextInstanceID(); |
| 75 GuestViewBase* guest = | 75 GuestViewBase* guest = |
| 76 GuestViewBase::Create(context_, guest_instance_id, view_type); | 76 GuestViewBase::Create(context_, guest_instance_id, view_type); |
| 77 if (!guest) { | 77 if (!guest) { |
| 78 callback.Run(NULL); | 78 callback.Run(NULL); |
| 79 return; | 79 return; |
| 80 } | 80 } |
| 81 guest->Init(embedder_extension_id, | 81 guest->Init(embedder_extension_id, |
| 82 embedder_render_process_id, | 82 embedder_render_process_id, |
| 83 embedder_web_contents, |
| 83 create_params, | 84 create_params, |
| 84 callback); | 85 callback); |
| 85 } | 86 } |
| 86 | 87 |
| 87 content::WebContents* GuestViewManager::CreateGuestWithWebContentsParams( | 88 content::WebContents* GuestViewManager::CreateGuestWithWebContentsParams( |
| 88 const std::string& view_type, | 89 const std::string& view_type, |
| 89 const std::string& embedder_extension_id, | 90 const std::string& embedder_extension_id, |
| 90 int embedder_render_process_id, | 91 int embedder_render_process_id, |
| 91 const content::WebContents::CreateParams& create_params) { | 92 const content::WebContents::CreateParams& create_params) { |
| 92 int guest_instance_id = GetNextInstanceID(); | 93 int guest_instance_id = GetNextInstanceID(); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 guest_web_contents_by_instance_id_.find(guest_instance_id); | 236 guest_web_contents_by_instance_id_.find(guest_instance_id); |
| 236 if (it == guest_web_contents_by_instance_id_.end()) | 237 if (it == guest_web_contents_by_instance_id_.end()) |
| 237 return true; | 238 return true; |
| 238 | 239 |
| 239 GuestViewBase* guest_view = GuestViewBase::FromWebContents(it->second); | 240 GuestViewBase* guest_view = GuestViewBase::FromWebContents(it->second); |
| 240 if (!guest_view) | 241 if (!guest_view) |
| 241 return false; | 242 return false; |
| 242 | 243 |
| 243 return embedder_render_process_id == guest_view->embedder_render_process_id(); | 244 return embedder_render_process_id == guest_view->embedder_render_process_id(); |
| 244 } | 245 } |
| OLD | NEW |