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

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

Issue 18558009: Fix flaky test OneClickSigninBubbleViewBrowserTest::ShowBubble (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years, 4 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 "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
13 #include "chrome/browser/ui/browser_window.h" 14 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/browser/ui/views/toolbar_view.h" 15 #include "chrome/browser/ui/sync/one_click_signin_bubble_delegate.h"
15 #include "ui/views/bubble/bubble_delegate.h" 16 #include "ui/views/bubble/bubble_delegate.h"
16 #include "ui/views/controls/button/button.h" 17 #include "ui/views/controls/button/button.h"
17 #include "ui/views/controls/link_listener.h" 18 #include "ui/views/controls/link_listener.h"
18 19
19 namespace base { 20 namespace base {
20 class MessageLoop; 21 class MessageLoop;
21 } 22 }
22 23
23 namespace views { 24 namespace views {
24 class GridLayout; 25 class GridLayout;
26 class ImageButton;
25 class LabelButton; 27 class LabelButton;
28 class View;
26 } 29 }
27 30
28 // OneClickSigninBubbleView is a view intended to be used as the content of an 31 // OneClickSigninBubbleView is a view intended to be used as the content of an
29 // Bubble. It provides simple and concise feedback to the user that sync'ing 32 // Bubble. It provides simple and concise feedback to the user that sync'ing
30 // has started after using the one-click singin infobar. 33 // has started after using the one-click singin infobar.
31 class OneClickSigninBubbleView : public views::BubbleDelegateView, 34 class OneClickSigninBubbleView : public views::BubbleDelegateView,
32 public views::LinkListener, 35 public views::LinkListener,
33 public views::ButtonListener { 36 public views::ButtonListener {
34 public: 37 public:
35 // Show the one-click signin bubble if not already showing. The bubble 38 // Show the one-click signin bubble if not already showing. The bubble
36 // will be placed visually beneath |anchor_view|. |start_sync| is called 39 // will be placed visually beneath |anchor_view|. |start_sync| is called
37 // to start sync. 40 // to start sync.
38 static void ShowBubble(BrowserWindow::OneClickSigninBubbleType type, 41 static void ShowBubble(BrowserWindow::OneClickSigninBubbleType type,
39 const string16& email, 42 const string16& email,
40 const string16& error_message, 43 const string16& error_message,
41 ToolbarView* toolbar_view, 44 scoped_ptr<OneClickSigninBubbleDelegate> delegate,
45 views::View* anchor_view,
42 const BrowserWindow::StartSyncCallback& start_sync); 46 const BrowserWindow::StartSyncCallback& start_sync);
43 47
44 static bool IsShowing(); 48 static bool IsShowing();
45 49
46 static void Hide(); 50 static void Hide();
47 51
48 // Gets the global bubble view. If its not showing returns NULL. This 52 // Gets the global bubble view. If its not showing returns NULL. This
49 // method is meant to be called only from tests. 53 // method is meant to be called only from tests.
50 static OneClickSigninBubbleView* view_for_testing() { return bubble_view_; } 54 static OneClickSigninBubbleView* view_for_testing() { return bubble_view_; }
51 55
52 protected: 56 protected:
53 // Creates a OneClickSigninBubbleView. 57 // Creates a OneClickSigninBubbleView.
54 OneClickSigninBubbleView( 58 OneClickSigninBubbleView(
55 content::WebContents* web_contents,
56 views::View* anchor_view,
57 const string16& error_message, 59 const string16& error_message,
58 const string16& email, 60 const string16& email,
61 scoped_ptr<OneClickSigninBubbleDelegate> delegate,
62 views::View* anchor_view,
59 const BrowserWindow::StartSyncCallback& start_sync_callback, 63 const BrowserWindow::StartSyncCallback& start_sync_callback,
60 bool is_sync_dialog); 64 bool is_sync_dialog);
61 65
62 virtual ~OneClickSigninBubbleView(); 66 virtual ~OneClickSigninBubbleView();
63 67
64 private: 68 private:
65 friend class OneClickSigninBubbleViewBrowserTest; 69 friend class OneClickSigninBubbleViewTest;
66 70
67 FRIEND_TEST_ALL_PREFIXES( 71 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewTest, BubbleOkButton);
68 OneClickSigninBubbleViewBrowserTest, BubbleOkButton); 72 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewTest, DialogOkButton);
69 FRIEND_TEST_ALL_PREFIXES( 73 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewTest, DialogUndoButton);
70 OneClickSigninBubbleViewBrowserTest, DialogOkButton); 74 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewTest, BubbleAdvancedLink);
71 FRIEND_TEST_ALL_PREFIXES( 75 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewTest, DialogAdvancedLink);
72 OneClickSigninBubbleViewBrowserTest, DialogUndoButton); 76 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewTest, BubbleLearnMoreLink);
73 FRIEND_TEST_ALL_PREFIXES( 77 FRIEND_TEST_ALL_PREFIXES(OneClickSigninBubbleViewTest, DialogLearnMoreLink);
74 OneClickSigninBubbleViewBrowserTest, BubbleAdvancedLink);
75 FRIEND_TEST_ALL_PREFIXES(
76 OneClickSigninBubbleViewBrowserTest, DialogAdvancedLink);
77 FRIEND_TEST_ALL_PREFIXES(
78 OneClickSigninBubbleViewBrowserTest, BubbleLearnMoreLink);
79 FRIEND_TEST_ALL_PREFIXES(
80 OneClickSigninBubbleViewBrowserTest, DialogLearnMoreLink);
81 78
82 // Overridden from views::BubbleDelegateView: 79 // Overridden from views::BubbleDelegateView:
83 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; 80 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
84 virtual void Init() OVERRIDE; 81 virtual void Init() OVERRIDE;
85 82
86 // Overridden from views::LinkListener: 83 // Overridden from views::LinkListener:
87 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; 84 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
88 85
89 // Overridden from views::ButtonListener: 86 // Overridden from views::ButtonListener:
90 virtual void ButtonPressed(views::Button* sender, 87 virtual void ButtonPressed(views::Button* sender,
(...skipping 16 matching lines...) Expand all
107 void InitButtons(views::GridLayout* layout); 104 void InitButtons(views::GridLayout* layout);
108 void GetButtons(views::LabelButton** ok_button, 105 void GetButtons(views::LabelButton** ok_button,
109 views::LabelButton** undo_button); 106 views::LabelButton** undo_button);
110 107
111 // Creates learn more link to be used at the bottom of the bubble. 108 // Creates learn more link to be used at the bottom of the bubble.
112 void InitLearnMoreLink(); 109 void InitLearnMoreLink();
113 110
114 // Creates advanced link to be used at the bottom of the bubble. 111 // Creates advanced link to be used at the bottom of the bubble.
115 void InitAdvancedLink(); 112 void InitAdvancedLink();
116 113
117 // The bubble/dialog will always outlive the web_content, so this is ok. 114 // Delegate to handle clicking on links in the bubble.
118 content::WebContents* web_contents_; 115 scoped_ptr<OneClickSigninBubbleDelegate> delegate_;
119 116
120 // Alternate error message to be displayed. 117 // Alternate error message to be displayed.
121 const string16 error_message_; 118 const string16 error_message_;
122 119
123 // The user's email address to be used for sync. 120 // The user's email address to be used for sync.
124 const string16 email_; 121 const string16 email_;
125 122
126 // This callback is nulled once its called, so that it is called only once. 123 // This callback is nulled once its called, so that it is called only once.
127 // It will be called when the bubble is closed if it has not been called 124 // It will be called when the bubble is closed if it has not been called
128 // and nulled earlier. 125 // and nulled earlier.
(...skipping 19 matching lines...) Expand all
148 // A message loop used only with unit tests. 145 // A message loop used only with unit tests.
149 base::MessageLoop* message_loop_for_testing_; 146 base::MessageLoop* message_loop_for_testing_;
150 147
151 // The bubble, if we're showing one. 148 // The bubble, if we're showing one.
152 static OneClickSigninBubbleView* bubble_view_; 149 static OneClickSigninBubbleView* bubble_view_;
153 150
154 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleView); 151 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleView);
155 }; 152 };
156 153
157 #endif // CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ 154 #endif // CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | chrome/browser/ui/views/sync/one_click_signin_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698