37119f9b271c6e652f72d8fdca520f6e624e92d3
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / cocoa / autofill / autofill_dialog_cocoa.h
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_COCOA_AUTOFILL_AUTOFILL_DIALOG_COCOA_H_
6 #define CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DIALOG_COCOA_H_
7
8 #include "base/mac/scoped_nsobject.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
12 #include "chrome/browser/ui/autofill/autofill_dialog_view.h"
13 #include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h"
14 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
15 #include "ui/gfx/size.h"
16
17 namespace content {
18 class NavigationController;
19 }
20
21 namespace autofill {
22 class AutofillDialogViewDelegate;
23 }
24
25 @class AutofillDialogWindowController;
26
27 namespace autofill {
28
29 class AutofillDialogCocoa : public AutofillDialogView,
30                             public TestableAutofillDialogView,
31                             public ConstrainedWindowMacDelegate {
32  public:
33   explicit AutofillDialogCocoa(AutofillDialogViewDelegate* delegate);
34   virtual ~AutofillDialogCocoa();
35
36   // AutofillDialogView implementation:
37   virtual void Show() OVERRIDE;
38   virtual void Hide() OVERRIDE;
39   virtual void UpdatesStarted() OVERRIDE;
40   virtual void UpdatesFinished() OVERRIDE;
41   virtual void UpdateAccountChooser() OVERRIDE;
42   virtual void UpdateButtonStrip() OVERRIDE;
43   virtual void UpdateOverlay() OVERRIDE;
44   virtual void UpdateDetailArea() OVERRIDE;
45   virtual void UpdateForErrors() OVERRIDE;
46   virtual void UpdateNotificationArea() OVERRIDE;
47   virtual void UpdateSection(DialogSection section) OVERRIDE;
48   virtual void UpdateErrorBubble() OVERRIDE;
49   virtual void FillSection(DialogSection section,
50                            ServerFieldType originating_type) OVERRIDE;
51   virtual void GetUserInput(DialogSection section,
52                             FieldValueMap* output) OVERRIDE;
53   virtual base::string16 GetCvc() OVERRIDE;
54   virtual bool HitTestInput(ServerFieldType type,
55                             const gfx::Point& screen_point) OVERRIDE;
56   virtual bool SaveDetailsLocally() OVERRIDE;
57   virtual const content::NavigationController* ShowSignIn() OVERRIDE;
58   virtual void HideSignIn() OVERRIDE;
59   virtual void ModelChanged() OVERRIDE;
60   virtual TestableAutofillDialogView* GetTestableView() OVERRIDE;
61   virtual void OnSignInResize(const gfx::Size& pref_size) OVERRIDE;
62
63   // TestableAutofillDialogView implementation:
64   // TODO(groby): Create a separate class to implement the testable interface:
65   // http://crbug.com/256864
66   virtual void SubmitForTesting() OVERRIDE;
67   virtual void CancelForTesting() OVERRIDE;
68   virtual base::string16 GetTextContentsOfInput(ServerFieldType type) OVERRIDE;
69   virtual void SetTextContentsOfInput(ServerFieldType type,
70                                       const base::string16& contents) OVERRIDE;
71   virtual void SetTextContentsOfSuggestionInput(
72       DialogSection section,
73       const base::string16& text) OVERRIDE;
74   virtual void ActivateInput(ServerFieldType type) OVERRIDE;
75   virtual gfx::Size GetSize() const OVERRIDE;
76   virtual content::WebContents* GetSignInWebContents() OVERRIDE;
77   virtual bool IsShowingOverlay() const OVERRIDE;
78
79   // ConstrainedWindowMacDelegate implementation:
80   virtual void OnConstrainedWindowClosed(
81       ConstrainedWindowMac* window) OVERRIDE;
82
83   AutofillDialogViewDelegate* delegate() { return delegate_; }
84
85   // Posts a close request on the current message loop.
86   void PerformClose();
87
88  private:
89   // Closes the sheet and ends the modal loop. Triggers cleanup sequence.
90   void CloseNow();
91
92   scoped_ptr<ConstrainedWindowMac> constrained_window_;
93   base::scoped_nsobject<AutofillDialogWindowController> sheet_delegate_;
94
95   // WeakPtrFactory for deferred close.
96   base::WeakPtrFactory<AutofillDialogCocoa> close_weak_ptr_factory_;
97
98   // The delegate |this| queries for logic and state.
99   AutofillDialogViewDelegate* delegate_;
100 };
101
102 }  // autofill
103
104 #endif  // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DIALOG_COCOA_H_