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/gtk/download/download_item_gtk.h" | 5 #include "chrome/browser/ui/gtk/download/download_item_gtk.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 const int kTooltipMaxWidth = 1000; | 55 const int kTooltipMaxWidth = 1000; |
56 | 56 |
57 // The minimum width we will ever draw the download item. Used as a lower bound | 57 // The minimum width we will ever draw the download item. Used as a lower bound |
58 // during animation. This number comes from the width of the images used to | 58 // during animation. This number comes from the width of the images used to |
59 // make the download item. | 59 // make the download item. |
60 const int kMinDownloadItemWidth = download_util::kSmallProgressIconSize; | 60 const int kMinDownloadItemWidth = download_util::kSmallProgressIconSize; |
61 | 61 |
62 // New download item animation speed in milliseconds. | 62 // New download item animation speed in milliseconds. |
63 const int kNewItemAnimationDurationMs = 800; | 63 const int kNewItemAnimationDurationMs = 800; |
64 | 64 |
65 // Dangerous download prompt transition animation speed in milliseconds. | |
66 const int kDangerPromptAnimationDurationMs = 800; | |
67 | |
65 // How long the 'download complete/interrupted' animation should last for. | 68 // How long the 'download complete/interrupted' animation should last for. |
66 const int kCompleteAnimationDurationMs = 2500; | 69 const int kCompleteAnimationDurationMs = 2500; |
67 | 70 |
68 // Width of the body area of the download item. | 71 // Width of the body area of the download item. |
69 // TODO(estade): get rid of the fudge factor. http://crbug.com/18692 | 72 // TODO(estade): get rid of the fudge factor. http://crbug.com/18692 |
70 const int kBodyWidth = kTextWidth + 50 + download_util::kSmallProgressIconSize; | 73 const int kBodyWidth = kTextWidth + 50 + download_util::kSmallProgressIconSize; |
71 | 74 |
72 // The font size of the text, and that size rounded down to the nearest integer | 75 // The font size of the text, and that size rounded down to the nearest integer |
73 // for the size of the arrow in GTK theme mode. | 76 // for the size of the arrow in GTK theme mode. |
74 const double kTextSize = 13.4; // 13.4px == 10pt @ 96dpi | 77 const double kTextSize = 13.4; // 13.4px == 10pt @ 96dpi |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 gtk_box_pack_start(GTK_BOX(shelf_hbox), hbox_.get(), FALSE, FALSE, 0); | 180 gtk_box_pack_start(GTK_BOX(shelf_hbox), hbox_.get(), FALSE, FALSE, 0); |
178 // Insert as the leftmost item. | 181 // Insert as the leftmost item. |
179 gtk_box_reorder_child(GTK_BOX(shelf_hbox), hbox_.get(), 0); | 182 gtk_box_reorder_child(GTK_BOX(shelf_hbox), hbox_.get(), 0); |
180 | 183 |
181 get_download()->AddObserver(this); | 184 get_download()->AddObserver(this); |
182 | 185 |
183 new_item_animation_.reset(new ui::SlideAnimation(this)); | 186 new_item_animation_.reset(new ui::SlideAnimation(this)); |
184 new_item_animation_->SetSlideDuration(kNewItemAnimationDurationMs); | 187 new_item_animation_->SetSlideDuration(kNewItemAnimationDurationMs); |
185 gtk_widget_show_all(hbox_.get()); | 188 gtk_widget_show_all(hbox_.get()); |
186 | 189 |
187 if (IsDangerous()) { | 190 if (IsDangerous()) |
188 // Hide the download item components for now. | 191 ShowDangerPrompt(); |
189 gtk_widget_set_no_show_all(body_.get(), TRUE); | |
190 gtk_widget_set_no_show_all(menu_button_, TRUE); | |
191 gtk_widget_hide(body_.get()); | |
192 gtk_widget_hide(menu_button_); | |
193 | |
194 // Create an hbox to hold it all. | |
195 dangerous_hbox_.Own(gtk_hbox_new(FALSE, kDangerousElementPadding)); | |
196 | |
197 // Add padding at the beginning and end. The hbox will add padding between | |
198 // the empty labels and the other elements. | |
199 GtkWidget* empty_label_a = gtk_label_new(NULL); | |
200 GtkWidget* empty_label_b = gtk_label_new(NULL); | |
201 gtk_box_pack_start(GTK_BOX(dangerous_hbox_.get()), empty_label_a, | |
202 FALSE, FALSE, 0); | |
203 gtk_box_pack_end(GTK_BOX(dangerous_hbox_.get()), empty_label_b, | |
204 FALSE, FALSE, 0); | |
205 | |
206 // Create the warning icon. | |
207 dangerous_image_ = gtk_image_new(); | |
208 gtk_box_pack_start(GTK_BOX(dangerous_hbox_.get()), dangerous_image_, | |
209 FALSE, FALSE, 0); | |
210 | |
211 dangerous_label_ = gtk_label_new(NULL); | |
212 // We pass TRUE, TRUE so that the label will condense to less than its | |
213 // request when the animation is going on. | |
214 gtk_box_pack_start(GTK_BOX(dangerous_hbox_.get()), dangerous_label_, | |
215 TRUE, TRUE, 0); | |
216 | |
217 // Create the nevermind button. | |
218 GtkWidget* dangerous_decline = gtk_button_new_with_label( | |
219 l10n_util::GetStringUTF8(IDS_DISCARD_DOWNLOAD).c_str()); | |
220 g_signal_connect(dangerous_decline, "clicked", | |
221 G_CALLBACK(OnDangerousDeclineThunk), this); | |
222 gtk_util::CenterWidgetInHBox(dangerous_hbox_.get(), dangerous_decline, | |
223 false, 0); | |
224 | |
225 // Create the ok button. | |
226 GtkWidget* dangerous_accept = gtk_button_new_with_label( | |
227 l10n_util::GetStringUTF8( | |
228 ChromeDownloadManagerDelegate::IsExtensionDownload( | |
229 download_model->download()) ? | |
230 IDS_CONTINUE_EXTENSION_DOWNLOAD : | |
231 IDS_CONFIRM_DOWNLOAD).c_str()); | |
232 g_signal_connect(dangerous_accept, "clicked", | |
233 G_CALLBACK(OnDangerousAcceptThunk), this); | |
234 gtk_util::CenterWidgetInHBox(dangerous_hbox_.get(), dangerous_accept, false, | |
235 0); | |
236 | |
237 // Put it in an alignment so that padding will be added on the left and | |
238 // right. | |
239 dangerous_prompt_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); | |
240 gtk_alignment_set_padding(GTK_ALIGNMENT(dangerous_prompt_), | |
241 0, 0, kDangerousElementPadding, kDangerousElementPadding); | |
242 gtk_container_add(GTK_CONTAINER(dangerous_prompt_), dangerous_hbox_.get()); | |
243 gtk_box_pack_start(GTK_BOX(hbox_.get()), dangerous_prompt_, FALSE, FALSE, | |
244 0); | |
245 gtk_widget_set_app_paintable(dangerous_prompt_, TRUE); | |
246 gtk_widget_set_redraw_on_allocate(dangerous_prompt_, TRUE); | |
247 g_signal_connect(dangerous_prompt_, "expose-event", | |
248 G_CALLBACK(OnDangerousPromptExposeThunk), this); | |
249 gtk_widget_show_all(dangerous_prompt_); | |
250 } | |
251 | 192 |
252 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 193 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
253 content::Source<ThemeService>(theme_service_)); | 194 content::Source<ThemeService>(theme_service_)); |
254 theme_service_->InitThemesFor(this); | 195 theme_service_->InitThemesFor(this); |
255 | 196 |
256 // Set the initial width of the widget to be animated. | |
257 if (IsDangerous()) { | 197 if (IsDangerous()) { |
258 gtk_widget_set_size_request(dangerous_hbox_.get(), | 198 gtk_widget_set_size_request(dangerous_hbox_.get(), |
259 dangerous_hbox_start_width_, -1); | 199 dangerous_hbox_start_width_, -1); |
260 } else { | 200 } else { |
261 gtk_widget_set_size_request(body_.get(), kMinDownloadItemWidth, -1); | 201 gtk_widget_set_size_request(body_.get(), kMinDownloadItemWidth, -1); |
262 } | 202 } |
263 | 203 |
264 new_item_animation_->Show(); | 204 new_item_animation_->Show(); |
265 | 205 |
266 complete_animation_.SetTweenType(ui::Tween::LINEAR); | 206 complete_animation_.SetTweenType(ui::Tween::LINEAR); |
(...skipping 30 matching lines...) Expand all Loading... | |
297 // We have been approved. | 237 // We have been approved. |
298 gtk_widget_set_no_show_all(body_.get(), FALSE); | 238 gtk_widget_set_no_show_all(body_.get(), FALSE); |
299 gtk_widget_set_no_show_all(menu_button_, FALSE); | 239 gtk_widget_set_no_show_all(menu_button_, FALSE); |
300 gtk_widget_show_all(hbox_.get()); | 240 gtk_widget_show_all(hbox_.get()); |
301 gtk_widget_destroy(dangerous_prompt_); | 241 gtk_widget_destroy(dangerous_prompt_); |
302 gtk_widget_set_size_request(body_.get(), kBodyWidth, -1); | 242 gtk_widget_set_size_request(body_.get(), kBodyWidth, -1); |
303 dangerous_prompt_ = NULL; | 243 dangerous_prompt_ = NULL; |
304 | 244 |
305 // We may free some shelf space for showing more download items. | 245 // We may free some shelf space for showing more download items. |
306 parent_shelf_->MaybeShowMoreDownloadItems(); | 246 parent_shelf_->MaybeShowMoreDownloadItems(); |
247 } else if (dangerous_prompt_ == NULL && IsDangerous()) { | |
248 ShowDangerPrompt(); | |
249 gtk_widget_set_size_request(dangerous_hbox_.get(), kBodyWidth, -1); | |
250 // Complete the new_item_animation_, so we don't race each other. | |
251 new_item_animation_->Reset(1); | |
252 danger_prompt_animation_.reset(new ui::SlideAnimation(this)); | |
253 danger_prompt_animation_->SetSlideDuration( | |
254 kDangerPromptAnimationDurationMs); | |
255 danger_prompt_animation_->Show(); | |
307 } | 256 } |
308 | 257 |
309 if (download->GetUserVerifiedFilePath() != icon_filepath_) { | 258 if (download->GetUserVerifiedFilePath() != icon_filepath_) { |
310 // Turns out the file path is "Unconfirmed %d.crdownload" for dangerous | 259 // Turns out the file path is "Unconfirmed %d.crdownload" for dangerous |
311 // downloads. When the download is confirmed, the file is renamed on | 260 // downloads. When the download is confirmed, the file is renamed on |
312 // another thread, so reload the icon if the download filename changes. | 261 // another thread, so reload the icon if the download filename changes. |
313 LoadIcon(); | 262 LoadIcon(); |
314 | 263 |
315 UpdateTooltip(); | 264 UpdateTooltip(); |
316 } | 265 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 NOTREACHED(); | 306 NOTREACHED(); |
358 } | 307 } |
359 | 308 |
360 status_text_ = UTF16ToUTF8(download_model_->GetStatusText()); | 309 status_text_ = UTF16ToUTF8(download_model_->GetStatusText()); |
361 UpdateStatusLabel(status_text_); | 310 UpdateStatusLabel(status_text_); |
362 } | 311 } |
363 | 312 |
364 void DownloadItemGtk::AnimationProgressed(const ui::Animation* animation) { | 313 void DownloadItemGtk::AnimationProgressed(const ui::Animation* animation) { |
365 if (animation == &complete_animation_) { | 314 if (animation == &complete_animation_) { |
366 gtk_widget_queue_draw(progress_area_.get()); | 315 gtk_widget_queue_draw(progress_area_.get()); |
316 } else if (danger_prompt_animation_.get() && | |
317 animation == danger_prompt_animation_.get()) { | |
318 int progress = static_cast<int>((dangerous_hbox_full_width_ - | |
319 kBodyWidth) * | |
320 animation->GetCurrentValue()); | |
321 int showing_width = kBodyWidth + progress; | |
322 gtk_widget_set_size_request(dangerous_hbox_.get(), showing_width, -1); | |
367 } else { | 323 } else { |
368 DCHECK(animation == new_item_animation_.get()); | 324 DCHECK(animation == new_item_animation_.get()); |
369 if (IsDangerous()) { | 325 if (IsDangerous()) { |
370 int progress = static_cast<int>((dangerous_hbox_full_width_ - | 326 int progress = static_cast<int>((dangerous_hbox_full_width_ - |
371 dangerous_hbox_start_width_) * | 327 dangerous_hbox_start_width_) * |
372 animation->GetCurrentValue()); | 328 animation->GetCurrentValue()); |
373 int showing_width = dangerous_hbox_start_width_ + progress; | 329 int showing_width = dangerous_hbox_start_width_ + progress; |
374 gtk_widget_set_size_request(dangerous_hbox_.get(), showing_width, -1); | 330 gtk_widget_set_size_request(dangerous_hbox_.get(), showing_width, -1); |
375 } else { | 331 } else { |
376 int showing_width = std::max(kMinDownloadItemWidth, | 332 int showing_width = std::max(kMinDownloadItemWidth, |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
551 gtk_label_set_text(GTK_LABEL(status_label_), status_text.c_str()); | 507 gtk_label_set_text(GTK_LABEL(status_label_), status_text.c_str()); |
552 } | 508 } |
553 | 509 |
554 void DownloadItemGtk::UpdateDangerWarning() { | 510 void DownloadItemGtk::UpdateDangerWarning() { |
555 if (dangerous_prompt_) { | 511 if (dangerous_prompt_) { |
556 UpdateDangerIcon(); | 512 UpdateDangerIcon(); |
557 | 513 |
558 // We create |dangerous_warning| as a wide string so we can more easily | 514 // We create |dangerous_warning| as a wide string so we can more easily |
559 // calculate its length in characters. | 515 // calculate its length in characters. |
560 string16 dangerous_warning; | 516 string16 dangerous_warning; |
517 DownloadStateInfo::DangerType danger_type = get_download()->GetDangerType(); | |
561 | 518 |
562 // The dangerous download label text is different for different cases. | 519 // The dangerous download label text is different for different cases. |
563 if (get_download()->GetDangerType() == DownloadStateInfo::DANGEROUS_URL) { | 520 if (danger_type == DownloadStateInfo::DANGEROUS_URL || |
521 danger_type == DownloadStateInfo::DANGEROUS_CONTENT) { | |
564 // Safebrowsing shows the download URL leads to malicious file. | 522 // Safebrowsing shows the download URL leads to malicious file. |
565 dangerous_warning = | 523 dangerous_warning = |
566 l10n_util::GetStringUTF16(IDS_PROMPT_UNSAFE_DOWNLOAD_URL); | 524 l10n_util::GetStringUTF16(IDS_PROMPT_UNSAFE_DOWNLOAD_URL); |
Randy Smith (Not in Mondays)
2011/11/21 01:38:13
Noe': Do we want the prompts to be the same for co
| |
567 } else { | 525 } else { |
568 // It's a dangerous file type (e.g.: an executable). | 526 // It's a dangerous file type (e.g.: an executable). |
569 DCHECK(get_download()->GetDangerType() == | 527 DCHECK(danger_type == DownloadStateInfo::DANGEROUS_FILE); |
570 DownloadStateInfo::DANGEROUS_FILE); | |
571 if (ChromeDownloadManagerDelegate::IsExtensionDownload(get_download())) { | 528 if (ChromeDownloadManagerDelegate::IsExtensionDownload(get_download())) { |
572 dangerous_warning = | 529 dangerous_warning = |
573 l10n_util::GetStringUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION); | 530 l10n_util::GetStringUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION); |
574 } else { | 531 } else { |
575 string16 elided_filename = ui::ElideFilename( | 532 string16 elided_filename = ui::ElideFilename( |
576 get_download()->target_name(), gfx::Font(), kTextWidth); | 533 get_download()->target_name(), gfx::Font(), kTextWidth); |
577 dangerous_warning = | 534 dangerous_warning = |
578 l10n_util::GetStringFUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD, | 535 l10n_util::GetStringFUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD, |
579 elided_filename); | 536 elided_filename); |
580 } | 537 } |
(...skipping 27 matching lines...) Expand all Loading... | |
608 | 565 |
609 // The width will depend on the text. We must do this each time we possibly | 566 // The width will depend on the text. We must do this each time we possibly |
610 // change the label above. | 567 // change the label above. |
611 gtk_widget_size_request(dangerous_hbox_.get(), &req); | 568 gtk_widget_size_request(dangerous_hbox_.get(), &req); |
612 dangerous_hbox_full_width_ = req.width; | 569 dangerous_hbox_full_width_ = req.width; |
613 dangerous_hbox_start_width_ = dangerous_hbox_full_width_ - label_width; | 570 dangerous_hbox_start_width_ = dangerous_hbox_full_width_ - label_width; |
614 } | 571 } |
615 } | 572 } |
616 | 573 |
617 void DownloadItemGtk::UpdateDangerIcon() { | 574 void DownloadItemGtk::UpdateDangerIcon() { |
575 DownloadStateInfo::DangerType danger_type = get_download()->GetDangerType(); | |
618 if (theme_service_->UsingNativeTheme()) { | 576 if (theme_service_->UsingNativeTheme()) { |
619 const char* stock = | 577 const char* stock = |
620 get_download()->GetDangerType() == DownloadStateInfo::DANGEROUS_URL ? | 578 (danger_type == DownloadStateInfo::DANGEROUS_URL || |
579 danger_type == DownloadStateInfo::DANGEROUS_CONTENT) ? | |
621 GTK_STOCK_DIALOG_ERROR : GTK_STOCK_DIALOG_WARNING; | 580 GTK_STOCK_DIALOG_ERROR : GTK_STOCK_DIALOG_WARNING; |
622 gtk_image_set_from_stock( | 581 gtk_image_set_from_stock( |
623 GTK_IMAGE(dangerous_image_), stock, GTK_ICON_SIZE_SMALL_TOOLBAR); | 582 GTK_IMAGE(dangerous_image_), stock, GTK_ICON_SIZE_SMALL_TOOLBAR); |
624 } else { | 583 } else { |
625 // Set the warning icon. | 584 // Set the warning icon. |
626 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 585 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
627 int pixbuf_id = | 586 int pixbuf_id = |
628 get_download()->GetDangerType() == DownloadStateInfo::DANGEROUS_URL ? | 587 (danger_type == DownloadStateInfo::DANGEROUS_URL || |
588 danger_type == DownloadStateInfo::DANGEROUS_CONTENT) ? | |
629 IDR_SAFEBROWSING_WARNING : IDR_WARNING; | 589 IDR_SAFEBROWSING_WARNING : IDR_WARNING; |
630 GdkPixbuf* download_pixbuf = rb.GetNativeImageNamed(pixbuf_id); | 590 GdkPixbuf* download_pixbuf = rb.GetNativeImageNamed(pixbuf_id); |
631 gtk_image_set_from_pixbuf(GTK_IMAGE(dangerous_image_), download_pixbuf); | 591 gtk_image_set_from_pixbuf(GTK_IMAGE(dangerous_image_), download_pixbuf); |
632 } | 592 } |
633 } | 593 } |
634 | 594 |
595 void DownloadItemGtk::ShowDangerPrompt() { | |
596 if (dangerous_prompt_) | |
597 return; | |
598 | |
599 // Hide the download item components for now. | |
600 gtk_widget_set_no_show_all(body_.get(), TRUE); | |
601 gtk_widget_set_no_show_all(menu_button_, TRUE); | |
602 gtk_widget_hide(body_.get()); | |
603 gtk_widget_hide(menu_button_); | |
604 | |
605 // Create an hbox to hold it all. | |
606 dangerous_hbox_.Own(gtk_hbox_new(FALSE, kDangerousElementPadding)); | |
607 | |
608 // Add padding at the beginning and end. The hbox will add padding between | |
609 // the empty labels and the other elements. | |
610 GtkWidget* empty_label_a = gtk_label_new(NULL); | |
611 GtkWidget* empty_label_b = gtk_label_new(NULL); | |
612 gtk_box_pack_start(GTK_BOX(dangerous_hbox_.get()), empty_label_a, | |
613 FALSE, FALSE, 0); | |
614 gtk_box_pack_end(GTK_BOX(dangerous_hbox_.get()), empty_label_b, | |
615 FALSE, FALSE, 0); | |
616 | |
617 // Create the warning icon. | |
618 dangerous_image_ = gtk_image_new(); | |
619 gtk_box_pack_start(GTK_BOX(dangerous_hbox_.get()), dangerous_image_, | |
620 FALSE, FALSE, 0); | |
621 | |
622 dangerous_label_ = gtk_label_new(NULL); | |
623 // We pass TRUE, TRUE so that the label will condense to less than its | |
624 // request when the animation is going on. | |
625 gtk_box_pack_start(GTK_BOX(dangerous_hbox_.get()), dangerous_label_, | |
626 TRUE, TRUE, 0); | |
627 | |
628 // Create the nevermind button. | |
629 GtkWidget* dangerous_decline = gtk_button_new_with_label( | |
630 l10n_util::GetStringUTF8(IDS_DISCARD_DOWNLOAD).c_str()); | |
631 g_signal_connect(dangerous_decline, "clicked", | |
632 G_CALLBACK(OnDangerousDeclineThunk), this); | |
633 gtk_util::CenterWidgetInHBox(dangerous_hbox_.get(), dangerous_decline, | |
634 false, 0); | |
635 | |
636 // Create the ok button. | |
637 GtkWidget* dangerous_accept = gtk_button_new_with_label( | |
638 l10n_util::GetStringUTF8( | |
639 ChromeDownloadManagerDelegate::IsExtensionDownload( | |
640 download_model_->download()) ? | |
641 IDS_CONTINUE_EXTENSION_DOWNLOAD : | |
642 IDS_CONFIRM_DOWNLOAD).c_str()); | |
643 g_signal_connect(dangerous_accept, "clicked", | |
644 G_CALLBACK(OnDangerousAcceptThunk), this); | |
645 gtk_util::CenterWidgetInHBox(dangerous_hbox_.get(), dangerous_accept, false, | |
646 0); | |
647 | |
648 // Put it in an alignment so that padding will be added on the left and right. | |
649 dangerous_prompt_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); | |
650 gtk_alignment_set_padding( | |
651 GTK_ALIGNMENT(dangerous_prompt_), | |
652 0, 0, kDangerousElementPadding, kDangerousElementPadding); | |
653 gtk_container_add(GTK_CONTAINER(dangerous_prompt_), dangerous_hbox_.get()); | |
654 gtk_box_pack_start(GTK_BOX(hbox_.get()), dangerous_prompt_, FALSE, FALSE, 0); | |
655 gtk_widget_set_app_paintable(dangerous_prompt_, TRUE); | |
656 gtk_widget_set_redraw_on_allocate(dangerous_prompt_, TRUE); | |
657 g_signal_connect(dangerous_prompt_, "expose-event", | |
658 G_CALLBACK(OnDangerousPromptExposeThunk), this); | |
659 gtk_widget_show_all(dangerous_prompt_); | |
660 UpdateDangerWarning(); | |
661 } | |
662 | |
635 // static | 663 // static |
636 void DownloadItemGtk::InitNineBoxes() { | 664 void DownloadItemGtk::InitNineBoxes() { |
637 if (body_nine_box_normal_) | 665 if (body_nine_box_normal_) |
638 return; | 666 return; |
639 | 667 |
640 body_nine_box_normal_ = new NineBox( | 668 body_nine_box_normal_ = new NineBox( |
641 IDR_DOWNLOAD_BUTTON_LEFT_TOP, | 669 IDR_DOWNLOAD_BUTTON_LEFT_TOP, |
642 IDR_DOWNLOAD_BUTTON_CENTER_TOP, | 670 IDR_DOWNLOAD_BUTTON_CENTER_TOP, |
643 IDR_DOWNLOAD_BUTTON_RIGHT_TOP, | 671 IDR_DOWNLOAD_BUTTON_RIGHT_TOP, |
644 IDR_DOWNLOAD_BUTTON_LEFT_MIDDLE, | 672 IDR_DOWNLOAD_BUTTON_LEFT_MIDDLE, |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
884 get_download()->DangerousDownloadValidated(); | 912 get_download()->DangerousDownloadValidated(); |
885 } | 913 } |
886 | 914 |
887 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { | 915 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { |
888 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", | 916 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", |
889 base::Time::Now() - creation_time_); | 917 base::Time::Now() - creation_time_); |
890 if (get_download()->IsPartialDownload()) | 918 if (get_download()->IsPartialDownload()) |
891 get_download()->Cancel(true); | 919 get_download()->Cancel(true); |
892 get_download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); | 920 get_download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); |
893 } | 921 } |
OLD | NEW |