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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 258373002: Towards moving guest management to chrome: Introduce GuestViewManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed John's comments Created 6 years, 7 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 (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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 : PermissionRequest(guest), 91 : PermissionRequest(guest),
92 instance_id_(instance_id) { 92 instance_id_(instance_id) {
93 RecordAction( 93 RecordAction(
94 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.NewWindow ")); 94 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.NewWindow "));
95 } 95 }
96 96
97 virtual void RespondImpl(bool should_allow, 97 virtual void RespondImpl(bool should_allow,
98 const std::string& user_input) OVERRIDE { 98 const std::string& user_input) OVERRIDE {
99 int embedder_render_process_id = 99 int embedder_render_process_id =
100 guest_->embedder_web_contents()->GetRenderProcessHost()->GetID(); 100 guest_->embedder_web_contents()->GetRenderProcessHost()->GetID();
101 BrowserPluginGuest* guest = 101 BrowserPluginGuest* guest = guest_->GetBrowserPluginGuestManager()->
102 guest_->GetWebContents()->GetBrowserPluginGuestManager()-> 102 GetGuestByInstanceID(instance_id_, embedder_render_process_id);
103 GetGuestByInstanceID(instance_id_, embedder_render_process_id);
104 if (!guest) { 103 if (!guest) {
105 VLOG(0) << "Guest not found. Instance ID: " << instance_id_; 104 VLOG(0) << "Guest not found. Instance ID: " << instance_id_;
106 return; 105 return;
107 } 106 }
108 107
109 // If we do not destroy the guest then we allow the new window. 108 // If we do not destroy the guest then we allow the new window.
110 if (!should_allow) 109 if (!should_allow)
111 guest->Destroy(); 110 guest->Destroy();
112 } 111 }
113 112
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 181
183 private: 182 private:
184 BrowserPluginGuest* browser_plugin_guest_; 183 BrowserPluginGuest* browser_plugin_guest_;
185 184
186 DISALLOW_COPY_AND_ASSIGN(EmbedderWebContentsObserver); 185 DISALLOW_COPY_AND_ASSIGN(EmbedderWebContentsObserver);
187 }; 186 };
188 187
189 BrowserPluginGuest::BrowserPluginGuest( 188 BrowserPluginGuest::BrowserPluginGuest(
190 int instance_id, 189 int instance_id,
191 bool has_render_view, 190 bool has_render_view,
192 WebContentsImpl* web_contents, 191 WebContentsImpl* web_contents)
193 BrowserPluginGuest* opener)
194 : WebContentsObserver(web_contents), 192 : WebContentsObserver(web_contents),
195 embedder_web_contents_(NULL), 193 embedder_web_contents_(NULL),
196 instance_id_(instance_id), 194 instance_id_(instance_id),
197 guest_device_scale_factor_(1.0f), 195 guest_device_scale_factor_(1.0f),
198 guest_hang_timeout_( 196 guest_hang_timeout_(
199 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), 197 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)),
200 focused_(false), 198 focused_(false),
201 mouse_locked_(false), 199 mouse_locked_(false),
202 pending_lock_request_(false), 200 pending_lock_request_(false),
203 embedder_visible_(true), 201 embedder_visible_(true),
204 auto_size_enabled_(false), 202 auto_size_enabled_(false),
205 copy_request_id_(0), 203 copy_request_id_(0),
206 next_permission_request_id_(browser_plugin::kInvalidPermissionRequestID), 204 next_permission_request_id_(browser_plugin::kInvalidPermissionRequestID),
207 has_render_view_(has_render_view), 205 has_render_view_(has_render_view),
208 last_seen_auto_size_enabled_(false), 206 last_seen_auto_size_enabled_(false),
209 is_in_destruction_(false), 207 is_in_destruction_(false),
210 last_text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 208 last_text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
211 last_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), 209 last_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
212 last_can_compose_inline_(true), 210 last_can_compose_inline_(true),
213 weak_ptr_factory_(this) { 211 weak_ptr_factory_(this) {
214 DCHECK(web_contents); 212 DCHECK(web_contents);
215 web_contents->SetDelegate(this); 213 web_contents->SetDelegate(this);
216 if (opener) 214 GetBrowserPluginGuestManager()->AddGuest(instance_id_, GetWebContents());
217 opener_ = opener->AsWeakPtr();
218 GetWebContents()->GetBrowserPluginGuestManager()->AddGuest(instance_id_,
219 GetWebContents());
220 } 215 }
221 216
222 bool BrowserPluginGuest::AddMessageToConsole(WebContents* source, 217 bool BrowserPluginGuest::AddMessageToConsole(WebContents* source,
223 int32 level, 218 int32 level,
224 const base::string16& message, 219 const base::string16& message,
225 int32 line_no, 220 int32 line_no,
226 const base::string16& source_id) { 221 const base::string16& source_id) {
227 if (!delegate_) 222 if (!delegate_)
228 return false; 223 return false;
229 224
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 BrowserPluginGuestDelegate::PermissionResponseCallback callback = 290 BrowserPluginGuestDelegate::PermissionResponseCallback callback =
296 base::Bind(&BrowserPluginGuest::RespondToPermissionRequest, 291 base::Bind(&BrowserPluginGuest::RespondToPermissionRequest,
297 AsWeakPtr(), 292 AsWeakPtr(),
298 request_id); 293 request_id);
299 delegate_->RequestPermission( 294 delegate_->RequestPermission(
300 permission_type, request_info, callback, request->AllowedByDefault()); 295 permission_type, request_info, callback, request->AllowedByDefault());
301 } 296 }
302 297
303 BrowserPluginGuest* BrowserPluginGuest::CreateNewGuestWindow( 298 BrowserPluginGuest* BrowserPluginGuest::CreateNewGuestWindow(
304 const OpenURLParams& params) { 299 const OpenURLParams& params) {
305 BrowserPluginGuestManager* guest_manager = 300 BrowserPluginGuestManager* guest_manager = GetBrowserPluginGuestManager();
306 GetWebContents()->GetBrowserPluginGuestManager();
307 301
308 // Allocate a new instance ID for the new guest. 302 // Allocate a new instance ID for the new guest.
309 int instance_id = guest_manager->get_next_instance_id(); 303 int instance_id = guest_manager->GetNextInstanceID();
310 304
311 // Set the attach params to use the same partition as the opener. 305 // Set the attach params to use the same partition as the opener.
312 // We pull the partition information from the site's URL, which is of the form 306 // We pull the partition information from the site's URL, which is of the form
313 // guest://site/{persist}?{partition_name}. 307 // guest://site/{persist}?{partition_name}.
314 const GURL& site_url = GetWebContents()->GetSiteInstance()->GetSiteURL(); 308 const GURL& site_url = GetWebContents()->GetSiteInstance()->GetSiteURL();
315 BrowserPluginHostMsg_Attach_Params attach_params; 309 BrowserPluginHostMsg_Attach_Params attach_params;
316 attach_params.storage_partition_id = site_url.query(); 310 attach_params.storage_partition_id = site_url.query();
317 attach_params.persist_storage = 311 attach_params.persist_storage =
318 site_url.path().find("persist") != std::string::npos; 312 site_url.path().find("persist") != std::string::npos;
319 313
320 // The new guest gets a copy of this guest's extra params so that the content 314 // The new guest gets a copy of this guest's extra params so that the content
321 // embedder exposes the same API for this guest as its opener. 315 // embedder exposes the same API for this guest as its opener.
322 scoped_ptr<base::DictionaryValue> extra_params( 316 scoped_ptr<base::DictionaryValue> extra_params(
323 extra_attach_params_->DeepCopy()); 317 extra_attach_params_->DeepCopy());
324 BrowserPluginGuest* new_guest = 318 BrowserPluginGuest* new_guest =
325 GetWebContents()->GetBrowserPluginGuestManager()->CreateGuest( 319 guest_manager->CreateGuest(GetWebContents()->GetSiteInstance(),
326 GetWebContents()->GetSiteInstance(), instance_id, 320 instance_id,
327 attach_params, extra_params.Pass()); 321 attach_params,
328 new_guest->opener_ = AsWeakPtr(); 322 extra_params.Pass());
323 if (new_guest->delegate_)
324 new_guest->delegate_->SetOpener(GetWebContents());
329 325
330 // Take ownership of |new_guest|. 326 // Take ownership of |new_guest|.
331 pending_new_windows_.insert( 327 pending_new_windows_.insert(
332 std::make_pair(new_guest, NewWindowInfo(params.url, std::string()))); 328 std::make_pair(new_guest, NewWindowInfo(params.url, std::string())));
333 329
334 // Request permission to show the new window. 330 // Request permission to show the new window.
335 RequestNewWindowPermission(params.disposition, gfx::Rect(), 331 RequestNewWindowPermission(params.disposition, gfx::Rect(),
336 params.user_gesture, new_guest->GetWebContents()); 332 params.user_gesture, new_guest->GetWebContents());
337 333
338 return new_guest; 334 return new_guest;
339 } 335 }
340 336
341 base::WeakPtr<BrowserPluginGuest> BrowserPluginGuest::AsWeakPtr() { 337 base::WeakPtr<BrowserPluginGuest> BrowserPluginGuest::AsWeakPtr() {
342 return weak_ptr_factory_.GetWeakPtr(); 338 return weak_ptr_factory_.GetWeakPtr();
343 } 339 }
344 340
345 void BrowserPluginGuest::EmbedderDestroyed() { 341 void BrowserPluginGuest::EmbedderDestroyed() {
346 embedder_web_contents_ = NULL; 342 embedder_web_contents_ = NULL;
347 if (delegate_) 343 if (delegate_)
348 delegate_->EmbedderDestroyed(); 344 delegate_->EmbedderDestroyed();
349 Destroy(); 345 Destroy();
350 } 346 }
351 347
352 void BrowserPluginGuest::Destroy() { 348 void BrowserPluginGuest::Destroy() {
353 is_in_destruction_ = true; 349 is_in_destruction_ = true;
354 if (!attached() && opener()) 350 if (!attached() && GetOpener())
355 opener()->pending_new_windows_.erase(this); 351 GetOpener()->pending_new_windows_.erase(this);
356 DestroyUnattachedWindows(); 352 DestroyUnattachedWindows();
357 GetWebContents()->GetBrowserPluginGuestManager()->RemoveGuest(instance_id_); 353 GetBrowserPluginGuestManager()->RemoveGuest(instance_id_);
358 delete GetWebContents(); 354 delete GetWebContents();
359 } 355 }
360 356
361 bool BrowserPluginGuest::OnMessageReceivedFromEmbedder( 357 bool BrowserPluginGuest::OnMessageReceivedFromEmbedder(
362 const IPC::Message& message) { 358 const IPC::Message& message) {
363 bool handled = true; 359 bool handled = true;
364 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) 360 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message)
365 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameSwappedACK, 361 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameSwappedACK,
366 OnCompositorFrameSwappedACK) 362 OnCompositorFrameSwappedACK)
367 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CopyFromCompositingSurfaceAck, 363 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CopyFromCompositingSurfaceAck,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 BrowserPluginGuest* BrowserPluginGuest::Create( 498 BrowserPluginGuest* BrowserPluginGuest::Create(
503 int instance_id, 499 int instance_id,
504 SiteInstance* guest_site_instance, 500 SiteInstance* guest_site_instance,
505 WebContentsImpl* web_contents, 501 WebContentsImpl* web_contents,
506 scoped_ptr<base::DictionaryValue> extra_params) { 502 scoped_ptr<base::DictionaryValue> extra_params) {
507 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create")); 503 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create"));
508 BrowserPluginGuest* guest = NULL; 504 BrowserPluginGuest* guest = NULL;
509 if (factory_) { 505 if (factory_) {
510 guest = factory_->CreateBrowserPluginGuest(instance_id, web_contents); 506 guest = factory_->CreateBrowserPluginGuest(instance_id, web_contents);
511 } else { 507 } else {
512 guest = new BrowserPluginGuest(instance_id, false, web_contents, NULL); 508 guest = new BrowserPluginGuest(instance_id, false, web_contents);
513 } 509 }
514 guest->extra_attach_params_.reset(extra_params->DeepCopy()); 510 guest->extra_attach_params_.reset(extra_params->DeepCopy());
515 web_contents->SetBrowserPluginGuest(guest); 511 web_contents->SetBrowserPluginGuest(guest);
516 BrowserPluginGuestDelegate* delegate = NULL; 512 BrowserPluginGuestDelegate* delegate = NULL;
517 GetContentClient()->browser()->GuestWebContentsCreated( 513 GetContentClient()->browser()->GuestWebContentsCreated(
518 guest_site_instance, web_contents, NULL, &delegate, extra_params.Pass()); 514 guest_site_instance, web_contents, NULL, &delegate, extra_params.Pass());
519 guest->SetDelegate(delegate); 515 guest->SetDelegate(delegate);
520 return guest; 516 return guest;
521 } 517 }
522 518
523 // static 519 // static
524 BrowserPluginGuest* BrowserPluginGuest::CreateWithOpener( 520 BrowserPluginGuest* BrowserPluginGuest::CreateWithOpener(
525 int instance_id, 521 int instance_id,
526 bool has_render_view, 522 bool has_render_view,
527 WebContentsImpl* web_contents, 523 WebContentsImpl* web_contents,
528 BrowserPluginGuest* opener) { 524 BrowserPluginGuest* opener) {
529 BrowserPluginGuest* guest = 525 BrowserPluginGuest* guest =
530 new BrowserPluginGuest( 526 new BrowserPluginGuest(
531 instance_id, has_render_view, web_contents, opener); 527 instance_id, has_render_view, web_contents);
532 web_contents->SetBrowserPluginGuest(guest); 528 web_contents->SetBrowserPluginGuest(guest);
533 BrowserPluginGuestDelegate* delegate = NULL; 529 BrowserPluginGuestDelegate* delegate = NULL;
534 GetContentClient()->browser()->GuestWebContentsCreated( 530 GetContentClient()->browser()->GuestWebContentsCreated(
535 opener->GetWebContents()->GetSiteInstance(), 531 opener->GetWebContents()->GetSiteInstance(),
536 web_contents, opener->GetWebContents(), &delegate, 532 web_contents, opener->GetWebContents(), &delegate,
537 scoped_ptr<base::DictionaryValue>()); 533 scoped_ptr<base::DictionaryValue>());
538 guest->SetDelegate(delegate); 534 guest->SetDelegate(delegate);
539 return guest; 535 return guest;
540 } 536 }
541 537
542 RenderWidgetHostView* BrowserPluginGuest::GetEmbedderRenderWidgetHostView() { 538 RenderWidgetHostView* BrowserPluginGuest::GetEmbedderRenderWidgetHostView() {
543 if (!attached()) 539 if (!attached())
544 return NULL; 540 return NULL;
545 return embedder_web_contents_->GetRenderWidgetHostView(); 541 return embedder_web_contents_->GetRenderWidgetHostView();
546 } 542 }
547 543
544 BrowserPluginGuest* BrowserPluginGuest::GetOpener() const {
545 if (!delegate_)
546 return NULL;
547
548 WebContents* opener = delegate_->GetOpener();
549 if (!opener)
550 return NULL;
551
552 return static_cast<WebContentsImpl*>(opener)->GetBrowserPluginGuest();
553 }
554
548 void BrowserPluginGuest::UpdateVisibility() { 555 void BrowserPluginGuest::UpdateVisibility() {
549 OnSetVisibility(instance_id_, visible()); 556 OnSetVisibility(instance_id_, visible());
550 } 557 }
551 558
552 void BrowserPluginGuest::CopyFromCompositingSurface( 559 void BrowserPluginGuest::CopyFromCompositingSurface(
553 gfx::Rect src_subrect, 560 gfx::Rect src_subrect,
554 gfx::Size dst_size, 561 gfx::Size dst_size,
555 const base::Callback<void(bool, const SkBitmap&)>& callback) { 562 const base::Callback<void(bool, const SkBitmap&)>& callback) {
556 copy_request_callbacks_.insert(std::make_pair(++copy_request_id_, callback)); 563 copy_request_callbacks_.insert(std::make_pair(++copy_request_id_, callback));
557 SendMessageToEmbedder( 564 SendMessageToEmbedder(
558 new BrowserPluginMsg_CopyFromCompositingSurface(instance_id(), 565 new BrowserPluginMsg_CopyFromCompositingSurface(instance_id(),
559 copy_request_id_, src_subrect, dst_size)); 566 copy_request_id_, src_subrect, dst_size));
560 } 567 }
561 568
569 BrowserPluginGuestManager*
570 BrowserPluginGuest::GetBrowserPluginGuestManager() const {
571 return BrowserPluginGuestManager::FromBrowserContext(
572 GetWebContents()->GetBrowserContext());
573 }
574
562 // screen. 575 // screen.
563 gfx::Rect BrowserPluginGuest::ToGuestRect(const gfx::Rect& bounds) { 576 gfx::Rect BrowserPluginGuest::ToGuestRect(const gfx::Rect& bounds) {
564 gfx::Rect guest_rect(bounds); 577 gfx::Rect guest_rect(bounds);
565 guest_rect.Offset(guest_window_rect_.OffsetFromOrigin()); 578 guest_rect.Offset(guest_window_rect_.OffsetFromOrigin());
566 return guest_rect; 579 return guest_rect;
567 } 580 }
568 581
569 void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) { 582 void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) {
570 embedder_visible_ = visible; 583 embedder_visible_ = visible;
571 UpdateVisibility(); 584 UpdateVisibility();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 } 703 }
691 704
692 WebContents* BrowserPluginGuest::OpenURLFromTab(WebContents* source, 705 WebContents* BrowserPluginGuest::OpenURLFromTab(WebContents* source,
693 const OpenURLParams& params) { 706 const OpenURLParams& params) {
694 // If the guest wishes to navigate away prior to attachment then we save the 707 // If the guest wishes to navigate away prior to attachment then we save the
695 // navigation to perform upon attachment. Navigation initializes a lot of 708 // navigation to perform upon attachment. Navigation initializes a lot of
696 // state that assumes an embedder exists, such as RenderWidgetHostViewGuest. 709 // state that assumes an embedder exists, such as RenderWidgetHostViewGuest.
697 // Navigation also resumes resource loading which we don't want to allow 710 // Navigation also resumes resource loading which we don't want to allow
698 // until attachment. 711 // until attachment.
699 if (!attached()) { 712 if (!attached()) {
700 PendingWindowMap::iterator it = opener()->pending_new_windows_.find(this); 713 PendingWindowMap::iterator it =
701 if (it == opener()->pending_new_windows_.end()) 714 GetOpener()->pending_new_windows_.find(this);
715 if (it == GetOpener()->pending_new_windows_.end())
702 return NULL; 716 return NULL;
703 const NewWindowInfo& old_target_url = it->second; 717 const NewWindowInfo& old_target_url = it->second;
704 NewWindowInfo new_window_info(params.url, old_target_url.name); 718 NewWindowInfo new_window_info(params.url, old_target_url.name);
705 new_window_info.changed = new_window_info.url != old_target_url.url; 719 new_window_info.changed = new_window_info.url != old_target_url.url;
706 it->second = new_window_info; 720 it->second = new_window_info;
707 return NULL; 721 return NULL;
708 } 722 }
709 if (params.disposition == CURRENT_TAB) { 723 if (params.disposition == CURRENT_TAB) {
710 // This can happen for cross-site redirects. 724 // This can happen for cross-site redirects.
711 LoadURLWithParams(params.url, params.referrer, params.transition, source); 725 LoadURLWithParams(params.url, params.referrer, params.transition, source);
712 return source; 726 return source;
713 } 727 }
714 728
715 return CreateNewGuestWindow(params)->GetWebContents(); 729 return CreateNewGuestWindow(params)->GetWebContents();
716 } 730 }
717 731
718 void BrowserPluginGuest::WebContentsCreated(WebContents* source_contents, 732 void BrowserPluginGuest::WebContentsCreated(WebContents* source_contents,
719 int opener_render_frame_id, 733 int opener_render_frame_id,
720 const base::string16& frame_name, 734 const base::string16& frame_name,
721 const GURL& target_url, 735 const GURL& target_url,
722 WebContents* new_contents) { 736 WebContents* new_contents) {
723 WebContentsImpl* new_contents_impl = 737 WebContentsImpl* new_contents_impl =
724 static_cast<WebContentsImpl*>(new_contents); 738 static_cast<WebContentsImpl*>(new_contents);
725 BrowserPluginGuest* guest = new_contents_impl->GetBrowserPluginGuest(); 739 BrowserPluginGuest* guest = new_contents_impl->GetBrowserPluginGuest();
726 guest->opener_ = AsWeakPtr(); 740 if (guest->delegate_)
741 guest->delegate_->SetOpener(GetWebContents());
727 std::string guest_name = base::UTF16ToUTF8(frame_name); 742 std::string guest_name = base::UTF16ToUTF8(frame_name);
728 guest->name_ = guest_name; 743 guest->name_ = guest_name;
729 // Take ownership of the new guest until it is attached to the embedder's DOM 744 // Take ownership of the new guest until it is attached to the embedder's DOM
730 // tree to avoid leaking a guest if this guest is destroyed before attaching 745 // tree to avoid leaking a guest if this guest is destroyed before attaching
731 // the new guest. 746 // the new guest.
732 pending_new_windows_.insert( 747 pending_new_windows_.insert(
733 std::make_pair(guest, NewWindowInfo(target_url, guest_name))); 748 std::make_pair(guest, NewWindowInfo(target_url, guest_name)));
734 } 749 }
735 750
736 void BrowserPluginGuest::RendererUnresponsive(WebContents* source) { 751 void BrowserPluginGuest::RendererUnresponsive(WebContents* source) {
(...skipping 20 matching lines...) Expand all
757 772
758 embedder_web_contents_->GetDelegate()->RunFileChooser(web_contents, params); 773 embedder_web_contents_->GetDelegate()->RunFileChooser(web_contents, params);
759 } 774 }
760 775
761 bool BrowserPluginGuest::ShouldFocusPageAfterCrash() { 776 bool BrowserPluginGuest::ShouldFocusPageAfterCrash() {
762 // Rather than managing focus in WebContentsImpl::RenderViewReady, we will 777 // Rather than managing focus in WebContentsImpl::RenderViewReady, we will
763 // manage the focus ourselves. 778 // manage the focus ourselves.
764 return false; 779 return false;
765 } 780 }
766 781
767 WebContentsImpl* BrowserPluginGuest::GetWebContents() { 782 WebContentsImpl* BrowserPluginGuest::GetWebContents() const {
768 return static_cast<WebContentsImpl*>(web_contents()); 783 return static_cast<WebContentsImpl*>(web_contents());
769 } 784 }
770 785
771 gfx::Point BrowserPluginGuest::GetScreenCoordinates( 786 gfx::Point BrowserPluginGuest::GetScreenCoordinates(
772 const gfx::Point& relative_position) const { 787 const gfx::Point& relative_position) const {
773 gfx::Point screen_pos(relative_position); 788 gfx::Point screen_pos(relative_position);
774 screen_pos += guest_window_rect_.OffsetFromOrigin(); 789 screen_pos += guest_window_rect_.OffsetFromOrigin();
775 return screen_pos; 790 return screen_pos;
776 } 791 }
777 792
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 GetWebContents()->GetRenderViewHost())->Init(); 1028 GetWebContents()->GetRenderViewHost())->Init();
1014 WebContentsViewGuest* new_view = 1029 WebContentsViewGuest* new_view =
1015 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); 1030 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
1016 new_view->CreateViewForWidget(web_contents()->GetRenderViewHost()); 1031 new_view->CreateViewForWidget(web_contents()->GetRenderViewHost());
1017 } 1032 }
1018 1033
1019 // We need to do a navigation here if the target URL has changed between 1034 // We need to do a navigation here if the target URL has changed between
1020 // the time the WebContents was created and the time it was attached. 1035 // the time the WebContents was created and the time it was attached.
1021 // We also need to do an initial navigation if a RenderView was never 1036 // We also need to do an initial navigation if a RenderView was never
1022 // created for the new window in cases where there is no referrer. 1037 // created for the new window in cases where there is no referrer.
1023 PendingWindowMap::iterator it = opener()->pending_new_windows_.find(this); 1038 PendingWindowMap::iterator it = GetOpener()->pending_new_windows_.find(this);
1024 if (it != opener()->pending_new_windows_.end()) { 1039 if (it != GetOpener()->pending_new_windows_.end()) {
1025 const NewWindowInfo& new_window_info = it->second; 1040 const NewWindowInfo& new_window_info = it->second;
1026 if (new_window_info.changed || !has_render_view_) 1041 if (new_window_info.changed || !has_render_view_)
1027 params.src = it->second.url.spec(); 1042 params.src = it->second.url.spec();
1028 } else { 1043 } else {
1029 NOTREACHED(); 1044 NOTREACHED();
1030 } 1045 }
1031 1046
1032 // Once a new guest is attached to the DOM of the embedder page, then the 1047 // Once a new guest is attached to the DOM of the embedder page, then the
1033 // lifetime of the new guest is no longer managed by the opener guest. 1048 // lifetime of the new guest is no longer managed by the opener guest.
1034 opener()->pending_new_windows_.erase(this); 1049 GetOpener()->pending_new_windows_.erase(this);
1035 1050
1036 // The guest's frame name takes precedence over the BrowserPlugin's name. 1051 // The guest's frame name takes precedence over the BrowserPlugin's name.
1037 // The guest's frame name is assigned in 1052 // The guest's frame name is assigned in
1038 // BrowserPluginGuest::WebContentsCreated. 1053 // BrowserPluginGuest::WebContentsCreated.
1039 if (!name_.empty()) 1054 if (!name_.empty())
1040 params.name.clear(); 1055 params.name.clear();
1041 1056
1042 Initialize(params, embedder_web_contents); 1057 Initialize(params, embedder_web_contents);
1043 1058
1044 SendQueuedMessages(); 1059 SendQueuedMessages();
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 const GURL& url) { 1540 const GURL& url) {
1526 if (!url.is_valid()) { 1541 if (!url.is_valid()) {
1527 callback.Run(false); 1542 callback.Run(false);
1528 return; 1543 return;
1529 } 1544 }
1530 1545
1531 delegate_->CanDownload(request_method, url, callback); 1546 delegate_->CanDownload(request_method, url, callback);
1532 } 1547 }
1533 1548
1534 } // namespace content 1549 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698