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 <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "chrome/browser/profiles/avatar_menu.h" | 11 #include "chrome/browser/profiles/avatar_menu.h" |
12 #include "chrome/browser/profiles/avatar_menu_observer.h" | 12 #include "chrome/browser/profiles/avatar_menu_observer.h" |
13 #include "chrome/browser/profiles/profile_metrics.h" | 13 #include "chrome/browser/profiles/profile_metrics.h" |
14 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
15 #include "chrome/browser/ui/profile_chooser_constants.h" | 15 #include "chrome/browser/ui/profile_chooser_constants.h" |
| 16 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 17 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
16 #include "content/public/browser/web_contents_delegate.h" | 18 #include "content/public/browser/web_contents_delegate.h" |
17 #include "google_apis/gaia/oauth2_token_service.h" | 19 #include "google_apis/gaia/oauth2_token_service.h" |
18 #include "ui/views/bubble/bubble_delegate.h" | 20 #include "ui/views/bubble/bubble_delegate.h" |
19 #include "ui/views/controls/button/button.h" | 21 #include "ui/views/controls/button/button.h" |
20 #include "ui/views/controls/link_listener.h" | 22 #include "ui/views/controls/link_listener.h" |
21 #include "ui/views/controls/styled_label_listener.h" | 23 #include "ui/views/controls/styled_label_listener.h" |
22 #include "ui/views/controls/textfield/textfield_controller.h" | 24 #include "ui/views/controls/textfield/textfield_controller.h" |
23 | 25 |
24 class EditableProfilePhoto; | 26 class EditableProfilePhoto; |
25 class EditableProfileName; | 27 class EditableProfileName; |
26 | 28 |
27 namespace gfx { | 29 namespace gfx { |
28 class Image; | 30 class Image; |
29 } | 31 } |
30 | 32 |
31 namespace views { | 33 namespace views { |
32 class GridLayout; | 34 class GridLayout; |
33 class ImageButton; | 35 class ImageButton; |
34 class Link; | 36 class Link; |
35 class LabelButton; | 37 class LabelButton; |
36 } | 38 } |
37 | 39 |
38 class Browser; | 40 class Browser; |
39 | 41 |
40 // This bubble view is displayed when the user clicks on the avatar button. | 42 // This bubble view is displayed when the user clicks on the avatar button. |
41 // It displays a list of profiles and allows users to switch between profiles. | 43 // It displays a list of profiles and allows users to switch between profiles. |
42 class ProfileChooserView : public content::WebContentsDelegate, | 44 class ProfileChooserView |
43 public views::BubbleDelegateView, | 45 : public content::WebContentsDelegate, |
44 public views::ButtonListener, | 46 public views::BubbleDelegateView, |
45 public views::LinkListener, | 47 public views::ButtonListener, |
46 public views::StyledLabelListener, | 48 public views::LinkListener, |
47 public views::TextfieldController, | 49 public views::StyledLabelListener, |
48 public AvatarMenuObserver, | 50 public views::TextfieldController, |
49 public OAuth2TokenService::Observer { | 51 public web_modal::WebContentsModalDialogHost, |
| 52 public web_modal::WebContentsModalDialogManagerDelegate, |
| 53 public AvatarMenuObserver, |
| 54 public OAuth2TokenService::Observer { |
50 public: | 55 public: |
51 // Shows the bubble if one is not already showing. This allows us to easily | 56 // Shows the bubble if one is not already showing. This allows us to easily |
52 // make a button toggle the bubble on and off when clicked: we unconditionally | 57 // make a button toggle the bubble on and off when clicked: we unconditionally |
53 // call this function when the button is clicked and if the bubble isn't | 58 // call this function when the button is clicked and if the bubble isn't |
54 // showing it will appear while if it is showing, nothing will happen here and | 59 // showing it will appear while if it is showing, nothing will happen here and |
55 // the existing bubble will auto-close due to focus loss. | 60 // the existing bubble will auto-close due to focus loss. |
56 static void ShowBubble( | 61 static void ShowBubble( |
57 profiles::BubbleViewMode view_mode, | 62 profiles::BubbleViewMode view_mode, |
58 profiles::TutorialMode tutorial_mode, | 63 profiles::TutorialMode tutorial_mode, |
59 const signin::ManageAccountsParams& manage_accounts_params, | 64 const signin::ManageAccountsParams& manage_accounts_params, |
60 views::View* anchor_view, | 65 views::View* anchor_view, |
61 views::BubbleBorder::Arrow arrow, | 66 views::BubbleBorder::Arrow arrow, |
62 views::BubbleBorder::BubbleAlignment border_alignment, | 67 views::BubbleBorder::BubbleAlignment border_alignment, |
63 Browser* browser); | 68 Browser* browser); |
64 static bool IsShowing(); | 69 static bool IsShowing(); |
65 | 70 |
66 // A ShowingType to indicate whether the avatar bubble view is showing in a | 71 // A ShowingType to indicate whether the avatar bubble view is showing in a |
67 // designated browser. | 72 // designated browser. |
68 enum ShowingType { | 73 enum ShowingType { |
69 IS_NOT_SHOWING = 0, | 74 IS_NOT_SHOWING = 0, |
70 IS_SHOWING = 1, | 75 IS_SHOWING = 1, |
71 IS_SHOWING_IN_ANOTHER_BROWSER = 2, | 76 IS_SHOWING_IN_ANOTHER_BROWSER = 2, |
72 }; | 77 }; |
73 static ShowingType IsShowingInBrowser(const Browser* browser); | 78 static ShowingType IsShowingInBrowser(const Browser* browser); |
74 static void Hide(); | 79 static void Hide(); |
75 | 80 |
| 81 // web_modal::WebContentsModalDialogManagerDelegate implementation. |
| 82 web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost() |
| 83 override; |
| 84 |
| 85 // web_modal::WebContentsModalDialogHost implementation. |
| 86 gfx::Size GetMaximumDialogSize() override; |
| 87 |
| 88 // web_modal::ModalDialogHost implementation. |
| 89 gfx::NativeView GetHostView() const override; |
| 90 gfx::Point GetDialogPosition(const gfx::Size& size) override; |
| 91 void AddObserver(web_modal::ModalDialogHostObserver* observer) override; |
| 92 void RemoveObserver(web_modal::ModalDialogHostObserver* observer) override; |
| 93 |
76 private: | 94 private: |
77 friend class ProfileChooserViewExtensionsTest; | 95 friend class ProfileChooserViewExtensionsTest; |
78 | 96 |
79 typedef std::vector<size_t> Indexes; | 97 typedef std::vector<size_t> Indexes; |
80 typedef std::map<views::Button*, int> ButtonIndexes; | 98 typedef std::map<views::Button*, int> ButtonIndexes; |
81 typedef std::map<views::Button*, std::string> AccountButtonIndexes; | 99 typedef std::map<views::Button*, std::string> AccountButtonIndexes; |
82 | 100 |
83 ProfileChooserView(views::View* anchor_view, | 101 ProfileChooserView(views::View* anchor_view, |
84 views::BubbleBorder::Arrow arrow, | 102 views::BubbleBorder::Arrow arrow, |
85 Browser* browser, | 103 Browser* browser, |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 // The current tutorial mode. | 291 // The current tutorial mode. |
274 profiles::TutorialMode tutorial_mode_; | 292 profiles::TutorialMode tutorial_mode_; |
275 | 293 |
276 // The GAIA service type provided in the response header. | 294 // The GAIA service type provided in the response header. |
277 signin::GAIAServiceType gaia_service_type_; | 295 signin::GAIAServiceType gaia_service_type_; |
278 | 296 |
279 DISALLOW_COPY_AND_ASSIGN(ProfileChooserView); | 297 DISALLOW_COPY_AND_ASSIGN(ProfileChooserView); |
280 }; | 298 }; |
281 | 299 |
282 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ | 300 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ |
OLD | NEW |