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" |
(...skipping 10 matching lines...) Expand all Loading... |
21 } | 21 } |
22 | 22 |
23 // OneClickSigninBubbleView is a view intended to be used as the content of an | 23 // 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 | 24 // Bubble. It provides simple and concise feedback to the user that sync'ing |
25 // has started after using the one-click singin infobar. | 25 // has started after using the one-click singin infobar. |
26 class OneClickSigninBubbleView : public views::BubbleDelegateView, | 26 class OneClickSigninBubbleView : public views::BubbleDelegateView, |
27 public views::LinkListener, | 27 public views::LinkListener, |
28 public views::ButtonListener { | 28 public views::ButtonListener { |
29 public: | 29 public: |
30 // Show the one-click signin bubble if not already showing. The bubble | 30 // Show the one-click signin bubble if not already showing. The bubble |
31 // will be placed visually beneath |anchor_view|. The |browser| is used | 31 // will be placed visually beneath |anchor_view|. The closures are called |
32 // to open links. | 32 // to open the corresponding links, and the callback is used to start sync. |
| 33 // The bool argument indicates if default sync settings should be used. |
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 base::Callback<void(bool)>& 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. |
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 base::Callback<void(bool)>& 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 base::Callback<void(bool)> start_sync_callback_; |
91 base::Closure learn_more_callback_; | 89 bool call_sync_callback_on_close_; |
92 base::Closure advanced_callback_; | |
93 | 90 |
94 // A message loop used only with unit tests. | 91 // A message loop used only with unit tests. |
95 MessageLoop* message_loop_for_testing_; | 92 MessageLoop* message_loop_for_testing_; |
96 | 93 |
97 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleView); | 94 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleView); |
98 }; | 95 }; |
99 | 96 |
100 #endif // CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ | 97 #endif // CHROME_BROWSER_UI_VIEWS_SYNC_ONE_CLICK_SIGNIN_BUBBLE_VIEW_H_ |
OLD | NEW |