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 "extensions/browser/guest_view/guest_view_base.h" | 5 #include "extensions/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 "content/public/browser/render_frame_host.h" | 9 #include "content/public/browser/render_frame_host.h" |
10 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 } | 315 } |
316 | 316 |
317 void GuestViewBase::GuestSizeChanged(const gfx::Size& old_size, | 317 void GuestViewBase::GuestSizeChanged(const gfx::Size& old_size, |
318 const gfx::Size& new_size) { | 318 const gfx::Size& new_size) { |
319 if (!auto_size_enabled_) | 319 if (!auto_size_enabled_) |
320 return; | 320 return; |
321 guest_size_ = new_size; | 321 guest_size_ = new_size; |
322 GuestSizeChangedDueToAutoSize(old_size, new_size); | 322 GuestSizeChangedDueToAutoSize(old_size, new_size); |
323 } | 323 } |
324 | 324 |
| 325 void GuestViewBase::SetAttachParams(const base::DictionaryValue& params) { |
| 326 attach_params_.reset(params.DeepCopy()); |
| 327 attach_params_->GetInteger(guestview::kParameterInstanceId, |
| 328 &view_instance_id_); |
| 329 } |
| 330 |
325 void GuestViewBase::SetOpener(GuestViewBase* guest) { | 331 void GuestViewBase::SetOpener(GuestViewBase* guest) { |
326 if (guest && guest->IsViewType(GetViewType())) { | 332 if (guest && guest->IsViewType(GetViewType())) { |
327 opener_ = guest->AsWeakPtr(); | 333 opener_ = guest->AsWeakPtr(); |
328 return; | 334 return; |
329 } | 335 } |
330 opener_ = base::WeakPtr<GuestViewBase>(); | 336 opener_ = base::WeakPtr<GuestViewBase>(); |
331 } | 337 } |
332 | 338 |
333 void GuestViewBase::RegisterDestructionCallback( | 339 void GuestViewBase::RegisterDestructionCallback( |
334 const DestructionCallback& callback) { | 340 const DestructionCallback& callback) { |
335 destruction_callback_ = callback; | 341 destruction_callback_ = callback; |
336 } | 342 } |
337 | 343 |
338 void GuestViewBase::WillAttach(content::WebContents* embedder_web_contents, | 344 void GuestViewBase::WillAttach(content::WebContents* embedder_web_contents) { |
339 const base::DictionaryValue& extra_params) { | |
340 // After attachment, this GuestViewBase's lifetime is restricted to the | 345 // After attachment, this GuestViewBase's lifetime is restricted to the |
341 // lifetime of its embedder WebContents. Observing the RenderProcessHost | 346 // lifetime of its embedder WebContents. Observing the RenderProcessHost |
342 // of the embedder is no longer necessary. | 347 // of the embedder is no longer necessary. |
343 embedder_web_contents->GetRenderProcessHost()->RemoveObserver(this); | 348 embedder_web_contents->GetRenderProcessHost()->RemoveObserver(this); |
344 embedder_web_contents_ = embedder_web_contents; | 349 embedder_web_contents_ = embedder_web_contents; |
345 embedder_web_contents_observer_.reset( | 350 embedder_web_contents_observer_.reset( |
346 new EmbedderWebContentsObserver(this)); | 351 new EmbedderWebContentsObserver(this)); |
347 extra_params.GetInteger(guestview::kParameterInstanceId, &view_instance_id_); | |
348 extra_params_.reset(extra_params.DeepCopy()); | |
349 | 352 |
350 WillAttachToEmbedder(); | 353 WillAttachToEmbedder(); |
351 } | 354 } |
352 | 355 |
353 void GuestViewBase::DidStopLoading(content::RenderViewHost* render_view_host) { | 356 void GuestViewBase::DidStopLoading(content::RenderViewHost* render_view_host) { |
354 if (!IsDragAndDropEnabled()) { | 357 if (!IsDragAndDropEnabled()) { |
355 const char script[] = "window.addEventListener('dragstart', function() { " | 358 const char script[] = "window.addEventListener('dragstart', function() { " |
356 " window.event.preventDefault(); " | 359 " window.event.preventDefault(); " |
357 "});"; | 360 "});"; |
358 render_view_host->GetMainFrame()->ExecuteJavaScript( | 361 render_view_host->GetMainFrame()->ExecuteJavaScript( |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 guest_web_contents); | 443 guest_web_contents); |
441 callback.Run(guest_web_contents); | 444 callback.Run(guest_web_contents); |
442 } | 445 } |
443 | 446 |
444 // static | 447 // static |
445 void GuestViewBase::RegisterGuestViewTypes() { | 448 void GuestViewBase::RegisterGuestViewTypes() { |
446 ExtensionsAPIClient::Get()->RegisterGuestViewTypes(); | 449 ExtensionsAPIClient::Get()->RegisterGuestViewTypes(); |
447 } | 450 } |
448 | 451 |
449 } // namespace extensions | 452 } // namespace extensions |
OLD | NEW |