Home | History | Annotate | Download | only in autofill
      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/cocoa/constrained_window/constrained_window_mac.h"
     14 #include "ui/gfx/size.h"
     15 
     16 namespace content {
     17 class NavigationController;
     18 }
     19 
     20 namespace autofill {
     21 class AutofillDialogViewDelegate;
     22 class AutofillDialogViewTesterCocoa;
     23 }
     24 
     25 @class AutofillDialogWindowController;
     26 
     27 namespace autofill {
     28 
     29 class AutofillDialogCocoa : public AutofillDialogView,
     30                             public ConstrainedWindowMacDelegate {
     31  public:
     32   explicit AutofillDialogCocoa(AutofillDialogViewDelegate* delegate);
     33   virtual ~AutofillDialogCocoa();
     34 
     35   // AutofillDialogView implementation:
     36   virtual void Show() OVERRIDE;
     37   virtual void Hide() OVERRIDE;
     38   virtual void UpdatesStarted() OVERRIDE;
     39   virtual void UpdatesFinished() OVERRIDE;
     40   virtual void UpdateAccountChooser() OVERRIDE;
     41   virtual void UpdateButtonStrip() OVERRIDE;
     42   virtual void UpdateOverlay() OVERRIDE;
     43   virtual void UpdateDetailArea() OVERRIDE;
     44   virtual void UpdateForErrors() OVERRIDE;
     45   virtual void UpdateNotificationArea() OVERRIDE;
     46   virtual void UpdateSection(DialogSection section) OVERRIDE;
     47   virtual void UpdateErrorBubble() OVERRIDE;
     48   virtual void FillSection(DialogSection section,
     49                            ServerFieldType originating_type) OVERRIDE;
     50   virtual void GetUserInput(DialogSection section,
     51                             FieldValueMap* output) OVERRIDE;
     52   virtual base::string16 GetCvc() OVERRIDE;
     53   virtual bool SaveDetailsLocally() OVERRIDE;
     54   virtual const content::NavigationController* ShowSignIn() OVERRIDE;
     55   virtual void HideSignIn() OVERRIDE;
     56   virtual void ModelChanged() OVERRIDE;
     57   virtual void OnSignInResize(const gfx::Size& pref_size) OVERRIDE;
     58   virtual void ValidateSection(DialogSection section) OVERRIDE;
     59 
     60   // ConstrainedWindowMacDelegate implementation:
     61   virtual void OnConstrainedWindowClosed(
     62       ConstrainedWindowMac* window) OVERRIDE;
     63 
     64   AutofillDialogViewDelegate* delegate() { return delegate_; }
     65 
     66   // Posts a close request on the current message loop.
     67   void PerformClose();
     68 
     69  private:
     70   friend class AutofillDialogViewTesterCocoa;
     71 
     72   // Closes the sheet and ends the modal loop. Triggers cleanup sequence.
     73   void CloseNow();
     74 
     75   scoped_ptr<ConstrainedWindowMac> constrained_window_;
     76   base::scoped_nsobject<AutofillDialogWindowController> sheet_delegate_;
     77 
     78   // WeakPtrFactory for deferred close.
     79   base::WeakPtrFactory<AutofillDialogCocoa> close_weak_ptr_factory_;
     80 
     81   // The delegate |this| queries for logic and state.
     82   AutofillDialogViewDelegate* delegate_;
     83 };
     84 
     85 }  // autofill
     86 
     87 #endif  // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DIALOG_COCOA_H_
     88