autofill_dialog_sign_in_delegate.h 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#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
11namespace autofill {
12
13class AutofillDialogView;
14
15// AutofillDialogSignInDelegate provides a WebContentsDelegate and
16// WebContentsObserver for the sign-in page in the autofill dialog. Allows the
17// dialog to resize based on the size of the hosted web page.
18// TODO(abodenha) It probably makes sense to move the NotificationObserver
19// for detecting completed sign-in to this class instead of
20// AutofillDialogControllerImpl.
21class AutofillDialogSignInDelegate: public content::WebContentsDelegate,
22                                    public content::WebContentsObserver {
23 public:
24  AutofillDialogSignInDelegate(AutofillDialogView* dialog_view,
25                               content::WebContents* web_contents);
26
27  // WebContentsDelegate implementation.
28  virtual void ResizeDueToAutoResize(content::WebContents* source,
29                                     const gfx::Size& pref_size) OVERRIDE;
30
31  // WebContentsObserver implementation.
32  virtual void RenderViewCreated(
33      content::RenderViewHost* render_view_host) OVERRIDE;
34
35  // Sets the minimum width for the render view. This should be set to the
36  // width of the host AutofillDialogView.
37  void SetMinWidth(int width);
38
39 private:
40  // Gets the minimum and maximum size for the dialog.
41  gfx::Size GetMinSize() const;
42  gfx::Size GetMaxSize() const;
43
44  AutofillDialogView* dialog_view_;
45  int min_width_;
46};
47
48}  // namespace autofill
49
50#endif  // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_SIGN_IN_DELEGATE_H_
51