Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Side by Side Diff: chrome/browser/ui/views/sync/one_click_signin_bubble_view.cc

Issue 13991002: views: Convert one_click_signin_bubble_view* to LabelButton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
151 *undo_button = new views::LabelButton(this, string16());
152 (*undo_button)->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
150 153
151 // The default size of the buttons is too large. To allow them to be smaller 154 // 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 155 // ignore the minimum default size. Furthermore, to make sure they are the
153 // same size, SetText() is called with both strings on both buttons. 156 // same size, SetText() is called with both strings on both buttons.
154 (*ok_button)->set_ignore_minimum_size(true); 157 (*ok_button)->set_min_size(gfx::Size());
155 (*undo_button)->set_ignore_minimum_size(true); 158 (*undo_button)->set_min_size(gfx::Size());
156 string16 ok_label = 159 string16 ok_label =
157 l10n_util::GetStringUTF16(IDS_ONE_CLICK_SIGNIN_DIALOG_OK_BUTTON); 160 l10n_util::GetStringUTF16(IDS_ONE_CLICK_SIGNIN_DIALOG_OK_BUTTON);
158 string16 undo_label = 161 string16 undo_label =
159 l10n_util::GetStringUTF16(IDS_ONE_CLICK_SIGNIN_DIALOG_UNDO_BUTTON); 162 l10n_util::GetStringUTF16(IDS_ONE_CLICK_SIGNIN_DIALOG_UNDO_BUTTON);
160 (*ok_button)->SetText(undo_label); 163 (*ok_button)->SetText(undo_label);
161 (*ok_button)->SetText(ok_label); 164 (*ok_button)->SetText(ok_label);
162 (*undo_button)->SetText(ok_label); 165 (*undo_button)->SetText(ok_label);
163 (*undo_button)->SetText(undo_label); 166 (*undo_button)->SetText(undo_label);
164 } 167 }
165 168
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 label->SetMultiLine(true); 285 label->SetMultiLine(true);
283 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 286 label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
284 label->SizeToFit(kMinimumLabelWidth); 287 label->SizeToFit(kMinimumLabelWidth);
285 288
286 layout->StartRow(0, COLUMN_SET_FILL_ALIGN); 289 layout->StartRow(0, COLUMN_SET_FILL_ALIGN);
287 layout->AddView(label); 290 layout->AddView(label);
288 291
289 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); 292 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing);
290 } 293 }
291 294
292 void OneClickSigninBubbleView::GetButtons(views::TextButton** ok_button, 295 void OneClickSigninBubbleView::GetButtons(views::LabelButton** ok_button,
293 views::TextButton** undo_button) { 296 views::LabelButton** undo_button) {
294 *ok_button = new views::NativeTextButton(this); 297 *ok_button = new views::LabelButton(this, string16());
295 *undo_button = new views::NativeTextButton(this); 298 (*ok_button)->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
299
300 *undo_button = new views::LabelButton(this, string16());
301 (*undo_button)->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
296 302
297 // The default size of the buttons is too large. To allow them to be smaller 303 // 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 304 // ignore the minimum default size. Furthermore, to make sure they are the
299 // same size, SetText() is called with both strings on both buttons. 305 // same size, SetText() is called with both strings on both buttons.
300 (*ok_button)->set_ignore_minimum_size(true); 306 (*ok_button)->set_min_size(gfx::Size());
301 (*undo_button)->set_ignore_minimum_size(true); 307 (*undo_button)->set_min_size(gfx::Size());
302 string16 ok_label = l10n_util::GetStringUTF16(IDS_OK); 308 string16 ok_label = l10n_util::GetStringUTF16(IDS_OK);
303 string16 undo_label = l10n_util::GetStringUTF16(IDS_ONE_CLICK_BUBBLE_UNDO); 309 string16 undo_label = l10n_util::GetStringUTF16(IDS_ONE_CLICK_BUBBLE_UNDO);
304 (*ok_button)->SetText(undo_label); 310 (*ok_button)->SetText(undo_label);
305 (*ok_button)->SetText(ok_label); 311 (*ok_button)->SetText(ok_label);
306 (*undo_button)->SetText(ok_label); 312 (*undo_button)->SetText(ok_label);
307 (*undo_button)->SetText(undo_label); 313 (*undo_button)->SetText(undo_label);
308 } 314 }
309 315
310 views::Link* OneClickSigninBubbleView::GetAdvancedLink() { 316 views::Link* OneClickSigninBubbleView::GetAdvancedLink() {
311 views::Link* advanced_link= new views::Link( 317 views::Link* advanced_link= new views::Link(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); 359 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST);
354 } 360 }
355 361
356 void OneClickSigninBubbleView::ButtonPressed(views::Button* sender, 362 void OneClickSigninBubbleView::ButtonPressed(views::Button* sender,
357 const ui::Event& event) { 363 const ui::Event& event) {
358 StartFade(false); 364 StartFade(false);
359 base::ResetAndReturn(&start_sync_callback_).Run((sender == ok_button_) ? 365 base::ResetAndReturn(&start_sync_callback_).Run((sender == ok_button_) ?
360 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS : 366 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS :
361 OneClickSigninSyncStarter::UNDO_SYNC); 367 OneClickSigninSyncStarter::UNDO_SYNC);
362 } 368 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698