11e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 21e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 31e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// found in the LICENSE file. 41e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 51e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "content/renderer/resizing_mode_selector.h" 61e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 71e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "content/common/view_messages.h" 81e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "content/renderer/render_thread_impl.h" 91e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "content/renderer/render_widget.h" 10f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "third_party/WebKit/public/platform/WebScreenInfo.h" 111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)namespace content { 131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 14f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)ResizingModeSelector::ResizingModeSelector() : is_synchronous_mode_(false) {} 15f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 16f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)bool ResizingModeSelector::NeverUsesSynchronousResize() const { 17f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) return !RenderThreadImpl::current() || // can be NULL when in unit tests 18f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) !RenderThreadImpl::current()->layout_test_mode(); 191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} 201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)bool ResizingModeSelector::ShouldAbortOnResize( 221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) RenderWidget* widget, 231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) const ViewMsg_Resize_Params& params) { 241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return is_synchronous_mode_ && 251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) params.is_fullscreen == widget->is_fullscreen() && 261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) params.screen_info.deviceScaleFactor == 271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) widget->screenInfo().deviceScaleFactor; 281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} 291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)void ResizingModeSelector::set_is_synchronous_mode(bool mode) { 31f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) is_synchronous_mode_ = mode; 321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} 331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)bool ResizingModeSelector::is_synchronous_mode() const { 351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return is_synchronous_mode_; 361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} 371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} // namespace content 39