Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Side by Side Diff: chrome/browser/guest_view/guest_view_base.cc

Issue 444813002: Remove BrowserPlugin's -internal-attach method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 // Give the derived class an opportunity to perform some actions. 265 // Give the derived class an opportunity to perform some actions.
266 DidAttachToEmbedder(); 266 DidAttachToEmbedder();
267 267
268 SendQueuedEvents(); 268 SendQueuedEvents();
269 } 269 }
270 270
271 int GuestViewBase::GetGuestInstanceID() const { 271 int GuestViewBase::GetGuestInstanceID() const {
272 return guest_instance_id_; 272 return guest_instance_id_;
273 } 273 }
274 274
275 void GuestViewBase::SetAttachParams(const base::DictionaryValue& params) {
276 attach_params_.reset(params.DeepCopy());
277 attach_params_->GetInteger(guestview::kParameterInstanceId,
278 &view_instance_id_);
279 }
280
275 void GuestViewBase::SetOpener(GuestViewBase* guest) { 281 void GuestViewBase::SetOpener(GuestViewBase* guest) {
276 if (guest && guest->IsViewType(GetViewType())) { 282 if (guest && guest->IsViewType(GetViewType())) {
277 opener_ = guest->AsWeakPtr(); 283 opener_ = guest->AsWeakPtr();
278 return; 284 return;
279 } 285 }
280 opener_ = base::WeakPtr<GuestViewBase>(); 286 opener_ = base::WeakPtr<GuestViewBase>();
281 } 287 }
282 288
283 void GuestViewBase::RegisterDestructionCallback( 289 void GuestViewBase::RegisterDestructionCallback(
284 const DestructionCallback& callback) { 290 const DestructionCallback& callback) {
285 destruction_callback_ = callback; 291 destruction_callback_ = callback;
286 } 292 }
287 293
288 void GuestViewBase::WillAttach(content::WebContents* embedder_web_contents, 294 void GuestViewBase::WillAttach(content::WebContents* embedder_web_contents) {
289 const base::DictionaryValue& extra_params) {
290 // After attachment, this GuestViewBase's lifetime is restricted to the 295 // After attachment, this GuestViewBase's lifetime is restricted to the
291 // lifetime of its embedder WebContents. Observing the RenderProcessHost 296 // lifetime of its embedder WebContents. Observing the RenderProcessHost
292 // of the embedder is no longer necessary. 297 // of the embedder is no longer necessary.
293 embedder_web_contents->GetRenderProcessHost()->RemoveObserver(this); 298 embedder_web_contents->GetRenderProcessHost()->RemoveObserver(this);
294 embedder_web_contents_ = embedder_web_contents; 299 embedder_web_contents_ = embedder_web_contents;
295 embedder_web_contents_observer_.reset( 300 embedder_web_contents_observer_.reset(
296 new EmbedderWebContentsObserver(this)); 301 new EmbedderWebContentsObserver(this));
297 extra_params.GetInteger(guestview::kParameterInstanceId, &view_instance_id_);
298 extra_params_.reset(extra_params.DeepCopy());
299 302
300 WillAttachToEmbedder(); 303 WillAttachToEmbedder();
301 } 304 }
302 305
303 void GuestViewBase::DidStopLoading(content::RenderViewHost* render_view_host) { 306 void GuestViewBase::DidStopLoading(content::RenderViewHost* render_view_host) {
304 if (!IsDragAndDropEnabled()) { 307 if (!IsDragAndDropEnabled()) {
305 const char script[] = "window.addEventListener('dragstart', function() { " 308 const char script[] = "window.addEventListener('dragstart', function() { "
306 " window.event.preventDefault(); " 309 " window.event.preventDefault(); "
307 "});"; 310 "});";
308 render_view_host->GetMainFrame()->ExecuteJavaScript( 311 render_view_host->GetMainFrame()->ExecuteJavaScript(
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 guest_web_contents); 387 guest_web_contents);
385 callback.Run(guest_web_contents); 388 callback.Run(guest_web_contents);
386 } 389 }
387 390
388 // static 391 // static
389 void GuestViewBase::RegisterGuestViewTypes() { 392 void GuestViewBase::RegisterGuestViewTypes() {
390 AppViewGuest::Register(); 393 AppViewGuest::Register();
391 ExtensionOptionsGuest::Register(); 394 ExtensionOptionsGuest::Register();
392 WebViewGuest::Register(); 395 WebViewGuest::Register();
393 } 396 }
OLDNEW
« no previous file with comments | « chrome/browser/guest_view/guest_view_base.h ('k') | chrome/browser/guest_view/guest_view_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698