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

Side by Side Diff: chrome/browser/ui/views/sync/one_click_signin_bubble_view.h

Issue 13979003: Win: Display a native bubble (instead of the JS one) after the web signin flow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Lint + review fixes Created 7 years, 8 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_
7 7
8 #include <string>
9
8 #include "base/basictypes.h" 10 #include "base/basictypes.h"
9 #include "base/callback.h" 11 #include "base/callback.h"
10 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
11 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
12 #include "base/string16.h" 14 #include "base/string16.h"
13 #include "chrome/browser/ui/browser_window.h" 15 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/browser/ui/views/toolbar_view.h" 16 #include "chrome/browser/ui/views/toolbar_view.h"
15 #include "ui/views/bubble/bubble_delegate.h" 17 #include "ui/views/bubble/bubble_delegate.h"
16 #include "ui/views/controls/button/button.h" 18 #include "ui/views/controls/button/button.h"
17 #include "ui/views/controls/link_listener.h" 19 #include "ui/views/controls/link_listener.h"
(...skipping 13 matching lines...) Expand all
31 class OneClickSigninBubbleView : public views::BubbleDelegateView, 33 class OneClickSigninBubbleView : public views::BubbleDelegateView,
32 public views::LinkListener, 34 public views::LinkListener,
33 public views::ButtonListener { 35 public views::ButtonListener {
34 public: 36 public:
35 // Show the one-click signin bubble if not already showing. The bubble 37 // Show the one-click signin bubble if not already showing. The bubble
36 // will be placed visually beneath |anchor_view|. |start_sync| is called 38 // will be placed visually beneath |anchor_view|. |start_sync| is called
37 // to start sync. 39 // to start sync.
38 static void ShowBubble(BrowserWindow::OneClickSigninBubbleType type, 40 static void ShowBubble(BrowserWindow::OneClickSigninBubbleType type,
39 const string16& email, 41 const string16& email,
40 ToolbarView* toolbar_view, 42 ToolbarView* toolbar_view,
41 const BrowserWindow::StartSyncCallback& start_sync); 43 const BrowserWindow::StartSyncCallback& start_sync,
44 const std::string& error_message);
42 45
43 static bool IsShowing(); 46 static bool IsShowing();
44 47
45 static void Hide(); 48 static void Hide();
46 49
47 // Gets the global bubble view. If its not showing returns NULL. This 50 // Gets the global bubble view. If its not showing returns NULL. This
48 // method is meant to be called only from tests. 51 // method is meant to be called only from tests.
49 static OneClickSigninBubbleView* view_for_testing() { return bubble_view_; } 52 static OneClickSigninBubbleView* view_for_testing() { return bubble_view_; }
50 53
51 protected: 54 protected:
52 // Creates a OneClickSigninBubbleView. 55 // Creates a OneClickSigninBubbleView.
53 OneClickSigninBubbleView( 56 OneClickSigninBubbleView(
57 content::WebContents* web_content,
54 views::View* anchor_view, 58 views::View* anchor_view,
55 const BrowserWindow::StartSyncCallback& start_sync_callback); 59 const std::string& error_message);
56 60
57 virtual ~OneClickSigninBubbleView(); 61 virtual ~OneClickSigninBubbleView();
58 62
59 // Overridden from views::LinkListener: 63 // Overridden from views::LinkListener:
60 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; 64 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
61 65
62 // Overridden from views::ButtonListener: 66 // Overridden from views::ButtonListener:
63 virtual void ButtonPressed(views::Button* sender, 67 virtual void ButtonPressed(views::Button* sender,
64 const ui::Event& event) OVERRIDE; 68 const ui::Event& event) OVERRIDE;
65 69
70 // views::View method:
71 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
72
73 // Creates learn more link to be used at the bottom of the bubble.
74 // Derived classes can reimplement. The caller of this function owns the
75 // returned link.
76 virtual views::Link* GetLearnMoreLink();
77
78 // Creates advanced link to be used at the bottom of the bubble.
79 // Derived classes can reimplement. The caller of this function owns the
80 // returned link.
81 virtual views::Link* GetAdvancedLink();
Roger Tawa OOO till Jul 10th 2013/04/17 17:53:25 The GetXXXLink() methods should probably moved bel
noms (inactive) 2013/04/17 20:32:37 Moved all of them to private as I killed the silly
82
83 // views::WidgetDelegate method:
84 virtual void WindowClosing() OVERRIDE;
85
86 // Link to sync setup advanced page.
87 views::Link* advanced_link_;
88
89 // Link to the Learn More details page
90 views::Link* learn_more_link_;
91
92 // Controls at bottom of bubble.
93 views::LabelButton* ok_button_;
94 views::LabelButton* undo_button_;
95
96 content::WebContents* web_content_;
Roger Tawa OOO till Jul 10th 2013/04/17 17:53:25 Member variables should always be private. Might
noms (inactive) 2013/04/17 20:32:37 Done.
97
66 private: 98 private:
67 friend class OneClickSigninBubbleViewBrowserTest; 99 friend class OneClickSigninBubbleViewBrowserTest;
68 100
69 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewBrowserTest, OkButton); 101 FRIEND_TEST_ALL_PREFIXES(
70 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewBrowserTest, UndoButton); 102 OneClickSigninBubbleViewBrowserTest, BubbleOkButton);
71 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewBrowserTest, AdvancedLink); 103 FRIEND_TEST_ALL_PREFIXES(
72 104 OneClickSigninBubbleViewBrowserTest, DialogOkButton);
105 FRIEND_TEST_ALL_PREFIXES(
106 OneClickSigninBubbleViewBrowserTest, DialogUndoButton);
107 FRIEND_TEST_ALL_PREFIXES(
108 OneClickSigninBubbleViewBrowserTest, BubbleAdvancedLink);
109 FRIEND_TEST_ALL_PREFIXES(
110 OneClickSigninBubbleViewBrowserTest, DialogAdvancedLink);
111 FRIEND_TEST_ALL_PREFIXES(
112 OneClickSigninBubbleViewBrowserTest, BubbleLearnMoreLink);
113 FRIEND_TEST_ALL_PREFIXES(
114 OneClickSigninBubbleViewBrowserTest, DialogLearnMoreLink);
73 // views::BubbleDelegateView methods: 115 // views::BubbleDelegateView methods:
74 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; 116 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
75 virtual void Init() OVERRIDE; 117 virtual void Init() OVERRIDE;
76 118
77 // Method to build the main part of the bubble. Derived classes should 119 // Method to build the main part of the bubble. Derived classes should
78 // reimplement this function. 120 // reimplement this function.
79 virtual void InitContent(views::GridLayout* layout); 121 virtual void InitContent(views::GridLayout* layout);
122 virtual void InitButtons(views::GridLayout* layout);
80 123
81 // Creates OK and Undo buttons to be used at the bottom of the bubble. 124 // Creates OK/Undo button to be used at the bottom of the bubble.
125 // By default, the Undo button is initialized, but not displayed
82 // Derived classes can reimplement to have buttons with different labels, 126 // Derived classes can reimplement to have buttons with different labels,
83 // colours, or sizes. The caller of this function owns the returned buttons. 127 // colours, or sizes. The caller of this function owns the returned buttons.
84 virtual void GetButtons(views::LabelButton** ok_button, 128 virtual void GetButtons(views::LabelButton** ok_button,
85 views::LabelButton** undo_button); 129 views::LabelButton** undo_button);
86 130
87 // Creates advanced link to be used at the bottom of the bubble.
88 // Derived classes can reimplement. The caller of this function owns the
89 // returned link.
90 virtual views::Link* GetAdvancedLink();
91
92 // views::WidgetDelegate method:
93 virtual void WindowClosing() OVERRIDE;
94
95 // views::View method:
96 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
97
98 // The bubble, if we're showing one. 131 // The bubble, if we're showing one.
99 static OneClickSigninBubbleView* bubble_view_; 132 static OneClickSigninBubbleView* bubble_view_;
100 133
101 // Link to sync setup advanced page.
102 views::Link* advanced_link_;
103
104 // Controls at bottom of bubble.
105 views::LabelButton* ok_button_;
106 views::LabelButton* undo_button_;
107
108 // This callback is nulled once its called, so that it is called only once.
109 // It will be called when the bubble is closed if it has not been called
110 // and nulled earlier.
111 BrowserWindow::StartSyncCallback start_sync_callback_;
112
113 // A message loop used only with unit tests. 134 // A message loop used only with unit tests.
114 base::MessageLoop* message_loop_for_testing_; 135 base::MessageLoop* message_loop_for_testing_;
115 136
137 // Alternate error message to be displayed
138 std::string error_message_;
139
116 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleView); 140 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleView);
117 }; 141 };
118 142
119 #endif // CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ 143 #endif // CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698