| 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/chrome_to_mobile_bubble_view.h" | 5 #include "chrome/browser/ui/views/chrome_to_mobile_bubble_view.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/chrome_to_mobile_service.h" | 15 #include "chrome/browser/chrome_to_mobile_service.h" |
| 16 #include "chrome/browser/chrome_to_mobile_service_factory.h" | 16 #include "chrome/browser/chrome_to_mobile_service_factory.h" |
| 17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 18 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| 19 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
| 20 #include "ui/base/animation/throb_animation.h" | 20 #include "ui/base/animation/throb_animation.h" |
| 21 #include "ui/base/keycodes/keyboard_codes.h" | 21 #include "ui/base/keycodes/keyboard_codes.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 23 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
| 24 #include "ui/base/text/bytes_formatting.h" | 24 #include "ui/base/text/bytes_formatting.h" |
| 25 #include "ui/views/controls/button/checkbox.h" | 25 #include "ui/views/controls/button/checkbox.h" |
| 26 #include "ui/views/controls/button/label_button.h" |
| 26 #include "ui/views/controls/button/radio_button.h" | 27 #include "ui/views/controls/button/radio_button.h" |
| 27 #include "ui/views/controls/button/text_button.h" | 28 #include "ui/views/controls/button/text_button.h" |
| 28 #include "ui/views/controls/label.h" | 29 #include "ui/views/controls/label.h" |
| 29 #include "ui/views/controls/link.h" | 30 #include "ui/views/controls/link.h" |
| 30 #include "ui/views/layout/grid_layout.h" | 31 #include "ui/views/layout/grid_layout.h" |
| 31 #include "ui/views/layout/layout_constants.h" | 32 #include "ui/views/layout/layout_constants.h" |
| 32 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
| 33 | 34 |
| 34 using views::GridLayout; | 35 using views::GridLayout; |
| 35 | 36 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 send_copy_->SetEnabled(true); | 160 send_copy_->SetEnabled(true); |
| 160 } else { | 161 } else { |
| 161 send_copy_->SetText(l10n_util::GetStringUTF16( | 162 send_copy_->SetText(l10n_util::GetStringUTF16( |
| 162 IDS_CHROME_TO_MOBILE_BUBBLE_SEND_COPY_FAILED)); | 163 IDS_CHROME_TO_MOBILE_BUBBLE_SEND_COPY_FAILED)); |
| 163 } | 164 } |
| 164 Layout(); | 165 Layout(); |
| 165 } | 166 } |
| 166 | 167 |
| 167 void ChromeToMobileBubbleView::OnSendComplete(bool success) { | 168 void ChromeToMobileBubbleView::OnSendComplete(bool success) { |
| 168 progress_animation_->Stop(); | 169 progress_animation_->Stop(); |
| 169 send_->set_alignment(views::TextButtonBase::ALIGN_CENTER); | 170 send_->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 170 | 171 |
| 171 if (success) { | 172 if (success) { |
| 172 send_->SetText(l10n_util::GetStringUTF16(IDS_CHROME_TO_MOBILE_BUBBLE_SENT)); | 173 send_->SetText(l10n_util::GetStringUTF16(IDS_CHROME_TO_MOBILE_BUBBLE_SENT)); |
| 173 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 174 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 174 base::Bind(&ChromeToMobileBubbleView::Hide), | 175 base::Bind(&ChromeToMobileBubbleView::Hide), |
| 175 base::TimeDelta::FromSeconds(kAutoCloseDelay)); | 176 base::TimeDelta::FromSeconds(kAutoCloseDelay)); |
| 176 } else { | 177 } else { |
| 177 send_->SetText( | 178 send_->SetText( |
| 178 l10n_util::GetStringUTF16(IDS_CHROME_TO_MOBILE_BUBBLE_ERROR)); | 179 l10n_util::GetStringUTF16(IDS_CHROME_TO_MOBILE_BUBBLE_ERROR)); |
| 179 views::Label* error_label = new views::Label( | 180 views::Label* error_label = new views::Label( |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 send_copy_->SetEnabledColor(SK_ColorBLACK); | 270 send_copy_->SetEnabledColor(SK_ColorBLACK); |
| 270 send_copy_->SetHoverColor(SK_ColorBLACK); | 271 send_copy_->SetHoverColor(SK_ColorBLACK); |
| 271 send_copy_->SetEnabled(false); | 272 send_copy_->SetEnabled(false); |
| 272 layout->StartRow(0, kSingleColumnSetId); | 273 layout->StartRow(0, kSingleColumnSetId); |
| 273 layout->AddView(send_copy_); | 274 layout->AddView(send_copy_); |
| 274 | 275 |
| 275 views::Link* learn_more = | 276 views::Link* learn_more = |
| 276 new views::Link(l10n_util::GetStringUTF16(IDS_LEARN_MORE)); | 277 new views::Link(l10n_util::GetStringUTF16(IDS_LEARN_MORE)); |
| 277 learn_more->set_listener(this); | 278 learn_more->set_listener(this); |
| 278 | 279 |
| 279 send_ = new views::NativeTextButton( | 280 send_ = new views::LabelButton( |
| 280 this, l10n_util::GetStringUTF16(IDS_CHROME_TO_MOBILE_BUBBLE_SEND)); | 281 this, l10n_util::GetStringUTF16(IDS_CHROME_TO_MOBILE_BUBBLE_SEND)); |
| 282 send_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| 281 send_->SetIsDefault(true); | 283 send_->SetIsDefault(true); |
| 282 cancel_ = new views::NativeTextButton( | 284 cancel_ = new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_CANCEL)); |
| 283 this, l10n_util::GetStringUTF16(IDS_CANCEL)); | 285 cancel_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| 284 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); | 286 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); |
| 285 layout->StartRow(0, kButtonColumnSetId); | 287 layout->StartRow(0, kButtonColumnSetId); |
| 286 layout->AddView(learn_more); | 288 layout->AddView(learn_more); |
| 287 layout->AddView(send_); | 289 layout->AddView(send_); |
| 288 layout->AddView(cancel_); | 290 layout->AddView(cancel_); |
| 289 | 291 |
| 290 AddAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); | 292 AddAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); |
| 291 } | 293 } |
| 292 | 294 |
| 293 ChromeToMobileBubbleView::ChromeToMobileBubbleView(views::View* anchor_view, | 295 ChromeToMobileBubbleView::ChromeToMobileBubbleView(views::View* anchor_view, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 send_copy_->checked() ? snapshot_path_ : base::FilePath(); | 341 send_copy_->checked() ? snapshot_path_ : base::FilePath(); |
| 340 service_->SendToMobile(mobile, snapshot, browser_, | 342 service_->SendToMobile(mobile, snapshot, browser_, |
| 341 weak_ptr_factory_.GetWeakPtr()); | 343 weak_ptr_factory_.GetWeakPtr()); |
| 342 } else { | 344 } else { |
| 343 NOTREACHED(); | 345 NOTREACHED(); |
| 344 } | 346 } |
| 345 | 347 |
| 346 // Update the view's contents to show the "Sending..." progress animation. | 348 // Update the view's contents to show the "Sending..." progress animation. |
| 347 cancel_->SetEnabled(false); | 349 cancel_->SetEnabled(false); |
| 348 send_->SetEnabled(false); | 350 send_->SetEnabled(false); |
| 349 send_->set_alignment(views::TextButtonBase::ALIGN_LEFT); | 351 send_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 350 progress_animation_.reset(new ui::ThrobAnimation(this)); | 352 progress_animation_.reset(new ui::ThrobAnimation(this)); |
| 351 progress_animation_->SetDuration(kProgressThrobDurationMS); | 353 progress_animation_->SetDuration(kProgressThrobDurationMS); |
| 352 progress_animation_->StartThrobbing(-1); | 354 progress_animation_->StartThrobbing(-1); |
| 353 } | 355 } |
| OLD | NEW |