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 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h" | 5 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/google/google_util.h" | 10 #include "chrome/browser/google/google_util.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
14 #include "grit/chromium_strings.h" | 14 #include "grit/chromium_strings.h" |
15 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
16 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
17 #include "grit/ui_resources.h" | 17 #include "grit/ui_resources.h" |
18 #include "ui/base/keycodes/keyboard_codes.h" | 18 #include "ui/base/keycodes/keyboard_codes.h" |
19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
20 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
21 #include "ui/views/controls/button/image_button.h" | 21 #include "ui/views/controls/button/image_button.h" |
22 #include "ui/views/controls/button/text_button.h" | 22 #include "ui/views/controls/button/label_button.h" |
23 #include "ui/views/controls/image_view.h" | 23 #include "ui/views/controls/image_view.h" |
24 #include "ui/views/controls/label.h" | 24 #include "ui/views/controls/label.h" |
25 #include "ui/views/controls/link.h" | 25 #include "ui/views/controls/link.h" |
26 #include "ui/views/layout/grid_layout.h" | 26 #include "ui/views/layout/grid_layout.h" |
27 #include "ui/views/layout/layout_constants.h" | 27 #include "ui/views/layout/layout_constants.h" |
28 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
29 | 29 |
30 // Minimum width for the mutli-line label. | 30 // Minimum width for the mutli-line label. |
31 const int kMinimumDialogLabelWidth = 400; | 31 const int kMinimumDialogLabelWidth = 400; |
32 const int kMinimumLabelWidth = 240; | 32 const int kMinimumLabelWidth = 240; |
(...skipping 15 matching lines...) Expand all Loading... |
48 content::WebContents* web_content, | 48 content::WebContents* web_content, |
49 views::View* anchor_view, | 49 views::View* anchor_view, |
50 const BrowserWindow::StartSyncCallback& start_sync_callback); | 50 const BrowserWindow::StartSyncCallback& start_sync_callback); |
51 | 51 |
52 private: | 52 private: |
53 // Overridden from views::WidgetDelegate: | 53 // Overridden from views::WidgetDelegate: |
54 virtual ui::ModalType GetModalType() const OVERRIDE; | 54 virtual ui::ModalType GetModalType() const OVERRIDE; |
55 | 55 |
56 // Overridden from OneClickSigninBubbleView: | 56 // Overridden from OneClickSigninBubbleView: |
57 virtual void InitContent(views::GridLayout* layout) OVERRIDE; | 57 virtual void InitContent(views::GridLayout* layout) OVERRIDE; |
58 virtual void GetButtons(views::TextButton** ok_button, | 58 virtual void GetButtons(views::LabelButton** ok_button, |
59 views::TextButton** undo_button) OVERRIDE; | 59 views::LabelButton** undo_button) OVERRIDE; |
60 virtual views::Link* GetAdvancedLink() OVERRIDE; | 60 virtual views::Link* GetAdvancedLink() OVERRIDE; |
61 | 61 |
62 // Overridden from views::LinkListener: | 62 // Overridden from views::LinkListener: |
63 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 63 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
64 | 64 |
65 content::WebContents* web_content_; | 65 content::WebContents* web_content_; |
66 views::Link* learn_more_link_; | 66 views::Link* learn_more_link_; |
67 views::ImageButton* close_button_; | 67 views::ImageButton* close_button_; |
68 | 68 |
69 DISALLOW_COPY_AND_ASSIGN(OneClickSigninDialogView); | 69 DISALLOW_COPY_AND_ASSIGN(OneClickSigninDialogView); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); | 136 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); |
137 learn_more_link_->set_listener(this); | 137 learn_more_link_->set_listener(this); |
138 learn_more_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 138 learn_more_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
139 layout->AddView(learn_more_link_, 1, 1, views::GridLayout::TRAILING, | 139 layout->AddView(learn_more_link_, 1, 1, views::GridLayout::TRAILING, |
140 views::GridLayout::CENTER); | 140 views::GridLayout::CENTER); |
141 } | 141 } |
142 | 142 |
143 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); | 143 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); |
144 } | 144 } |
145 | 145 |
146 void OneClickSigninDialogView::GetButtons(views::TextButton** ok_button, | 146 void OneClickSigninDialogView::GetButtons(views::LabelButton** ok_button, |
147 views::TextButton** undo_button) { | 147 views::LabelButton** undo_button) { |
148 *ok_button = new views::NativeTextButton(this); | 148 *ok_button = new views::LabelButton(this, string16()); |
149 *undo_button = new views::NativeTextButton(this); | 149 (*ok_button)->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| 150 *undo_button = new views::LabelButton(this, string16()); |
| 151 (*undo_button)->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
150 | 152 |
151 // The default size of the buttons is too large. To allow them to be smaller | 153 // The default size of the buttons is too large. To allow them to be smaller |
152 // ignore the minimum default size. Furthermore, to make sure they are the | 154 // ignore the minimum default size. Furthermore, to make sure they are the |
153 // same size, SetText() is called with both strings on both buttons. | 155 // same size, SetText() is called with both strings on both buttons. |
154 (*ok_button)->set_ignore_minimum_size(true); | 156 (*ok_button)->set_min_size(gfx::Size()); |
155 (*undo_button)->set_ignore_minimum_size(true); | 157 (*undo_button)->set_min_size(gfx::Size()); |
156 string16 ok_label = | 158 string16 ok_label = |
157 l10n_util::GetStringUTF16(IDS_ONE_CLICK_SIGNIN_DIALOG_OK_BUTTON); | 159 l10n_util::GetStringUTF16(IDS_ONE_CLICK_SIGNIN_DIALOG_OK_BUTTON); |
158 string16 undo_label = | 160 string16 undo_label = |
159 l10n_util::GetStringUTF16(IDS_ONE_CLICK_SIGNIN_DIALOG_UNDO_BUTTON); | 161 l10n_util::GetStringUTF16(IDS_ONE_CLICK_SIGNIN_DIALOG_UNDO_BUTTON); |
160 (*ok_button)->SetText(undo_label); | 162 (*ok_button)->SetText(undo_label); |
161 (*ok_button)->SetText(ok_label); | 163 (*ok_button)->SetText(ok_label); |
162 (*undo_button)->SetText(ok_label); | 164 (*undo_button)->SetText(ok_label); |
163 (*undo_button)->SetText(undo_label); | 165 (*undo_button)->SetText(undo_label); |
164 } | 166 } |
165 | 167 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 label->SetMultiLine(true); | 284 label->SetMultiLine(true); |
283 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 285 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
284 label->SizeToFit(kMinimumLabelWidth); | 286 label->SizeToFit(kMinimumLabelWidth); |
285 | 287 |
286 layout->StartRow(0, COLUMN_SET_FILL_ALIGN); | 288 layout->StartRow(0, COLUMN_SET_FILL_ALIGN); |
287 layout->AddView(label); | 289 layout->AddView(label); |
288 | 290 |
289 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); | 291 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); |
290 } | 292 } |
291 | 293 |
292 void OneClickSigninBubbleView::GetButtons(views::TextButton** ok_button, | 294 void OneClickSigninBubbleView::GetButtons(views::LabelButton** ok_button, |
293 views::TextButton** undo_button) { | 295 views::LabelButton** undo_button) { |
294 *ok_button = new views::NativeTextButton(this); | 296 *ok_button = new views::LabelButton(this, string16()); |
295 *undo_button = new views::NativeTextButton(this); | 297 (*ok_button)->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| 298 *undo_button = new views::LabelButton(this, string16()); |
| 299 (*undo_button)->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
296 | 300 |
297 // The default size of the buttons is too large. To allow them to be smaller | 301 // The default size of the buttons is too large. To allow them to be smaller |
298 // ignore the minimum default size. Furthermore, to make sure they are the | 302 // ignore the minimum default size. Furthermore, to make sure they are the |
299 // same size, SetText() is called with both strings on both buttons. | 303 // same size, SetText() is called with both strings on both buttons. |
300 (*ok_button)->set_ignore_minimum_size(true); | 304 (*ok_button)->set_min_size(gfx::Size()); |
301 (*undo_button)->set_ignore_minimum_size(true); | 305 (*undo_button)->set_min_size(gfx::Size()); |
302 string16 ok_label = l10n_util::GetStringUTF16(IDS_OK); | 306 string16 ok_label = l10n_util::GetStringUTF16(IDS_OK); |
303 string16 undo_label = l10n_util::GetStringUTF16(IDS_ONE_CLICK_BUBBLE_UNDO); | 307 string16 undo_label = l10n_util::GetStringUTF16(IDS_ONE_CLICK_BUBBLE_UNDO); |
304 (*ok_button)->SetText(undo_label); | 308 (*ok_button)->SetText(undo_label); |
305 (*ok_button)->SetText(ok_label); | 309 (*ok_button)->SetText(ok_label); |
306 (*undo_button)->SetText(ok_label); | 310 (*undo_button)->SetText(ok_label); |
307 (*undo_button)->SetText(undo_label); | 311 (*undo_button)->SetText(undo_label); |
308 } | 312 } |
309 | 313 |
310 views::Link* OneClickSigninBubbleView::GetAdvancedLink() { | 314 views::Link* OneClickSigninBubbleView::GetAdvancedLink() { |
311 views::Link* advanced_link= new views::Link( | 315 views::Link* advanced_link= new views::Link( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); | 357 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
354 } | 358 } |
355 | 359 |
356 void OneClickSigninBubbleView::ButtonPressed(views::Button* sender, | 360 void OneClickSigninBubbleView::ButtonPressed(views::Button* sender, |
357 const ui::Event& event) { | 361 const ui::Event& event) { |
358 StartFade(false); | 362 StartFade(false); |
359 base::ResetAndReturn(&start_sync_callback_).Run((sender == ok_button_) ? | 363 base::ResetAndReturn(&start_sync_callback_).Run((sender == ok_button_) ? |
360 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS : | 364 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS : |
361 OneClickSigninSyncStarter::UNDO_SYNC); | 365 OneClickSigninSyncStarter::UNDO_SYNC); |
362 } | 366 } |
OLD | NEW |