summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h
blob: 250a2357f09e6ddd0478c4fc25e86b29fde635b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DIALOG_COCOA_H_
#define CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DIALOG_COCOA_H_

#include "base/mac/scoped_nsobject.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/autofill/autofill_dialog_types.h"
#include "chrome/browser/ui/autofill/autofill_dialog_view.h"
#include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
#include "ui/gfx/geometry/size.h"

namespace content {
class NavigationController;
}

namespace autofill {
class AutofillDialogViewDelegate;
class AutofillDialogViewTesterCocoa;
}

@class AutofillDialogWindowController;

namespace autofill {

class AutofillDialogCocoa : public AutofillDialogView,
                            public ConstrainedWindowMacDelegate {
 public:
  explicit AutofillDialogCocoa(AutofillDialogViewDelegate* delegate);
  ~AutofillDialogCocoa() override;

  // AutofillDialogView implementation:
  void Show() override;
  void Hide() override;
  void UpdatesStarted() override;
  void UpdatesFinished() override;
  void UpdateAccountChooser() override;
  void UpdateButtonStrip() override;
  void UpdateOverlay() override;
  void UpdateDetailArea() override;
  void UpdateForErrors() override;
  void UpdateNotificationArea() override;
  void UpdateSection(DialogSection section) override;
  void UpdateErrorBubble() override;
  void FillSection(DialogSection section,
                   ServerFieldType originating_type) override;
  void GetUserInput(DialogSection section, FieldValueMap* output) override;
  base::string16 GetCvc() override;
  bool SaveDetailsLocally() override;
  const content::NavigationController* ShowSignIn(const GURL& url) override;
  void HideSignIn() override;
  void ModelChanged() override;
  void OnSignInResize(const gfx::Size& pref_size) override;
  void ValidateSection(DialogSection section) override;

  // ConstrainedWindowMacDelegate implementation:
  void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override;

  AutofillDialogViewDelegate* delegate() { return delegate_; }

  // Posts a close request on the current message loop.
  void PerformClose();

 private:
  friend class AutofillDialogViewTesterCocoa;

  // Closes the sheet and ends the modal loop. Triggers cleanup sequence.
  void CloseNow();

  scoped_ptr<ConstrainedWindowMac> constrained_window_;
  base::scoped_nsobject<AutofillDialogWindowController> sheet_delegate_;

  // The delegate |this| queries for logic and state.
  AutofillDialogViewDelegate* delegate_;

  // WeakPtrFactory for deferred close.
  base::WeakPtrFactory<AutofillDialogCocoa> close_weak_ptr_factory_;

};

}  // autofill

#endif  // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DIALOG_COCOA_H_