Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / autofill / autofill_dialog_sign_in_delegate.h
bloba8019ce44a52961fb78d5b660766c19e9e1ed977
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.
5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_SIGN_IN_DELEGATE_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_SIGN_IN_DELEGATE_H_
8 #include "base/basictypes.h"
9 #include "content/public/browser/web_contents_delegate.h"
10 #include "content/public/browser/web_contents_observer.h"
11 #include "ui/gfx/size.h"
13 namespace autofill {
15 class AutofillDialogView;
17 // AutofillDialogSignInDelegate provides a WebContentsDelegate and
18 // WebContentsObserver for the sign-in page in the autofill dialog. Allows the
19 // dialog to resize based on the size of the hosted web page.
20 // TODO(abodenha) It probably makes sense to move the NotificationObserver
21 // for detecting completed sign-in to this class instead of
22 // AutofillDialogControllerImpl.
23 class AutofillDialogSignInDelegate: public content::WebContentsDelegate,
24 public content::WebContentsObserver {
25 public:
26 AutofillDialogSignInDelegate(AutofillDialogView* dialog_view,
27 content::WebContents* dialog_web_contents,
28 content::WebContents* originating_web_contents,
29 const gfx::Size& minimum_size,
30 const gfx::Size& maximum_size);
32 // WebContentsDelegate implementation.
33 virtual void ResizeDueToAutoResize(content::WebContents* source,
34 const gfx::Size& preferred_size) OVERRIDE;
35 virtual content::WebContents* OpenURLFromTab(
36 content::WebContents* source,
37 const content::OpenURLParams& params) OVERRIDE;
38 virtual void AddNewContents(content::WebContents* source,
39 content::WebContents* new_contents,
40 WindowOpenDisposition disposition,
41 const gfx::Rect& initial_pos,
42 bool user_gesture,
43 bool* was_blocked) OVERRIDE;
45 // WebContentsObserver implementation.
46 virtual void RenderViewCreated(
47 content::RenderViewHost* render_view_host) OVERRIDE;
49 // Updates the size limits and enables auto-resize for this view.
50 void UpdateLimitsAndEnableAutoResize(const gfx::Size& minimum_size,
51 const gfx::Size& maximum_size);
53 private:
54 // Enables auto-resizing for this view, if possible, constrained to the latest
55 // minimum and maximum size allowed by the delegate.
56 void EnableAutoResize();
58 // The dialog view hosting this sign in page.
59 AutofillDialogView* const dialog_view_;
61 // The WebContents of the page that originated the dialog. Weak ptr, but
62 // guaranteed to outlive the dialog, since the dialog is tab-modal to those
63 // contents.
64 content::WebContents* const originating_web_contents_;
66 // The minimum and maximum sizes that the sign-in view may have.
67 gfx::Size minimum_size_;
68 gfx::Size maximum_size_;
70 DISALLOW_COPY_AND_ASSIGN(AutofillDialogSignInDelegate);
73 } // namespace autofill
75 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_SIGN_IN_DELEGATE_H_