| 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" |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 253 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 254 views::Label* title_label = new views::Label(); | 254 views::Label* title_label = new views::Label(); |
| 255 title_label->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); | 255 title_label->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); |
| 256 title_label->SetEnabledColor(kTitleColor); | 256 title_label->SetEnabledColor(kTitleColor); |
| 257 layout->StartRow(0, single_column_set_id); | 257 layout->StartRow(0, single_column_set_id); |
| 258 layout->AddView(title_label); | 258 layout->AddView(title_label); |
| 259 | 259 |
| 260 const ListValue* mobiles = service_->GetMobiles(); | 260 const ListValue* mobiles = service_->GetMobiles(); |
| 261 if (mobiles->GetSize() == 1) { | 261 if (mobiles->GetSize() == 1) { |
| 262 string16 name; | 262 string16 name; |
| 263 DictionaryValue* mobile = NULL; | 263 const DictionaryValue* mobile = NULL; |
| 264 if (mobiles->GetDictionary(0, &mobile) && | 264 if (mobiles->GetDictionary(0, &mobile) && |
| 265 mobile->GetString("name", &name)) { | 265 mobile->GetString("name", &name)) { |
| 266 title_label->SetText(l10n_util::GetStringFUTF16( | 266 title_label->SetText(l10n_util::GetStringFUTF16( |
| 267 IDS_CHROME_TO_MOBILE_BUBBLE_SINGLE_TITLE, name)); | 267 IDS_CHROME_TO_MOBILE_BUBBLE_SINGLE_TITLE, name)); |
| 268 } else { | 268 } else { |
| 269 NOTREACHED(); | 269 NOTREACHED(); |
| 270 } | 270 } |
| 271 } else { | 271 } else { |
| 272 title_label->SetText(l10n_util::GetStringUTF16( | 272 title_label->SetText(l10n_util::GetStringUTF16( |
| 273 IDS_CHROME_TO_MOBILE_BUBBLE_MULTI_TITLE)); | 273 IDS_CHROME_TO_MOBILE_BUBBLE_MULTI_TITLE)); |
| 274 | 274 |
| 275 string16 name; | 275 string16 name; |
| 276 DictionaryValue* mobile = NULL; | 276 const DictionaryValue* mobile = NULL; |
| 277 views::RadioButton* radio = NULL; | 277 views::RadioButton* radio = NULL; |
| 278 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); | 278 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); |
| 279 for (size_t index = 0; index < mobiles->GetSize(); ++index) { | 279 for (size_t index = 0; index < mobiles->GetSize(); ++index) { |
| 280 if (mobiles->GetDictionary(index, &mobile) && | 280 if (mobiles->GetDictionary(index, &mobile) && |
| 281 mobile->GetString("name", &name)) { | 281 mobile->GetString("name", &name)) { |
| 282 radio = new views::RadioButton(name, 0); | 282 radio = new views::RadioButton(name, 0); |
| 283 radio->SetEnabledColor(SK_ColorBLACK); | 283 radio->SetEnabledColor(SK_ColorBLACK); |
| 284 radio->SetHoverColor(SK_ColorBLACK); | 284 radio->SetHoverColor(SK_ColorBLACK); |
| 285 radio_buttons_.push_back(radio); | 285 radio_buttons_.push_back(radio); |
| 286 layout->StartRow(0, single_column_set_id); | 286 layout->StartRow(0, single_column_set_id); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 if (mobiles->GetSize() > 1) { | 358 if (mobiles->GetSize() > 1) { |
| 359 DCHECK_EQ(mobiles->GetSize(), radio_buttons_.size()); | 359 DCHECK_EQ(mobiles->GetSize(), radio_buttons_.size()); |
| 360 for (; selected_index < radio_buttons_.size(); ++selected_index) { | 360 for (; selected_index < radio_buttons_.size(); ++selected_index) { |
| 361 if (radio_buttons_[selected_index]->checked()) | 361 if (radio_buttons_[selected_index]->checked()) |
| 362 break; | 362 break; |
| 363 } | 363 } |
| 364 } else { | 364 } else { |
| 365 DCHECK(radio_buttons_.empty()); | 365 DCHECK(radio_buttons_.empty()); |
| 366 } | 366 } |
| 367 | 367 |
| 368 DictionaryValue* mobile = NULL; | 368 const DictionaryValue* mobile = NULL; |
| 369 if (mobiles->GetDictionary(selected_index, &mobile)) { | 369 if (mobiles->GetDictionary(selected_index, &mobile)) { |
| 370 FilePath snapshot = send_copy_->checked() ? snapshot_path_ : FilePath(); | 370 FilePath snapshot = send_copy_->checked() ? snapshot_path_ : FilePath(); |
| 371 service_->SendToMobile(*mobile, snapshot, browser_, | 371 service_->SendToMobile(*mobile, snapshot, browser_, |
| 372 weak_ptr_factory_.GetWeakPtr()); | 372 weak_ptr_factory_.GetWeakPtr()); |
| 373 } else { | 373 } else { |
| 374 NOTREACHED(); | 374 NOTREACHED(); |
| 375 } | 375 } |
| 376 | 376 |
| 377 // Update the view's contents to show the "Sending..." progress animation. | 377 // Update the view's contents to show the "Sending..." progress animation. |
| 378 cancel_->SetEnabled(false); | 378 cancel_->SetEnabled(false); |
| 379 send_->SetEnabled(false); | 379 send_->SetEnabled(false); |
| 380 send_->set_alignment(views::TextButtonBase::ALIGN_LEFT); | 380 send_->set_alignment(views::TextButtonBase::ALIGN_LEFT); |
| 381 progress_animation_.reset(new ui::ThrobAnimation(this)); | 381 progress_animation_.reset(new ui::ThrobAnimation(this)); |
| 382 progress_animation_->SetDuration(kProgressThrobDurationMS); | 382 progress_animation_->SetDuration(kProgressThrobDurationMS); |
| 383 progress_animation_->StartThrobbing(-1); | 383 progress_animation_->StartThrobbing(-1); |
| 384 } | 384 } |
| OLD | NEW |