OLD | NEW |
---|---|
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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "chrome/browser/ui/browser_window.h" | |
13 #include "ui/views/bubble/bubble_delegate.h" | 14 #include "ui/views/bubble/bubble_delegate.h" |
14 #include "ui/views/controls/button/button.h" | 15 #include "ui/views/controls/button/button.h" |
15 #include "ui/views/controls/link_listener.h" | 16 #include "ui/views/controls/link_listener.h" |
16 | 17 |
17 class MessageLoop; | 18 class MessageLoop; |
18 | 19 |
19 namespace views { | 20 namespace views { |
20 class TextButton; | 21 class TextButton; |
21 } | 22 } |
22 | 23 |
23 // OneClickSigninBubbleView is a view intended to be used as the content of an | 24 // OneClickSigninBubbleView is a view intended to be used as the content of an |
24 // Bubble. It provides simple and concise feedback to the user that sync'ing | 25 // Bubble. It provides simple and concise feedback to the user that sync'ing |
25 // has started after using the one-click singin infobar. | 26 // has started after using the one-click singin infobar. |
26 class OneClickSigninBubbleView : public views::BubbleDelegateView, | 27 class OneClickSigninBubbleView : public views::BubbleDelegateView, |
27 public views::LinkListener, | 28 public views::LinkListener, |
28 public views::ButtonListener { | 29 public views::ButtonListener { |
29 public: | 30 public: |
30 // Show the one-click signin bubble if not already showing. The bubble | 31 // Show the one-click signin bubble if not already showing. The bubble |
31 // will be placed visually beneath |anchor_view|. The |browser| is used | 32 // will be placed visually beneath |anchor_view|. |start_sync| is called |
32 // to open links. | 33 // to start sync. |
33 static void ShowBubble(views::View* anchor_view, | 34 static void ShowBubble(views::View* anchor_view, |
34 const base::Closure& learn_more_callback, | 35 const BrowserWindow::StartSyncCallback& start_sync); |
35 const base::Closure& advanced_callback); | |
36 | 36 |
37 static bool IsShowing(); | 37 static bool IsShowing(); |
38 | 38 |
39 static void Hide(); | 39 static void Hide(); |
40 | 40 |
41 // Gets the global bubble view. If its not showing returns NULL. This | 41 // Gets the global bubble view. If its not showing returns NULL. This |
42 // method is meant to be called only from tests. | 42 // method is meant to be called only from tests. |
43 static OneClickSigninBubbleView* view_for_testing() { return bubble_view_; } | 43 static OneClickSigninBubbleView* view_for_testing() { return bubble_view_; } |
44 | 44 |
45 // The following accessor message should only be used for testing. | 45 // The following accessor message should only be used for testing. |
Peter Kasting
2012/05/25 21:09:33
Did you decide these should still stay as for_test
Roger Tawa OOO till Jul 10th
2012/05/26 01:56:02
Done.
| |
46 views::Link* learn_more_link_for_testing() const { return learn_more_link_; } | |
47 views::Link* advanced_link_for_testing() const { return advanced_link_; } | 46 views::Link* advanced_link_for_testing() const { return advanced_link_; } |
48 views::TextButton* close_button_for_testing() const { return close_button_; } | 47 views::TextButton* ok_button_for_testing() const { return ok_button_; } |
48 views::TextButton* undo_button_for_testing() const { return undo_button_; } | |
49 void set_message_loop_for_testing(MessageLoop* loop) { | 49 void set_message_loop_for_testing(MessageLoop* loop) { |
50 message_loop_for_testing_ = loop; | 50 message_loop_for_testing_ = loop; |
51 } | 51 } |
52 | 52 |
53 private: | 53 private: |
54 // Creates a BookmarkBubbleView. | 54 // Creates a BookmarkBubbleView. |
55 OneClickSigninBubbleView(views::View* anchor_view, | 55 OneClickSigninBubbleView( |
56 const base::Closure& learn_more_callback, | 56 views::View* anchor_view, |
57 const base::Closure& advanced_callback); | 57 const BrowserWindow::StartSyncCallback& start_sync_callback); |
58 | 58 |
59 virtual ~OneClickSigninBubbleView(); | 59 virtual ~OneClickSigninBubbleView(); |
60 | 60 |
61 // views::BubbleDelegateView methods: | 61 // views::BubbleDelegateView methods: |
62 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 62 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; |
63 virtual void Init() OVERRIDE; | 63 virtual void Init() OVERRIDE; |
64 | 64 |
65 // views::WidgetDelegate method: | 65 // views::WidgetDelegate method: |
66 virtual void WindowClosing() OVERRIDE; | 66 virtual void WindowClosing() OVERRIDE; |
67 | 67 |
68 // views::View method: | 68 // views::View method: |
69 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | 69 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; |
70 | 70 |
71 // Overridden from views::LinkListener: | 71 // Overridden from views::LinkListener: |
72 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 72 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
73 | 73 |
74 // Overridden from views::ButtonListener: | 74 // Overridden from views::ButtonListener: |
75 virtual void ButtonPressed(views::Button* sender, | 75 virtual void ButtonPressed(views::Button* sender, |
76 const views::Event& event) OVERRIDE; | 76 const views::Event& event) OVERRIDE; |
77 | 77 |
78 // The bubble, if we're showing one. | 78 // The bubble, if we're showing one. |
79 static OneClickSigninBubbleView* bubble_view_; | 79 static OneClickSigninBubbleView* bubble_view_; |
80 | 80 |
81 // Link to web page to learn more about sync. | |
82 views::Link* learn_more_link_; | |
83 | |
84 // Link to sync setup advanced page. | 81 // Link to sync setup advanced page. |
85 views::Link* advanced_link_; | 82 views::Link* advanced_link_; |
86 | 83 |
87 // Button to close the window. | 84 // Controls at buttom of bubble. |
88 views::TextButton* close_button_; | 85 views::TextButton* ok_button_; |
86 views::TextButton* undo_button_; | |
89 | 87 |
90 // The callbacks for the links. | 88 // This callback is nulled once its called, so that it is called only once. |
91 base::Closure learn_more_callback_; | 89 // It will be called when the bubble is closed if it has not been called |
92 base::Closure advanced_callback_; | 90 // and nulled earlier. |
91 BrowserWindow::StartSyncCallback start_sync_callback_; | |
93 | 92 |
94 // A message loop used only with unit tests. | 93 // A message loop used only with unit tests. |
95 MessageLoop* message_loop_for_testing_; | 94 MessageLoop* message_loop_for_testing_; |
96 | 95 |
97 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleView); | 96 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleView); |
98 }; | 97 }; |
99 | 98 |
100 #endif // CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ | 99 #endif // CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ |
OLD | NEW |