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

Unified Diff: chrome/browser/ui/autofill/save_card_bubble_controller_impl.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: Change object lifecycles + add interface classes. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/autofill/save_card_bubble_controller_impl.h
diff --git a/chrome/browser/ui/autofill/save_card_bubble_controller_impl.h b/chrome/browser/ui/autofill/save_card_bubble_controller_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..4133dae74589d0a79d421dea249480c2bdc3c5d2
--- /dev/null
+++ b/chrome/browser/ui/autofill/save_card_bubble_controller_impl.h
@@ -0,0 +1,92 @@
+// Copyright 2015 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_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_
+#define CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "base/timer/elapsed_timer.h"
+#include "components/autofill/core/browser/ui/save_card_bubble_controller.h"
+#include "content/public/browser/web_contents_observer.h"
+#include "content/public/browser/web_contents_user_data.h"
+
+namespace autofill {
+
+// Implementation of per-tab class to control the save credit card bubble and
+// Omnibox icon.
+//
+// TODO(bondd): Add text strings so different dialog contents can be shown
+// depending upon whether upstreaming is available.
+class SaveCardBubbleControllerImpl
+ : public SaveCardBubbleController,
+ public content::WebContentsObserver,
+ public content::WebContentsUserData<SaveCardBubbleControllerImpl> {
+ public:
+ // SaveCardBubbleController
+ void CreateBubble(const base::Closure& save_card_callback) override;
+ void ShowBubble() override;
+
+ void OnSaveButton() override;
+ void OnCancelButton() override;
+ void OnBubbleClosed() override;
+
+ bool IsIconVisible() const override;
+ bool IsIconToggled() const override;
+
+ SaveCardBubbleView* save_card_bubble_view() const override;
+
+ private:
+ friend class content::WebContentsUserData<SaveCardBubbleControllerImpl>;
+
+ enum State {
+ // There is no save card bubble or icon for the current site.
+ INACTIVE_STATE,
+
+ // Save card bubble is available for the current site but not visible.
+ BUBBLE_AVAILABLE_STATE,
+
+ // Save card bubble is visible.
+ BUBBLE_VISIBLE_STATE,
+ };
+
+ explicit SaveCardBubbleControllerImpl(content::WebContents* web_contents);
+ ~SaveCardBubbleControllerImpl() override;
+
+ // Update the visibility and toggled state of the Omnibox save card icon.
+ void UpdateIcon();
+
+ // Reset back to INACTIVE_STATE. Gets rid of any existing bubble and hides
+ // the icon.
+ void Deactivate();
+
+ // Returns the time elapsed since |timer_| was initialized,
+ // or base::TimeDelta::Max() if |timer_| was not initialized.
+ base::TimeDelta Elapsed() const;
+
+ // content::WebContentsObserver:
+ void DidNavigateMainFrame(
+ const content::LoadCommittedDetails& details,
+ const content::FrameNavigateParams& params) override;
+
+ content::WebContents* web_contents_;
+
+ // Will be nullptr if no bubble is currently shown.
+ SaveCardBubbleView* save_card_bubble_view_;
+
+ // Callback to run if user presses Save button in the bubble. Not valid in
+ // INACTIVE_STATE.
+ base::Closure save_card_callback_;
+
+ // Used to measure the amount of time on a page; if it's less than some
+ // reasonable limit, then don't close the bubble upon navigation.
+ scoped_ptr<base::ElapsedTimer> timer_;
+
+ State state_;
Evan Stade 2015/10/16 01:20:44 instead of having this redundant information, chec
Evan Stade 2015/10/16 01:20:44 probably don't need this var, can just check other
bondd 2015/10/22 02:15:17 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(SaveCardBubbleControllerImpl);
+};
+
+} // namespace autofill
+
+#endif // CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_BUBBLE_CONTROLLER_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698