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_base.h" | 5 #include "chrome/browser/guest_view/guest_view_base.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/guest_view/app_view/app_view_guest.h" | 9 #include "chrome/browser/guest_view/app_view/app_view_guest.h" |
10 #include "chrome/browser/guest_view/extension_options/extension_options_guest.h" | 10 #include "chrome/browser/guest_view/extension_options/extension_options_guest.h" |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 } | 336 } |
337 | 337 |
338 void GuestViewBase::GuestSizeChanged(const gfx::Size& old_size, | 338 void GuestViewBase::GuestSizeChanged(const gfx::Size& old_size, |
339 const gfx::Size& new_size) { | 339 const gfx::Size& new_size) { |
340 if (!auto_size_enabled_) | 340 if (!auto_size_enabled_) |
341 return; | 341 return; |
342 guest_size_ = new_size; | 342 guest_size_ = new_size; |
343 GuestSizeChangedDueToAutoSize(old_size, new_size); | 343 GuestSizeChangedDueToAutoSize(old_size, new_size); |
344 } | 344 } |
345 | 345 |
| 346 void GuestViewBase::SetAttachParams(const base::DictionaryValue& params) { |
| 347 attach_params_.reset(params.DeepCopy()); |
| 348 attach_params_->GetInteger(guestview::kParameterInstanceId, |
| 349 &view_instance_id_); |
| 350 } |
| 351 |
346 void GuestViewBase::SetOpener(GuestViewBase* guest) { | 352 void GuestViewBase::SetOpener(GuestViewBase* guest) { |
347 if (guest && guest->IsViewType(GetViewType())) { | 353 if (guest && guest->IsViewType(GetViewType())) { |
348 opener_ = guest->AsWeakPtr(); | 354 opener_ = guest->AsWeakPtr(); |
349 return; | 355 return; |
350 } | 356 } |
351 opener_ = base::WeakPtr<GuestViewBase>(); | 357 opener_ = base::WeakPtr<GuestViewBase>(); |
352 } | 358 } |
353 | 359 |
354 void GuestViewBase::RegisterDestructionCallback( | 360 void GuestViewBase::RegisterDestructionCallback( |
355 const DestructionCallback& callback) { | 361 const DestructionCallback& callback) { |
356 destruction_callback_ = callback; | 362 destruction_callback_ = callback; |
357 } | 363 } |
358 | 364 |
359 void GuestViewBase::WillAttach(content::WebContents* embedder_web_contents, | 365 void GuestViewBase::WillAttach(content::WebContents* embedder_web_contents) { |
360 const base::DictionaryValue& extra_params) { | |
361 // After attachment, this GuestViewBase's lifetime is restricted to the | 366 // After attachment, this GuestViewBase's lifetime is restricted to the |
362 // lifetime of its embedder WebContents. Observing the RenderProcessHost | 367 // lifetime of its embedder WebContents. Observing the RenderProcessHost |
363 // of the embedder is no longer necessary. | 368 // of the embedder is no longer necessary. |
364 embedder_web_contents->GetRenderProcessHost()->RemoveObserver(this); | 369 embedder_web_contents->GetRenderProcessHost()->RemoveObserver(this); |
365 embedder_web_contents_ = embedder_web_contents; | 370 embedder_web_contents_ = embedder_web_contents; |
366 embedder_web_contents_observer_.reset( | 371 embedder_web_contents_observer_.reset( |
367 new EmbedderWebContentsObserver(this)); | 372 new EmbedderWebContentsObserver(this)); |
368 extra_params.GetInteger(guestview::kParameterInstanceId, &view_instance_id_); | |
369 extra_params_.reset(extra_params.DeepCopy()); | |
370 | 373 |
371 WillAttachToEmbedder(); | 374 WillAttachToEmbedder(); |
372 } | 375 } |
373 | 376 |
374 void GuestViewBase::DidStopLoading(content::RenderViewHost* render_view_host) { | 377 void GuestViewBase::DidStopLoading(content::RenderViewHost* render_view_host) { |
375 if (!IsDragAndDropEnabled()) { | 378 if (!IsDragAndDropEnabled()) { |
376 const char script[] = "window.addEventListener('dragstart', function() { " | 379 const char script[] = "window.addEventListener('dragstart', function() { " |
377 " window.event.preventDefault(); " | 380 " window.event.preventDefault(); " |
378 "});"; | 381 "});"; |
379 render_view_host->GetMainFrame()->ExecuteJavaScript( | 382 render_view_host->GetMainFrame()->ExecuteJavaScript( |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 guest_web_contents); | 468 guest_web_contents); |
466 callback.Run(guest_web_contents); | 469 callback.Run(guest_web_contents); |
467 } | 470 } |
468 | 471 |
469 // static | 472 // static |
470 void GuestViewBase::RegisterGuestViewTypes() { | 473 void GuestViewBase::RegisterGuestViewTypes() { |
471 AppViewGuest::Register(); | 474 AppViewGuest::Register(); |
472 ExtensionOptionsGuest::Register(); | 475 ExtensionOptionsGuest::Register(); |
473 WebViewGuest::Register(); | 476 WebViewGuest::Register(); |
474 } | 477 } |
OLD | NEW |