Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Side by Side Diff: chrome/browser/ui/autofill/save_card_bubble_controller.h

Issue 1396923003: Autofill: Replace "save credit card" infobar with a bubble (Views only). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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_SAVE_CARD_BUBBLE_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_H_
7
8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/timer/elapsed_timer.h"
11 #include "content/public/browser/web_contents_observer.h"
12
13 namespace autofill {
14
15 // Per-tab class to control the save credit card bubble and Omnibox icon.
16 //
17 // TODO(bondd): Add text strings so different dialog contents can be shown
18 // depending upon whether upstreaming is available.
19 class SaveCardBubbleController : public content::WebContentsObserver {
20 public:
21 explicit SaveCardBubbleController(content::WebContents* web_contents);
22 ~SaveCardBubbleController() override;
23
24 // |save_card_callback| will be invoked if/when the Save button is pressed.
25 void ShowBubble(const base::Closure& save_card_callback);
26
27 // Re-shows bubble that was already created with ShowBubble and then
28 // dismissed, for example by clicking outside of the bubble or changing tabs.
29 void ReshowBubble();
30
31 // Functions called by SaveCardBubbleView.
32 void OnSaveButton();
Evan Stade 2015/10/09 18:54:44 I like separating these out into another interface
bondd 2015/10/13 02:03:16 Sounds good. I'll do that.
33 void OnCancelButton();
34 void OnBubbleClosed();
35
36 // Returns true if Omnibox save credit card icon should be visible.
37 bool WantIconVisible() const;
38
39 // Returns true if Omnibox save credit card should be shown in its "toggled
40 // on" state.
41 bool WantIconToggled() const;
42
43 private:
44 enum State {
45 // There is no save card bubble or icon for the current site.
46 INACTIVE_STATE,
47
48 // Save card bubble is available for the current site but not visible.
49 BUBBLE_AVAILABLE_STATE,
50
51 // Save card bubble is visible.
52 BUBBLE_VISIBLE_STATE,
53 };
54
55 // Update the visibility and toggled state of the Omnibox save card icon.
56 void UpdateIcon();
57
58 // Reset back to INACTIVE_STATE. Gets rid of any existing bubble and hides
59 // the icon.
60 void Deactivate();
61
62 // Returns the time elapsed since |timer_| was initialized,
63 // or base::TimeDelta::Max() if |timer_| was not initialized.
64 base::TimeDelta Elapsed() const;
65
66 // content::WebContentsObserver:
67 void DidNavigateMainFrame(
68 const content::LoadCommittedDetails& details,
69 const content::FrameNavigateParams& params) override;
70
71 content::WebContents* web_contents_;
72
73 // Callback to run if user presses Save button in the bubble. Not valid in
74 // INACTIVE_STATE.
75 base::Closure save_card_callback_;
76
77 // Used to measure the amount of time on a page; if it's less than some
78 // reasonable limit, then don't close the bubble upon navigation.
79 scoped_ptr<base::ElapsedTimer> timer_;
80
81 State state_;
82
83 DISALLOW_COPY_AND_ASSIGN(SaveCardBubbleController);
84 };
85
86 } // namespace autofill
87
88 #endif // CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698