autofill_dialog_sign_in_delegate.cc revision eb525c5499e34cc9c4b825d6d9e75bb07cc06ace
1// Copyright (c) 2013 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "chrome/browser/ui/autofill/autofill_dialog_sign_in_delegate.h" 6 7#include "chrome/browser/ui/autofill/autofill_dialog_view.h" 8#include "content/public/browser/render_view_host.h" 9#include "content/public/browser/web_contents.h" 10 11namespace autofill { 12 13AutofillDialogSignInDelegate::AutofillDialogSignInDelegate( 14 AutofillDialogView* dialog_view, 15 content::WebContents* web_contents) 16 : WebContentsObserver(web_contents), 17 dialog_view_(dialog_view), 18 min_width_(400) { 19 web_contents->SetDelegate(this); 20} 21 22void AutofillDialogSignInDelegate::ResizeDueToAutoResize( 23 content::WebContents* source, const gfx::Size& pref_size) { 24 dialog_view_->OnSignInResize(pref_size); 25} 26 27void AutofillDialogSignInDelegate::RenderViewCreated( 28 content::RenderViewHost* render_view_host) { 29 SetMinWidth(min_width_); 30 31 // Set the initial size as soon as we have an RVH to avoid 32 // bad size jumping. 33 dialog_view_->OnSignInResize(GetMinSize()); 34} 35 36void AutofillDialogSignInDelegate::SetMinWidth(int width) { 37 min_width_ = width; 38 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); 39 if (host) 40 host->EnableAutoResize(GetMinSize(), GetMaxSize()); 41} 42 43gfx::Size AutofillDialogSignInDelegate::GetMinSize() const { 44 return gfx::Size(min_width_, 331); 45} 46 47gfx::Size AutofillDialogSignInDelegate::GetMaxSize() const { 48 return gfx::Size(std::max(min_width_, 800), 600); 49} 50 51} // namespace autofill 52