OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/first_run_bubble.h" | 5 #include "chrome/browser/ui/views/first_run_bubble.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/first_run/first_run.h" | 8 #include "chrome/browser/first_run/first_run.h" |
9 #include "chrome/browser/search_engines/util.h" | 9 #include "chrome/browser/search_engines/util.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 label2_(NULL), | 104 label2_(NULL), |
105 label3_(NULL), | 105 label3_(NULL), |
106 keep_button_(NULL), | 106 keep_button_(NULL), |
107 change_button_(NULL), | 107 change_button_(NULL), |
108 profile_(profile) { | 108 profile_(profile) { |
109 const gfx::Font& font = | 109 const gfx::Font& font = |
110 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont); | 110 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont); |
111 | 111 |
112 label1_ = new views::Label(l10n_util::GetStringUTF16(IDS_FR_BUBBLE_TITLE)); | 112 label1_ = new views::Label(l10n_util::GetStringUTF16(IDS_FR_BUBBLE_TITLE)); |
113 label1_->SetFont(font.DeriveFont(3, gfx::Font::BOLD)); | 113 label1_->SetFont(font.DeriveFont(3, gfx::Font::BOLD)); |
| 114 label1_->SetBackgroundColor(Bubble::kBackgroundColor); |
114 label1_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 115 label1_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
115 AddChildView(label1_); | 116 AddChildView(label1_); |
116 | 117 |
117 gfx::Size ps = GetPreferredSize(); | 118 gfx::Size ps = GetPreferredSize(); |
118 | 119 |
119 label2_ = new views::Label(l10n_util::GetStringUTF16(IDS_FR_BUBBLE_SUBTEXT)); | 120 label2_ = new views::Label(l10n_util::GetStringUTF16(IDS_FR_BUBBLE_SUBTEXT)); |
120 label2_->SetMultiLine(true); | 121 label2_->SetMultiLine(true); |
121 label2_->SetFont(font); | 122 label2_->SetFont(font); |
| 123 label2_->SetBackgroundColor(Bubble::kBackgroundColor); |
122 label2_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 124 label2_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
123 label2_->SizeToFit(ps.width() - kBubblePadding * 2); | 125 label2_->SizeToFit(ps.width() - kBubblePadding * 2); |
124 AddChildView(label2_); | 126 AddChildView(label2_); |
125 | 127 |
126 string16 question_str = l10n_util::GetStringFUTF16( | 128 string16 question_str = l10n_util::GetStringFUTF16( |
127 IDS_FR_BUBBLE_QUESTION, | 129 IDS_FR_BUBBLE_QUESTION, |
128 GetDefaultSearchEngineName(profile)); | 130 GetDefaultSearchEngineName(profile)); |
129 label3_ = new views::Label(question_str); | 131 label3_ = new views::Label(question_str); |
130 label3_->SetMultiLine(true); | 132 label3_->SetMultiLine(true); |
131 label3_->SetFont(font); | 133 label3_->SetFont(font); |
| 134 label3_->SetBackgroundColor(Bubble::kBackgroundColor); |
132 label3_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 135 label3_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
133 label3_->SizeToFit(ps.width() - kBubblePadding * 2); | 136 label3_->SizeToFit(ps.width() - kBubblePadding * 2); |
134 AddChildView(label3_); | 137 AddChildView(label3_); |
135 | 138 |
136 std::wstring keep_str = UTF16ToWide(l10n_util::GetStringFUTF16( | 139 std::wstring keep_str = UTF16ToWide(l10n_util::GetStringFUTF16( |
137 IDS_FR_BUBBLE_OK, | 140 IDS_FR_BUBBLE_OK, |
138 GetDefaultSearchEngineName(profile))); | 141 GetDefaultSearchEngineName(profile))); |
139 keep_button_ = new views::NativeTextButton(this, keep_str); | 142 keep_button_ = new views::NativeTextButton(this, keep_str); |
140 keep_button_->SetIsDefault(true); | 143 keep_button_->SetIsDefault(true); |
141 AddChildView(keep_button_); | 144 AddChildView(keep_button_); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 label2_(NULL), | 271 label2_(NULL), |
269 label3_(NULL), | 272 label3_(NULL), |
270 close_button_(NULL), | 273 close_button_(NULL), |
271 profile_(profile) { | 274 profile_(profile) { |
272 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 275 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
273 const gfx::Font& font = rb.GetFont(ResourceBundle::MediumFont); | 276 const gfx::Font& font = rb.GetFont(ResourceBundle::MediumFont); |
274 | 277 |
275 label1_ = new views::Label( | 278 label1_ = new views::Label( |
276 l10n_util::GetStringUTF16(IDS_FR_OEM_BUBBLE_TITLE_1)); | 279 l10n_util::GetStringUTF16(IDS_FR_OEM_BUBBLE_TITLE_1)); |
277 label1_->SetFont(font.DeriveFont(3, gfx::Font::BOLD)); | 280 label1_->SetFont(font.DeriveFont(3, gfx::Font::BOLD)); |
278 label1_->SetColor(SK_ColorRED); | 281 label1_->SetBackgroundColor(Bubble::kBackgroundColor); |
| 282 label1_->SetEnabledColor(SK_ColorRED); |
279 label1_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 283 label1_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
280 AddChildView(label1_); | 284 AddChildView(label1_); |
281 | 285 |
282 label2_ = new views::Label( | 286 label2_ = new views::Label( |
283 l10n_util::GetStringUTF16(IDS_FR_OEM_BUBBLE_TITLE_2)); | 287 l10n_util::GetStringUTF16(IDS_FR_OEM_BUBBLE_TITLE_2)); |
284 label2_->SetFont(font.DeriveFont(3, gfx::Font::BOLD)); | 288 label2_->SetFont(font.DeriveFont(3, gfx::Font::BOLD)); |
| 289 label2_->SetBackgroundColor(Bubble::kBackgroundColor); |
285 label2_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 290 label2_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
286 AddChildView(label2_); | 291 AddChildView(label2_); |
287 | 292 |
288 gfx::Size ps = GetPreferredSize(); | 293 gfx::Size ps = GetPreferredSize(); |
289 | 294 |
290 label3_ = new views::Label( | 295 label3_ = new views::Label( |
291 l10n_util::GetStringUTF16(IDS_FR_OEM_BUBBLE_SUBTEXT)); | 296 l10n_util::GetStringUTF16(IDS_FR_OEM_BUBBLE_SUBTEXT)); |
292 label3_->SetMultiLine(true); | 297 label3_->SetMultiLine(true); |
293 label3_->SetFont(font); | 298 label3_->SetFont(font); |
| 299 label3_->SetBackgroundColor(Bubble::kBackgroundColor); |
294 label3_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 300 label3_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
295 label3_->SizeToFit(ps.width() - kOEMBubblePadding * 2); | 301 label3_->SizeToFit(ps.width() - kOEMBubblePadding * 2); |
296 AddChildView(label3_); | 302 AddChildView(label3_); |
297 | 303 |
298 close_button_ = new views::ImageButton(this); | 304 close_button_ = new views::ImageButton(this); |
299 close_button_->SetImage(views::CustomButton::BS_NORMAL, | 305 close_button_->SetImage(views::CustomButton::BS_NORMAL, |
300 rb.GetBitmapNamed(IDR_CLOSE_BAR)); | 306 rb.GetBitmapNamed(IDR_CLOSE_BAR)); |
301 close_button_->SetImage(views::CustomButton::BS_HOT, | 307 close_button_->SetImage(views::CustomButton::BS_HOT, |
302 rb.GetBitmapNamed(IDR_CLOSE_BAR_H)); | 308 rb.GetBitmapNamed(IDR_CLOSE_BAR_H)); |
303 close_button_->SetImage(views::CustomButton::BS_PUSHED, | 309 close_button_->SetImage(views::CustomButton::BS_PUSHED, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 profile_(profile), | 422 profile_(profile), |
417 label1_(NULL), | 423 label1_(NULL), |
418 label2_(NULL) { | 424 label2_(NULL) { |
419 const gfx::Font& font = | 425 const gfx::Font& font = |
420 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont); | 426 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont); |
421 | 427 |
422 label1_ = new views::Label(l10n_util::GetStringFUTF16( | 428 label1_ = new views::Label(l10n_util::GetStringFUTF16( |
423 IDS_FR_SE_BUBBLE_TITLE, | 429 IDS_FR_SE_BUBBLE_TITLE, |
424 GetDefaultSearchEngineName(profile_))); | 430 GetDefaultSearchEngineName(profile_))); |
425 label1_->SetFont(font.DeriveFont(3, gfx::Font::BOLD)); | 431 label1_->SetFont(font.DeriveFont(3, gfx::Font::BOLD)); |
| 432 label1_->SetBackgroundColor(Bubble::kBackgroundColor); |
426 label1_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 433 label1_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
427 AddChildView(label1_); | 434 AddChildView(label1_); |
428 | 435 |
429 gfx::Size ps = GetPreferredSize(); | 436 gfx::Size ps = GetPreferredSize(); |
430 | 437 |
431 label2_ = new views::Label( | 438 label2_ = new views::Label( |
432 l10n_util::GetStringUTF16(IDS_FR_BUBBLE_SUBTEXT)); | 439 l10n_util::GetStringUTF16(IDS_FR_BUBBLE_SUBTEXT)); |
433 label2_->SetMultiLine(true); | 440 label2_->SetMultiLine(true); |
434 label2_->SetFont(font); | 441 label2_->SetFont(font); |
| 442 label2_->SetBackgroundColor(Bubble::kBackgroundColor); |
435 label2_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 443 label2_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
436 label2_->SizeToFit(ps.width() - kBubblePadding * 2); | 444 label2_->SizeToFit(ps.width() - kBubblePadding * 2); |
437 AddChildView(label2_); | 445 AddChildView(label2_); |
438 } | 446 } |
439 | 447 |
440 void FirstRunMinimalBubbleView::BubbleShown() { | 448 void FirstRunMinimalBubbleView::BubbleShown() { |
441 RequestFocus(); | 449 RequestFocus(); |
442 } | 450 } |
443 | 451 |
444 void FirstRunMinimalBubbleView::Layout() { | 452 void FirstRunMinimalBubbleView::Layout() { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 // Keep window from automatically closing until kLingerTime has passed. | 565 // Keep window from automatically closing until kLingerTime has passed. |
558 if (::IsWindowEnabled(GetParent())) | 566 if (::IsWindowEnabled(GetParent())) |
559 Bubble::OnActivate(action, minimized, window); | 567 Bubble::OnActivate(action, minimized, window); |
560 } | 568 } |
561 | 569 |
562 void FirstRunBubble::BubbleClosing(Bubble* bubble, bool closed_by_escape) { | 570 void FirstRunBubble::BubbleClosing(Bubble* bubble, bool closed_by_escape) { |
563 // Make sure our parent window is re-enabled. | 571 // Make sure our parent window is re-enabled. |
564 if (!IsWindowEnabled(GetParent())) | 572 if (!IsWindowEnabled(GetParent())) |
565 ::EnableWindow(GetParent(), true); | 573 ::EnableWindow(GetParent(), true); |
566 } | 574 } |
OLD | NEW |