autofill_dialog_sign_in_delegate.h revision 4e180b6a0b4720a9b8e9e959a882386f690f08ff
1// Copyright 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#ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_SIGN_IN_DELEGATE_H_ 6#define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_SIGN_IN_DELEGATE_H_ 7 8#include "content/public/browser/web_contents_delegate.h" 9#include "content/public/browser/web_contents_observer.h" 10#include "ui/gfx/size.h" 11 12namespace autofill { 13 14class AutofillDialogView; 15 16// AutofillDialogSignInDelegate provides a WebContentsDelegate and 17// WebContentsObserver for the sign-in page in the autofill dialog. Allows the 18// dialog to resize based on the size of the hosted web page. 19// TODO(abodenha) It probably makes sense to move the NotificationObserver 20// for detecting completed sign-in to this class instead of 21// AutofillDialogControllerImpl. 22class AutofillDialogSignInDelegate: public content::WebContentsDelegate, 23 public content::WebContentsObserver { 24 public: 25 AutofillDialogSignInDelegate(AutofillDialogView* dialog_view, 26 content::WebContents* web_contents, 27 content::WebContentsDelegate* wrapped_delegate, 28 const gfx::Size& minimum_size, 29 const gfx::Size& maximum_size); 30 31 // WebContentsDelegate implementation. 32 virtual void ResizeDueToAutoResize(content::WebContents* source, 33 const gfx::Size& preferred_size) OVERRIDE; 34 virtual content::WebContents* OpenURLFromTab( 35 content::WebContents* source, 36 const content::OpenURLParams& params) OVERRIDE; 37 virtual void AddNewContents(content::WebContents* source, 38 content::WebContents* new_contents, 39 WindowOpenDisposition disposition, 40 const gfx::Rect& initial_pos, 41 bool user_gesture, 42 bool* was_blocked) OVERRIDE; 43 44 // WebContentsObserver implementation. 45 virtual void RenderViewCreated( 46 content::RenderViewHost* render_view_host) OVERRIDE; 47 48 // Updates the size limits and enables auto-resize for this view. 49 void UpdateLimitsAndEnableAutoResize(const gfx::Size& minimum_size, 50 const gfx::Size& maximum_size); 51 52 private: 53 // Enables auto-resizing for this view, if possible, constrained to the latest 54 // minimum and maximum size allowed by the delegate. 55 void EnableAutoResize(); 56 57 // The dialog view hosting this sign in page. 58 AutofillDialogView* const dialog_view_; 59 60 // The delegate for the WebContents hosting this dialog. 61 content::WebContentsDelegate* const wrapped_delegate_; 62 63 // The minimum and maximum sizes that the sign-in view may have. 64 gfx::Size minimum_size_; 65 gfx::Size maximum_size_; 66}; 67 68} // namespace autofill 69 70#endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_SIGN_IN_DELEGATE_H_ 71