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 |
163 GtkWidget* content = gtk_vbox_new(FALSE, 5); | 168 GtkWidget* content = gtk_vbox_new(FALSE, 5); |
164 gtk_container_set_border_width(GTK_CONTAINER(content), kContentBorder); | 169 gtk_container_set_border_width(GTK_CONTAINER(content), kContentBorder); |
165 | 170 |
166 // Create and pack the title label; init the selected mobile device. | 171 // Create and pack the title label; init the selected mobile device. |
167 GtkWidget* title = NULL; | 172 GtkWidget* title = NULL; |
168 const ListValue* mobiles = service_->GetMobiles(); | |
169 if (mobiles->GetSize() == 1) { | 173 if (mobiles->GetSize() == 1) { |
170 string16 name; | 174 string16 name; |
171 const DictionaryValue* mobile = NULL; | 175 const DictionaryValue* mobile = NULL; |
172 if (mobiles->GetDictionary(0, &mobile) && | 176 if (mobiles->GetDictionary(0, &mobile) && |
173 mobile->GetString("name", &name)) { | 177 mobile->GetString("name", &name)) { |
174 title = gtk_label_new(l10n_util::GetStringFUTF8( | 178 title = gtk_label_new(l10n_util::GetStringFUTF8( |
175 IDS_CHROME_TO_MOBILE_BUBBLE_SINGLE_TITLE, name).c_str()); | 179 IDS_CHROME_TO_MOBILE_BUBBLE_SINGLE_TITLE, name).c_str()); |
176 } else { | 180 } else { |
177 NOTREACHED(); | 181 NOTREACHED(); |
178 } | 182 } |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 if (gtk_toggle_button_get_active(button)) | 317 if (gtk_toggle_button_get_active(button)) |
314 break; | 318 break; |
315 } | 319 } |
316 } else { | 320 } else { |
317 DCHECK(radio_buttons_.empty()); | 321 DCHECK(radio_buttons_.empty()); |
318 } | 322 } |
319 | 323 |
320 const DictionaryValue* mobile = NULL; | 324 const DictionaryValue* mobile = NULL; |
321 if (mobiles->GetDictionary(selected_index, &mobile)) { | 325 if (mobiles->GetDictionary(selected_index, &mobile)) { |
322 bool snapshot = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(send_copy_)); | 326 bool snapshot = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(send_copy_)); |
323 service_->SendToMobile(mobile, snapshot ? snapshot_path_ : FilePath(), | 327 service_->SendToMobile(*mobile, snapshot ? snapshot_path_ : FilePath(), |
324 browser_, weak_ptr_factory_.GetWeakPtr()); | 328 browser_, weak_ptr_factory_.GetWeakPtr()); |
325 } else { | 329 } else { |
326 NOTREACHED(); | 330 NOTREACHED(); |
327 } | 331 } |
328 | 332 |
329 // Update the view's contents to show the "Sending..." progress animation. | 333 // Update the view's contents to show the "Sending..." progress animation. |
330 gtk_widget_set_sensitive(cancel_, FALSE); | 334 gtk_widget_set_sensitive(cancel_, FALSE); |
331 gtk_widget_set_sensitive(send_, FALSE); | 335 gtk_widget_set_sensitive(send_, FALSE); |
332 gtk_button_set_alignment(GTK_BUTTON(send_), 0, 0.5); | 336 gtk_button_set_alignment(GTK_BUTTON(send_), 0, 0.5); |
333 progress_animation_.reset(new ui::ThrobAnimation(this)); | 337 progress_animation_.reset(new ui::ThrobAnimation(this)); |
334 progress_animation_->SetDuration(kProgressThrobDurationMS); | 338 progress_animation_->SetDuration(kProgressThrobDurationMS); |
335 progress_animation_->StartThrobbing(-1); | 339 progress_animation_->StartThrobbing(-1); |
336 } | 340 } |
OLD | NEW |