| 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/gtk/chrome_to_mobile_bubble_gtk.h" | 5 #include "chrome/browser/ui/gtk/chrome_to_mobile_bubble_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 cancel_(NULL), | 153 cancel_(NULL), |
| 154 send_(NULL), | 154 send_(NULL), |
| 155 error_(NULL), | 155 error_(NULL), |
| 156 bubble_(NULL) { | 156 bubble_(NULL) { |
| 157 DCHECK(service_->HasMobiles()); | 157 DCHECK(service_->HasMobiles()); |
| 158 service_->LogMetric(ChromeToMobileService::BUBBLE_SHOWN); | 158 service_->LogMetric(ChromeToMobileService::BUBBLE_SHOWN); |
| 159 | 159 |
| 160 // Generate the MHTML snapshot now to report its size in the bubble. | 160 // Generate the MHTML snapshot now to report its size in the bubble. |
| 161 service_->GenerateSnapshot(browser_, weak_ptr_factory_.GetWeakPtr()); | 161 service_->GenerateSnapshot(browser_, weak_ptr_factory_.GetWeakPtr()); |
| 162 | 162 |
| 163 // Request a mobile device list update. | |
| 164 service_->RequestMobileListUpdate(); | |
| 165 | |
| 166 const ListValue* mobiles = service_->GetMobiles(); | |
| 167 | |
| 168 GtkWidget* content = gtk_vbox_new(FALSE, 5); | 163 GtkWidget* content = gtk_vbox_new(FALSE, 5); |
| 169 gtk_container_set_border_width(GTK_CONTAINER(content), kContentBorder); | 164 gtk_container_set_border_width(GTK_CONTAINER(content), kContentBorder); |
| 170 | 165 |
| 171 // Create and pack the title label; init the selected mobile device. | 166 // Create and pack the title label; init the selected mobile device. |
| 172 GtkWidget* title = NULL; | 167 GtkWidget* title = NULL; |
| 168 const ListValue* mobiles = service_->GetMobiles(); |
| 173 if (mobiles->GetSize() == 1) { | 169 if (mobiles->GetSize() == 1) { |
| 174 string16 name; | 170 string16 name; |
| 175 const DictionaryValue* mobile = NULL; | 171 const DictionaryValue* mobile = NULL; |
| 176 if (mobiles->GetDictionary(0, &mobile) && | 172 if (mobiles->GetDictionary(0, &mobile) && |
| 177 mobile->GetString("name", &name)) { | 173 mobile->GetString("name", &name)) { |
| 178 title = gtk_label_new(l10n_util::GetStringFUTF8( | 174 title = gtk_label_new(l10n_util::GetStringFUTF8( |
| 179 IDS_CHROME_TO_MOBILE_BUBBLE_SINGLE_TITLE, name).c_str()); | 175 IDS_CHROME_TO_MOBILE_BUBBLE_SINGLE_TITLE, name).c_str()); |
| 180 } else { | 176 } else { |
| 181 NOTREACHED(); | 177 NOTREACHED(); |
| 182 } | 178 } |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 if (gtk_toggle_button_get_active(button)) | 313 if (gtk_toggle_button_get_active(button)) |
| 318 break; | 314 break; |
| 319 } | 315 } |
| 320 } else { | 316 } else { |
| 321 DCHECK(radio_buttons_.empty()); | 317 DCHECK(radio_buttons_.empty()); |
| 322 } | 318 } |
| 323 | 319 |
| 324 const DictionaryValue* mobile = NULL; | 320 const DictionaryValue* mobile = NULL; |
| 325 if (mobiles->GetDictionary(selected_index, &mobile)) { | 321 if (mobiles->GetDictionary(selected_index, &mobile)) { |
| 326 bool snapshot = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(send_copy_)); | 322 bool snapshot = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(send_copy_)); |
| 327 service_->SendToMobile(*mobile, snapshot ? snapshot_path_ : FilePath(), | 323 service_->SendToMobile(mobile, snapshot ? snapshot_path_ : FilePath(), |
| 328 browser_, weak_ptr_factory_.GetWeakPtr()); | 324 browser_, weak_ptr_factory_.GetWeakPtr()); |
| 329 } else { | 325 } else { |
| 330 NOTREACHED(); | 326 NOTREACHED(); |
| 331 } | 327 } |
| 332 | 328 |
| 333 // Update the view's contents to show the "Sending..." progress animation. | 329 // Update the view's contents to show the "Sending..." progress animation. |
| 334 gtk_widget_set_sensitive(cancel_, FALSE); | 330 gtk_widget_set_sensitive(cancel_, FALSE); |
| 335 gtk_widget_set_sensitive(send_, FALSE); | 331 gtk_widget_set_sensitive(send_, FALSE); |
| 336 gtk_button_set_alignment(GTK_BUTTON(send_), 0, 0.5); | 332 gtk_button_set_alignment(GTK_BUTTON(send_), 0, 0.5); |
| 337 progress_animation_.reset(new ui::ThrobAnimation(this)); | 333 progress_animation_.reset(new ui::ThrobAnimation(this)); |
| 338 progress_animation_->SetDuration(kProgressThrobDurationMS); | 334 progress_animation_->SetDuration(kProgressThrobDurationMS); |
| 339 progress_animation_->StartThrobbing(-1); | 335 progress_animation_->StartThrobbing(-1); |
| 340 } | 336 } |
| OLD | NEW |