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

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

Issue 984963004: <webview>: Implement fullscreen permission for html5 element.requestFullscreen() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tmptmptmp
Patch Set: Created 5 years, 9 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 "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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 73
74 // This observer ensures that the GuestViewBase destroys itself when its 74 // This observer ensures that the GuestViewBase destroys itself when its
75 // embedder goes away. 75 // embedder goes away.
76 class GuestViewBase::OwnerLifetimeObserver : public WebContentsObserver { 76 class GuestViewBase::OwnerLifetimeObserver : public WebContentsObserver {
77 public: 77 public:
78 OwnerLifetimeObserver(GuestViewBase* guest, 78 OwnerLifetimeObserver(GuestViewBase* guest,
79 content::WebContents* embedder_web_contents) 79 content::WebContents* embedder_web_contents)
80 : WebContentsObserver(embedder_web_contents), 80 : WebContentsObserver(embedder_web_contents),
81 destroyed_(false), 81 destroyed_(false),
82 guest_(guest) {} 82 guest_(guest),
83 fullscreen_(false) {}
83 84
84 ~OwnerLifetimeObserver() override {} 85 ~OwnerLifetimeObserver() override {}
85 86
87 void DidToggleFullscreenModeForTab(
88 bool entered_fullscreen) override {
89 fullscreen_ = entered_fullscreen;
90 printf("+++++ %s, entered_fullscreen: %d\n",
91 __PRETTY_FUNCTION__, entered_fullscreen);
92 guest_->EmbedderFullscreenToggled(fullscreen_);
93 }
94
95 void MainFrameWasResized(bool width_changed) override {
96 printf("EMB::MainFrameWasResized\n");
97 printf("Will call EMB::IsFullscreenForTabOrPending\n");
98 bool is_f =
99 web_contents()->GetDelegate()->IsFullscreenForTabOrPending(
100 web_contents());
101 printf("Called EMB::IsFullscreenForTabOrPending\n");
102 if (fullscreen_ && !is_f) {
103 // web_contents()->GetDelegate()->IsFullscreenForTabOrPending(
104 // web_contents())) {
105 fullscreen_ = false;
106 guest_->EmbedderFullscreenToggled(fullscreen_);
107 }
108 }
109
86 // WebContentsObserver implementation. 110 // WebContentsObserver implementation.
87 void WebContentsDestroyed() override { 111 void WebContentsDestroyed() override {
88 // If the embedder is destroyed then destroy the guest. 112 // If the embedder is destroyed then destroy the guest.
89 Destroy(); 113 Destroy();
90 } 114 }
91 115
92 void DidNavigateMainFrame( 116 void DidNavigateMainFrame(
93 const content::LoadCommittedDetails& details, 117 const content::LoadCommittedDetails& details,
94 const content::FrameNavigateParams& params) override { 118 const content::FrameNavigateParams& params) override {
95 // If the embedder navigates to a different page then destroy the guest. 119 // If the embedder navigates to a different page then destroy the guest.
96 if (details.is_navigation_to_different_page()) 120 if (details.is_navigation_to_different_page())
97 Destroy(); 121 Destroy();
98 } 122 }
99 123
100 void RenderProcessGone(base::TerminationStatus status) override { 124 void RenderProcessGone(base::TerminationStatus status) override {
101 // If the embedder crashes, then destroy the guest. 125 // If the embedder crashes, then destroy the guest.
102 Destroy(); 126 Destroy();
103 } 127 }
104 128
105 private: 129 private:
106 bool destroyed_; 130 bool destroyed_;
107 GuestViewBase* guest_; 131 GuestViewBase* guest_;
132 bool fullscreen_;
108 133
109 void Destroy() { 134 void Destroy() {
110 if (destroyed_) 135 if (destroyed_)
111 return; 136 return;
112 137
113 destroyed_ = true; 138 destroyed_ = true;
114 guest_->EmbedderWillBeDestroyed(); 139 guest_->EmbedderWillBeDestroyed();
115 guest_->Destroy(); 140 guest_->Destroy();
116 } 141 }
117 142
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 void GuestViewBase::RegisterGuestViewTypes() { 838 void GuestViewBase::RegisterGuestViewTypes() {
814 AppViewGuest::Register(); 839 AppViewGuest::Register();
815 ExtensionOptionsGuest::Register(); 840 ExtensionOptionsGuest::Register();
816 ExtensionViewGuest::Register(); 841 ExtensionViewGuest::Register();
817 MimeHandlerViewGuest::Register(); 842 MimeHandlerViewGuest::Register();
818 SurfaceWorkerGuest::Register(); 843 SurfaceWorkerGuest::Register();
819 WebViewGuest::Register(); 844 WebViewGuest::Register();
820 } 845 }
821 846
822 } // namespace extensions 847 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698