OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.
h" | 5 #include "chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.
h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_navigator.h" | 13 #include "chrome/browser/ui/browser_navigator.h" |
14 #include "chrome/browser/ui/browser_navigator_params.h" | 14 #include "chrome/browser/ui/browser_navigator_params.h" |
15 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
| 16 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" |
16 #include "chrome/grit/chromium_strings.h" | 17 #include "chrome/grit/chromium_strings.h" |
17 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
18 #include "components/constrained_window/constrained_window_views.h" | 19 #include "components/constrained_window/constrained_window_views.h" |
19 #include "components/signin/core/common/profile_management_switches.h" | 20 #include "components/signin/core/common/profile_management_switches.h" |
20 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
21 #include "google_apis/gaia/gaia_auth_util.h" | 22 #include "google_apis/gaia/gaia_auth_util.h" |
22 #include "third_party/skia/include/core/SkColor.h" | 23 #include "third_party/skia/include/core/SkColor.h" |
23 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
24 #include "ui/base/ui_features.h" | |
25 #include "ui/gfx/font.h" | 25 #include "ui/gfx/font.h" |
26 #include "ui/gfx/native_widget_types.h" | 26 #include "ui/gfx/native_widget_types.h" |
27 #include "ui/gfx/range/range.h" | 27 #include "ui/gfx/range/range.h" |
28 #include "ui/views/background.h" | 28 #include "ui/views/background.h" |
29 #include "ui/views/border.h" | 29 #include "ui/views/border.h" |
30 #include "ui/views/controls/button/md_text_button.h" | 30 #include "ui/views/controls/button/md_text_button.h" |
31 #include "ui/views/controls/label.h" | 31 #include "ui/views/controls/label.h" |
32 #include "ui/views/controls/styled_label.h" | 32 #include "ui/views/controls/styled_label.h" |
33 #include "ui/views/layout/box_layout.h" | 33 #include "ui/views/layout/box_layout.h" |
34 #include "ui/views/layout/grid_layout.h" | 34 #include "ui/views/layout/grid_layout.h" |
35 #include "ui/views/layout/layout_constants.h" | 35 #include "ui/views/layout/layout_constants.h" |
36 #include "ui/views/widget/widget.h" | 36 #include "ui/views/widget/widget.h" |
37 #include "ui/views/window/dialog_client_view.h" | 37 #include "ui/views/window/dialog_client_view.h" |
38 | 38 |
39 #if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) | |
40 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" | |
41 #endif | |
42 | |
43 ProfileSigninConfirmationDialogViews::ProfileSigninConfirmationDialogViews( | 39 ProfileSigninConfirmationDialogViews::ProfileSigninConfirmationDialogViews( |
44 Browser* browser, | 40 Browser* browser, |
45 const std::string& username, | 41 const std::string& username, |
46 std::unique_ptr<ui::ProfileSigninConfirmationDelegate> delegate) | 42 ui::ProfileSigninConfirmationDelegate* delegate) |
47 : browser_(browser), | 43 : browser_(browser), |
48 username_(username), | 44 username_(username), |
49 delegate_(std::move(delegate)), | 45 delegate_(delegate), |
50 prompt_for_new_profile_(true) {} | 46 prompt_for_new_profile_(true) {} |
51 | 47 |
52 ProfileSigninConfirmationDialogViews::~ProfileSigninConfirmationDialogViews() {} | 48 ProfileSigninConfirmationDialogViews::~ProfileSigninConfirmationDialogViews() {} |
53 | 49 |
54 // static | 50 // static |
55 void ProfileSigninConfirmationDialogViews::ShowDialog( | 51 void ProfileSigninConfirmationDialogViews::ShowDialog( |
56 Browser* browser, | 52 Browser* browser, |
57 Profile* profile, | 53 Profile* profile, |
58 const std::string& username, | 54 const std::string& username, |
59 std::unique_ptr<ui::ProfileSigninConfirmationDelegate> delegate) { | 55 ui::ProfileSigninConfirmationDelegate* delegate) { |
60 #if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) | |
61 // Hides the new avatar bubble if it is currently shown. The new avatar bubble | 56 // Hides the new avatar bubble if it is currently shown. The new avatar bubble |
62 // should be automatically closed when it loses focus. However on windows the | 57 // should be automatically closed when it loses focus. However on windows the |
63 // profile signin confirmation dialog is not modal yet thus it does not take | 58 // profile signin confirmation dialog is not modal yet thus it does not take |
64 // away focus, thus as a temporary workaround we need to manually close the | 59 // away focus, thus as a temporary workaround we need to manually close the |
65 // bubble. | 60 // bubble. |
66 // TODO(guohui): removes the workaround once the profile confirmation dialog | 61 // TODO(guohui): removes the workaround once the profile confirmation dialog |
67 // is fixed. | 62 // is fixed. |
68 ProfileChooserView::Hide(); | 63 ProfileChooserView::Hide(); |
69 #endif | |
70 | 64 |
71 ProfileSigninConfirmationDialogViews* dialog = | 65 ProfileSigninConfirmationDialogViews* dialog = |
72 new ProfileSigninConfirmationDialogViews(browser, username, | 66 new ProfileSigninConfirmationDialogViews( |
73 std::move(delegate)); | 67 browser, username, delegate); |
74 ui::CheckShouldPromptForNewProfile( | 68 ui::CheckShouldPromptForNewProfile( |
75 profile, | 69 profile, |
76 // This callback is guaranteed to be invoked, and once it is, the dialog | 70 // This callback is guaranteed to be invoked, and once it is, the dialog |
77 // owns itself. | 71 // owns itself. |
78 base::Bind(&ProfileSigninConfirmationDialogViews::Show, | 72 base::Bind(&ProfileSigninConfirmationDialogViews::Show, |
79 base::Unretained(dialog))); | 73 base::Unretained(dialog))); |
80 } | 74 } |
81 | 75 |
82 void ProfileSigninConfirmationDialogViews::Show(bool prompt_for_new_profile) { | 76 void ProfileSigninConfirmationDialogViews::Show(bool prompt_for_new_profile) { |
83 prompt_for_new_profile_ = prompt_for_new_profile; | 77 prompt_for_new_profile_ = prompt_for_new_profile; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 return views::MdTextButton::CreateSecondaryUiButton(this, | 110 return views::MdTextButton::CreateSecondaryUiButton(this, |
117 continue_signin_text); | 111 continue_signin_text); |
118 } | 112 } |
119 | 113 |
120 bool ProfileSigninConfirmationDialogViews::Accept() { | 114 bool ProfileSigninConfirmationDialogViews::Accept() { |
121 if (delegate_) { | 115 if (delegate_) { |
122 if (prompt_for_new_profile_) | 116 if (prompt_for_new_profile_) |
123 delegate_->OnSigninWithNewProfile(); | 117 delegate_->OnSigninWithNewProfile(); |
124 else | 118 else |
125 delegate_->OnContinueSignin(); | 119 delegate_->OnContinueSignin(); |
126 delegate_ = nullptr; | 120 delegate_ = NULL; |
127 } | 121 } |
128 return true; | 122 return true; |
129 } | 123 } |
130 | 124 |
131 bool ProfileSigninConfirmationDialogViews::Cancel() { | 125 bool ProfileSigninConfirmationDialogViews::Cancel() { |
132 if (delegate_) { | 126 if (delegate_) { |
133 delegate_->OnCancelSignin(); | 127 delegate_->OnCancelSignin(); |
134 delegate_ = nullptr; | 128 delegate_ = NULL; |
135 } | 129 } |
136 return true; | 130 return true; |
137 } | 131 } |
138 | 132 |
139 ui::ModalType ProfileSigninConfirmationDialogViews::GetModalType() const { | 133 ui::ModalType ProfileSigninConfirmationDialogViews::GetModalType() const { |
140 return ui::MODAL_TYPE_WINDOW; | 134 return ui::MODAL_TYPE_WINDOW; |
141 } | 135 } |
142 | 136 |
143 void ProfileSigninConfirmationDialogViews::ViewHierarchyChanged( | 137 void ProfileSigninConfirmationDialogViews::ViewHierarchyChanged( |
144 const ViewHierarchyChangedDetails& details) { | 138 const ViewHierarchyChangedDetails& details) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 239 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
246 chrome::Navigate(¶ms); | 240 chrome::Navigate(¶ms); |
247 } | 241 } |
248 | 242 |
249 void ProfileSigninConfirmationDialogViews::ButtonPressed( | 243 void ProfileSigninConfirmationDialogViews::ButtonPressed( |
250 views::Button* sender, | 244 views::Button* sender, |
251 const ui::Event& event) { | 245 const ui::Event& event) { |
252 DCHECK(prompt_for_new_profile_); | 246 DCHECK(prompt_for_new_profile_); |
253 if (delegate_) { | 247 if (delegate_) { |
254 delegate_->OnContinueSignin(); | 248 delegate_->OnContinueSignin(); |
255 delegate_ = nullptr; | 249 delegate_ = NULL; |
256 } | 250 } |
257 GetWidget()->Close(); | 251 GetWidget()->Close(); |
258 } | 252 } |
OLD | NEW |