Chromium Code Reviews| 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_guest.h" | 5 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 next_permission_request_id_(browser_plugin::kInvalidPermissionRequestID), | 214 next_permission_request_id_(browser_plugin::kInvalidPermissionRequestID), |
| 215 has_render_view_(has_render_view), | 215 has_render_view_(has_render_view), |
| 216 last_seen_auto_size_enabled_(false), | 216 last_seen_auto_size_enabled_(false), |
| 217 is_in_destruction_(false), | 217 is_in_destruction_(false), |
| 218 last_text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 218 last_text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 219 last_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), | 219 last_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), |
| 220 last_can_compose_inline_(true), | 220 last_can_compose_inline_(true), |
| 221 weak_ptr_factory_(this) { | 221 weak_ptr_factory_(this) { |
| 222 DCHECK(web_contents); | 222 DCHECK(web_contents); |
| 223 web_contents->SetDelegate(this); | 223 web_contents->SetDelegate(this); |
| 224 GetBrowserPluginGuestManager()->AddGuest(instance_id_, GetWebContents()); | |
| 225 } | 224 } |
| 226 | 225 |
| 227 bool BrowserPluginGuest::AddMessageToConsole(WebContents* source, | 226 bool BrowserPluginGuest::AddMessageToConsole(WebContents* source, |
| 228 int32 level, | 227 int32 level, |
| 229 const base::string16& message, | 228 const base::string16& message, |
| 230 int32 line_no, | 229 int32 line_no, |
| 231 const base::string16& source_id) { | 230 const base::string16& source_id) { |
| 232 if (!delegate_) | 231 if (!delegate_) |
| 233 return false; | 232 return false; |
| 234 | 233 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 const OpenURLParams& params) { | 308 const OpenURLParams& params) { |
| 310 BrowserPluginGuestManager* guest_manager = GetBrowserPluginGuestManager(); | 309 BrowserPluginGuestManager* guest_manager = GetBrowserPluginGuestManager(); |
| 311 | 310 |
| 312 // Allocate a new instance ID for the new guest. | 311 // Allocate a new instance ID for the new guest. |
| 313 int instance_id = guest_manager->GetNextInstanceID(); | 312 int instance_id = guest_manager->GetNextInstanceID(); |
| 314 | 313 |
| 315 // Set the attach params to use the same partition as the opener. | 314 // Set the attach params to use the same partition as the opener. |
| 316 // We pull the partition information from the site's URL, which is of the form | 315 // We pull the partition information from the site's URL, which is of the form |
| 317 // guest://site/{persist}?{partition_name}. | 316 // guest://site/{persist}?{partition_name}. |
| 318 const GURL& site_url = GetWebContents()->GetSiteInstance()->GetSiteURL(); | 317 const GURL& site_url = GetWebContents()->GetSiteInstance()->GetSiteURL(); |
| 319 BrowserPluginHostMsg_Attach_Params attach_params; | 318 BrowserPluginHostMsg_Attach_Params attach_params; |
|
lazyboy
2014/05/02 19:52:52
Do we still need to create this MSG object here?
Fady Samuel
2014/05/06 20:02:48
No removed.
| |
| 320 attach_params.storage_partition_id = site_url.query(); | 319 attach_params.storage_partition_id = site_url.query(); |
| 321 attach_params.persist_storage = | 320 attach_params.persist_storage = |
| 322 site_url.path().find("persist") != std::string::npos; | 321 site_url.path().find("persist") != std::string::npos; |
| 323 | 322 |
| 324 // The new guest gets a copy of this guest's extra params so that the content | 323 // The new guest gets a copy of this guest's extra params so that the content |
| 325 // embedder exposes the same API for this guest as its opener. | 324 // embedder exposes the same API for this guest as its opener. |
| 326 scoped_ptr<base::DictionaryValue> extra_params( | 325 scoped_ptr<base::DictionaryValue> extra_params( |
| 327 extra_attach_params_->DeepCopy()); | 326 extra_attach_params_->DeepCopy()); |
| 327 StorageInfo storage_info; | |
| 328 storage_info.partition_id = attach_params.storage_partition_id; | |
| 329 storage_info.persist = attach_params.persist_storage; | |
| 328 BrowserPluginGuest* new_guest = | 330 BrowserPluginGuest* new_guest = |
| 329 guest_manager->CreateGuest(GetWebContents()->GetSiteInstance(), | 331 guest_manager->CreateGuest(GetWebContents()->GetSiteInstance(), |
| 330 instance_id, | 332 instance_id, |
| 331 attach_params, | 333 storage_info, |
| 332 extra_params.Pass()); | 334 extra_params.Pass()); |
| 333 if (new_guest->delegate_) | 335 if (new_guest->delegate_) |
| 334 new_guest->delegate_->SetOpener(GetWebContents()); | 336 new_guest->delegate_->SetOpener(GetWebContents()); |
| 335 | 337 |
| 336 // Take ownership of |new_guest|. | 338 // Take ownership of |new_guest|. |
| 337 pending_new_windows_.insert( | 339 pending_new_windows_.insert( |
| 338 std::make_pair(new_guest, NewWindowInfo(params.url, std::string()))); | 340 std::make_pair(new_guest, NewWindowInfo(params.url, std::string()))); |
| 339 | 341 |
| 340 // Request permission to show the new window. | 342 // Request permission to show the new window. |
| 341 RequestNewWindowPermission(params.disposition, gfx::Rect(), | 343 RequestNewWindowPermission(params.disposition, gfx::Rect(), |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 353 if (delegate_) | 355 if (delegate_) |
| 354 delegate_->EmbedderDestroyed(); | 356 delegate_->EmbedderDestroyed(); |
| 355 Destroy(); | 357 Destroy(); |
| 356 } | 358 } |
| 357 | 359 |
| 358 void BrowserPluginGuest::Destroy() { | 360 void BrowserPluginGuest::Destroy() { |
| 359 is_in_destruction_ = true; | 361 is_in_destruction_ = true; |
| 360 if (!attached() && GetOpener()) | 362 if (!attached() && GetOpener()) |
| 361 GetOpener()->pending_new_windows_.erase(this); | 363 GetOpener()->pending_new_windows_.erase(this); |
| 362 DestroyUnattachedWindows(); | 364 DestroyUnattachedWindows(); |
| 363 GetBrowserPluginGuestManager()->RemoveGuest(instance_id_); | |
| 364 delete GetWebContents(); | 365 delete GetWebContents(); |
| 365 } | 366 } |
| 366 | 367 |
| 367 bool BrowserPluginGuest::OnMessageReceivedFromEmbedder( | 368 bool BrowserPluginGuest::OnMessageReceivedFromEmbedder( |
| 368 const IPC::Message& message) { | 369 const IPC::Message& message) { |
| 369 bool handled = true; | 370 bool handled = true; |
| 370 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) | 371 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) |
| 371 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameSwappedACK, | 372 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameSwappedACK, |
| 372 OnCompositorFrameSwappedACK) | 373 OnCompositorFrameSwappedACK) |
| 373 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CopyFromCompositingSurfaceAck, | 374 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CopyFromCompositingSurfaceAck, |
| (...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1550 const GURL& url) { | 1551 const GURL& url) { |
| 1551 if (!url.is_valid()) { | 1552 if (!url.is_valid()) { |
| 1552 callback.Run(false); | 1553 callback.Run(false); |
| 1553 return; | 1554 return; |
| 1554 } | 1555 } |
| 1555 | 1556 |
| 1556 delegate_->CanDownload(request_method, url, callback); | 1557 delegate_->CanDownload(request_method, url, callback); |
| 1557 } | 1558 } |
| 1558 | 1559 |
| 1559 } // namespace content | 1560 } // namespace content |
| OLD | NEW |