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 "components/ui/zoom/page_zoom.h" | 9 #include "components/ui/zoom/page_zoom.h" |
10 #include "components/ui/zoom/zoom_controller.h" | 10 #include "components/ui/zoom/zoom_controller.h" |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 } | 549 } |
550 | 550 |
551 void GuestViewBase::DeactivateContents(WebContents* web_contents) { | 551 void GuestViewBase::DeactivateContents(WebContents* web_contents) { |
552 if (!attached() || !embedder_web_contents()->GetDelegate()) | 552 if (!attached() || !embedder_web_contents()->GetDelegate()) |
553 return; | 553 return; |
554 | 554 |
555 embedder_web_contents()->GetDelegate()->DeactivateContents( | 555 embedder_web_contents()->GetDelegate()->DeactivateContents( |
556 embedder_web_contents()); | 556 embedder_web_contents()); |
557 } | 557 } |
558 | 558 |
| 559 void GuestViewBase::ContentsMouseEvent(content::WebContents* source, |
| 560 const gfx::Point& location, |
| 561 bool motion) { |
| 562 if (!attached() || !embedder_web_contents()->GetDelegate()) |
| 563 return; |
| 564 |
| 565 embedder_web_contents()->GetDelegate()->ContentsMouseEvent( |
| 566 embedder_web_contents(), location, motion); |
| 567 } |
| 568 |
559 void GuestViewBase::ContentsZoomChange(bool zoom_in) { | 569 void GuestViewBase::ContentsZoomChange(bool zoom_in) { |
560 ui_zoom::PageZoom::Zoom( | 570 ui_zoom::PageZoom::Zoom( |
561 embedder_web_contents(), | 571 embedder_web_contents(), |
562 zoom_in ? content::PAGE_ZOOM_IN : content::PAGE_ZOOM_OUT); | 572 zoom_in ? content::PAGE_ZOOM_IN : content::PAGE_ZOOM_OUT); |
563 } | 573 } |
564 | 574 |
565 void GuestViewBase::HandleKeyboardEvent( | 575 void GuestViewBase::HandleKeyboardEvent( |
566 WebContents* source, | 576 WebContents* source, |
567 const content::NativeWebKeyboardEvent& event) { | 577 const content::NativeWebKeyboardEvent& event) { |
568 if (!attached()) | 578 if (!attached()) |
569 return; | 579 return; |
570 | 580 |
571 // Send the keyboard events back to the embedder to reprocess them. | 581 // Send the keyboard events back to the embedder to reprocess them. |
572 embedder_web_contents()->GetDelegate()-> | 582 embedder_web_contents()->GetDelegate()-> |
573 HandleKeyboardEvent(embedder_web_contents(), event); | 583 HandleKeyboardEvent(embedder_web_contents(), event); |
574 } | 584 } |
575 | 585 |
| 586 void GuestViewBase::LoadingStateChanged(content::WebContents* source, |
| 587 bool to_different_document) { |
| 588 if (!attached() || !embedder_web_contents()->GetDelegate()) |
| 589 return; |
| 590 |
| 591 embedder_web_contents()->GetDelegate()->LoadingStateChanged( |
| 592 embedder_web_contents(), to_different_document); |
| 593 } |
| 594 |
576 void GuestViewBase::RunFileChooser(WebContents* web_contents, | 595 void GuestViewBase::RunFileChooser(WebContents* web_contents, |
577 const content::FileChooserParams& params) { | 596 const content::FileChooserParams& params) { |
578 if (!attached() || !embedder_web_contents()->GetDelegate()) | 597 if (!attached() || !embedder_web_contents()->GetDelegate()) |
579 return; | 598 return; |
580 | 599 |
581 embedder_web_contents()->GetDelegate()->RunFileChooser(web_contents, params); | 600 embedder_web_contents()->GetDelegate()->RunFileChooser(web_contents, params); |
582 } | 601 } |
583 | 602 |
584 bool GuestViewBase::ShouldFocusPageAfterCrash() { | 603 bool GuestViewBase::ShouldFocusPageAfterCrash() { |
585 // Focus is managed elsewhere. | 604 // Focus is managed elsewhere. |
(...skipping 12 matching lines...) Expand all Loading... |
598 const gfx::Size& pref_size) { | 617 const gfx::Size& pref_size) { |
599 // In theory it's not necessary to check IsPreferredSizeModeEnabled() because | 618 // In theory it's not necessary to check IsPreferredSizeModeEnabled() because |
600 // there will only be events if it was enabled in the first place. However, | 619 // there will only be events if it was enabled in the first place. However, |
601 // something else may have turned on preferred size mode, so double check. | 620 // something else may have turned on preferred size mode, so double check. |
602 DCHECK_EQ(web_contents(), target_web_contents); | 621 DCHECK_EQ(web_contents(), target_web_contents); |
603 if (IsPreferredSizeModeEnabled()) { | 622 if (IsPreferredSizeModeEnabled()) { |
604 OnPreferredSizeChanged(pref_size); | 623 OnPreferredSizeChanged(pref_size); |
605 } | 624 } |
606 } | 625 } |
607 | 626 |
| 627 void GuestViewBase::UpdateTargetURL(content::WebContents* source, |
| 628 const GURL& url) { |
| 629 if (!attached() || !embedder_web_contents()->GetDelegate()) |
| 630 return; |
| 631 |
| 632 embedder_web_contents()->GetDelegate()->UpdateTargetURL( |
| 633 embedder_web_contents(), url); |
| 634 } |
| 635 |
608 GuestViewBase::~GuestViewBase() { | 636 GuestViewBase::~GuestViewBase() { |
609 } | 637 } |
610 | 638 |
611 void GuestViewBase::OnZoomChanged( | 639 void GuestViewBase::OnZoomChanged( |
612 const ui_zoom::ZoomController::ZoomChangedEventData& data) { | 640 const ui_zoom::ZoomController::ZoomChangedEventData& data) { |
613 auto guest_zoom_controller = | 641 auto guest_zoom_controller = |
614 ui_zoom::ZoomController::FromWebContents(web_contents()); | 642 ui_zoom::ZoomController::FromWebContents(web_contents()); |
615 if (content::ZoomValuesEqual(data.new_zoom_level, | 643 if (content::ZoomValuesEqual(data.new_zoom_level, |
616 guest_zoom_controller->GetZoomLevel())) { | 644 guest_zoom_controller->GetZoomLevel())) { |
617 return; | 645 return; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 // static | 770 // static |
743 void GuestViewBase::RegisterGuestViewTypes() { | 771 void GuestViewBase::RegisterGuestViewTypes() { |
744 AppViewGuest::Register(); | 772 AppViewGuest::Register(); |
745 ExtensionOptionsGuest::Register(); | 773 ExtensionOptionsGuest::Register(); |
746 MimeHandlerViewGuest::Register(); | 774 MimeHandlerViewGuest::Register(); |
747 SurfaceWorkerGuest::Register(); | 775 SurfaceWorkerGuest::Register(); |
748 WebViewGuest::Register(); | 776 WebViewGuest::Register(); |
749 } | 777 } |
750 | 778 |
751 } // namespace extensions | 779 } // namespace extensions |
OLD | NEW |