OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PROFILES_PROFILE_CHOOSER_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "chrome/browser/profiles/avatar_menu.h" | 14 #include "chrome/browser/profiles/avatar_menu.h" |
15 #include "chrome/browser/profiles/avatar_menu_observer.h" | 15 #include "chrome/browser/profiles/avatar_menu_observer.h" |
16 #include "chrome/browser/profiles/profile_metrics.h" | 16 #include "chrome/browser/profiles/profile_metrics.h" |
17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
18 #include "chrome/browser/ui/profile_chooser_constants.h" | 18 #include "chrome/browser/ui/profile_chooser_constants.h" |
19 #include "components/signin/core/browser/signin_header_helper.h" | 19 #include "components/signin/core/browser/signin_header_helper.h" |
20 #include "content/public/browser/web_contents_delegate.h" | 20 #include "content/public/browser/web_contents_delegate.h" |
21 #include "google_apis/gaia/oauth2_token_service.h" | 21 #include "google_apis/gaia/oauth2_token_service.h" |
22 #include "ui/views/bubble/bubble_dialog_delegate.h" | 22 #include "ui/views/bubble/bubble_dialog_delegate.h" |
23 #include "ui/views/controls/button/button.h" | 23 #include "ui/views/controls/button/button.h" |
| 24 #include "ui/views/controls/button/menu_button.h" |
24 #include "ui/views/controls/link_listener.h" | 25 #include "ui/views/controls/link_listener.h" |
25 #include "ui/views/controls/styled_label_listener.h" | 26 #include "ui/views/controls/styled_label_listener.h" |
26 | 27 |
27 namespace views { | 28 namespace views { |
28 class GridLayout; | 29 class GridLayout; |
29 class ImageButton; | 30 class ImageButton; |
30 class Link; | 31 class Link; |
31 class LabelButton; | 32 class LabelButton; |
32 } | 33 } |
33 | 34 |
(...skipping 12 matching lines...) Expand all Loading... |
46 // Shows the bubble if one is not already showing. This allows us to easily | 47 // Shows the bubble if one is not already showing. This allows us to easily |
47 // make a button toggle the bubble on and off when clicked: we unconditionally | 48 // make a button toggle the bubble on and off when clicked: we unconditionally |
48 // call this function when the button is clicked and if the bubble isn't | 49 // call this function when the button is clicked and if the bubble isn't |
49 // showing it will appear while if it is showing, nothing will happen here and | 50 // showing it will appear while if it is showing, nothing will happen here and |
50 // the existing bubble will auto-close due to focus loss. | 51 // the existing bubble will auto-close due to focus loss. |
51 static void ShowBubble( | 52 static void ShowBubble( |
52 profiles::BubbleViewMode view_mode, | 53 profiles::BubbleViewMode view_mode, |
53 profiles::TutorialMode tutorial_mode, | 54 profiles::TutorialMode tutorial_mode, |
54 const signin::ManageAccountsParams& manage_accounts_params, | 55 const signin::ManageAccountsParams& manage_accounts_params, |
55 signin_metrics::AccessPoint access_point, | 56 signin_metrics::AccessPoint access_point, |
56 views::View* anchor_view, | 57 views::MenuButton* calling_button, |
57 Browser* browser, | 58 Browser* browser, |
58 bool is_source_keyboard); | 59 bool is_source_keyboard); |
59 static bool IsShowing(); | 60 static bool IsShowing(); |
60 static void Hide(); | 61 static void Hide(); |
61 | 62 |
| 63 // Make calling_button look pressed and animate the ink drop on it. |
| 64 // The event (click) is used to center the ink drop. |
| 65 static void MakeCallingButtonPressedIfShowing(const ui::Event* click_event); |
| 66 |
62 const Browser* browser() const { return browser_; } | 67 const Browser* browser() const { return browser_; } |
63 | 68 |
64 private: | 69 private: |
65 friend class ProfileChooserViewExtensionsTest; | 70 friend class ProfileChooserViewExtensionsTest; |
66 | 71 |
67 typedef std::vector<size_t> Indexes; | 72 typedef std::vector<size_t> Indexes; |
68 typedef std::map<views::Button*, int> ButtonIndexes; | 73 typedef std::map<views::Button*, int> ButtonIndexes; |
69 typedef std::map<views::Button*, std::string> AccountButtonIndexes; | 74 typedef std::map<views::Button*, std::string> AccountButtonIndexes; |
70 | 75 |
71 ProfileChooserView(views::View* anchor_view, | 76 ProfileChooserView(views::MenuButton* calling_button, |
72 Browser* browser, | 77 Browser* browser, |
73 profiles::BubbleViewMode view_mode, | 78 profiles::BubbleViewMode view_mode, |
74 profiles::TutorialMode tutorial_mode, | 79 profiles::TutorialMode tutorial_mode, |
75 signin::GAIAServiceType service_type, | 80 signin::GAIAServiceType service_type, |
76 signin_metrics::AccessPoint access_point); | 81 signin_metrics::AccessPoint access_point); |
77 ~ProfileChooserView() override; | 82 ~ProfileChooserView() override; |
78 | 83 |
| 84 void MakeCallingButtonPressed(const ui::Event* click_event); |
| 85 |
79 // views::BubbleDialogDelegateView: | 86 // views::BubbleDialogDelegateView: |
80 void Init() override; | 87 void Init() override; |
81 void OnNativeThemeChanged(const ui::NativeTheme* native_theme) override; | 88 void OnNativeThemeChanged(const ui::NativeTheme* native_theme) override; |
82 void WindowClosing() override; | 89 void WindowClosing() override; |
83 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 90 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
84 views::View* GetInitiallyFocusedView() override; | 91 views::View* GetInitiallyFocusedView() override; |
85 int GetDialogButtons() const override; | 92 int GetDialogButtons() const override; |
86 | 93 |
87 // content::WebContentsDelegate: | 94 // content::WebContentsDelegate: |
88 bool HandleContextMenu(const content::ContextMenuParams& params) override; | 95 bool HandleContextMenu(const content::ContextMenuParams& params) override; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 200 |
194 // Create a view that shows various options for an upgrade user who is not | 201 // Create a view that shows various options for an upgrade user who is not |
195 // the same person as the currently signed in user. | 202 // the same person as the currently signed in user. |
196 views::View* CreateSwitchUserView(); | 203 views::View* CreateSwitchUserView(); |
197 | 204 |
198 bool ShouldShowGoIncognito() const; | 205 bool ShouldShowGoIncognito() const; |
199 | 206 |
200 // Clean-up done after an action was performed in the ProfileChooser. | 207 // Clean-up done after an action was performed in the ProfileChooser. |
201 void PostActionPerformed(ProfileMetrics::ProfileDesktopMenu action_performed); | 208 void PostActionPerformed(ProfileMetrics::ProfileDesktopMenu action_performed); |
202 | 209 |
| 210 // Avatar button pressed to show this menu and the lock to keep it "pressed" |
| 211 views::MenuButton* calling_button_; |
| 212 std::unique_ptr<views::MenuButton::PressedLock> pressed_lock_; |
| 213 |
203 std::unique_ptr<AvatarMenu> avatar_menu_; | 214 std::unique_ptr<AvatarMenu> avatar_menu_; |
204 Browser* browser_; | 215 Browser* browser_; |
205 | 216 |
206 // Other profiles used in the "fast profile switcher" view. | 217 // Other profiles used in the "fast profile switcher" view. |
207 ButtonIndexes open_other_profile_indexes_map_; | 218 ButtonIndexes open_other_profile_indexes_map_; |
208 | 219 |
209 // Buttons associated with the current profile. | 220 // Buttons associated with the current profile. |
210 AccountButtonIndexes delete_account_button_map_; | 221 AccountButtonIndexes delete_account_button_map_; |
211 AccountButtonIndexes reauth_account_button_map_; | 222 AccountButtonIndexes reauth_account_button_map_; |
212 | 223 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 // The GAIA service type provided in the response header. | 279 // The GAIA service type provided in the response header. |
269 signin::GAIAServiceType gaia_service_type_; | 280 signin::GAIAServiceType gaia_service_type_; |
270 | 281 |
271 // The current access point of sign in. | 282 // The current access point of sign in. |
272 const signin_metrics::AccessPoint access_point_; | 283 const signin_metrics::AccessPoint access_point_; |
273 | 284 |
274 DISALLOW_COPY_AND_ASSIGN(ProfileChooserView); | 285 DISALLOW_COPY_AND_ASSIGN(ProfileChooserView); |
275 }; | 286 }; |
276 | 287 |
277 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ | 288 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ |
OLD | NEW |