OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 | 1187 |
1188 // The browser will allow us to go into fullscreen mode only when processing | 1188 // The browser will allow us to go into fullscreen mode only when processing |
1189 // a user gesture. This is guaranteed to work with in-process plugins and | 1189 // a user gesture. This is guaranteed to work with in-process plugins and |
1190 // out-of-process syncronous proxies, but might be an issue with Flash when | 1190 // out-of-process syncronous proxies, but might be an issue with Flash when |
1191 // it switches over from PPB_FlashFullscreen. | 1191 // it switches over from PPB_FlashFullscreen. |
1192 // TODO(polina, bbudge): make this work with asynchronous proxies. | 1192 // TODO(polina, bbudge): make this work with asynchronous proxies. |
1193 WebFrame* frame = container_->element().document().frame(); | 1193 WebFrame* frame = container_->element().document().frame(); |
1194 if (fullscreen && !frame->isProcessingUserGesture()) | 1194 if (fullscreen && !frame->isProcessingUserGesture()) |
1195 return false; | 1195 return false; |
1196 | 1196 |
1197 // Unbind current 2D or 3D graphics context. | |
1198 BindGraphics(pp_instance(), 0); | |
1199 | |
1200 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); | 1197 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); |
1201 desired_fullscreen_state_ = fullscreen; | 1198 desired_fullscreen_state_ = fullscreen; |
1202 | 1199 |
1203 if (fullscreen) { | 1200 if (fullscreen) { |
1204 // WebKit does not resize the plugin to fill the screen in fullscreen mode, | 1201 // WebKit does not resize the plugin to fill the screen in fullscreen mode, |
1205 // so we will tweak plugin's attributes to support the expected behavior. | 1202 // so we will tweak plugin's attributes to support the expected behavior. |
1206 KeepSizeAttributesBeforeFullscreen(); | 1203 KeepSizeAttributesBeforeFullscreen(); |
1207 SetSizeAttributesForFullscreen(); | 1204 SetSizeAttributesForFullscreen(); |
1208 container_->element().requestFullScreen(); | 1205 container_->element().requestFullScreen(); |
1209 } else { | 1206 } else { |
1210 container_->element().document().cancelFullScreen(); | 1207 container_->element().document().cancelFullScreen(); |
1211 } | 1208 } |
1212 if (!delay_report) { | |
1213 ReportGeometry(); | |
1214 } else { | |
1215 MessageLoop::current()->PostTask( | |
1216 FROM_HERE, base::Bind(&PluginInstance::ReportGeometry, this)); | |
1217 } | |
1218 return true; | 1209 return true; |
1219 } | 1210 } |
1220 | 1211 |
1221 void PluginInstance::FlashSetFullscreen(bool fullscreen, bool delay_report) { | 1212 void PluginInstance::FlashSetFullscreen(bool fullscreen, bool delay_report) { |
1222 // Keep a reference on the stack. See NOTE above. | 1213 // Keep a reference on the stack. See NOTE above. |
1223 scoped_refptr<PluginInstance> ref(this); | 1214 scoped_refptr<PluginInstance> ref(this); |
1224 | 1215 |
1225 // We check whether we are trying to switch to the state we're already going | 1216 // We check whether we are trying to switch to the state we're already going |
1226 // to (i.e. if we're already switching to fullscreen but the fullscreen | 1217 // to (i.e. if we're already switching to fullscreen but the fullscreen |
1227 // container isn't ready yet, don't do anything more). | 1218 // container isn't ready yet, don't do anything more). |
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2063 screen_size_for_fullscreen_ = gfx::Size(); | 2054 screen_size_for_fullscreen_ = gfx::Size(); |
2064 WebElement element = container_->element(); | 2055 WebElement element = container_->element(); |
2065 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2056 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
2066 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2057 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
2067 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2058 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
2068 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2059 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
2069 } | 2060 } |
2070 | 2061 |
2071 } // namespace ppapi | 2062 } // namespace ppapi |
2072 } // namespace webkit | 2063 } // namespace webkit |
OLD | NEW |