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/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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 int border_width = gtk_container_get_border_width(GTK_CONTAINER(widget)); | 708 int border_width = gtk_container_get_border_width(GTK_CONTAINER(widget)); |
709 int x = allocation.x + border_width; | 709 int x = allocation.x + border_width; |
710 int y = allocation.y + border_width; | 710 int y = allocation.y + border_width; |
711 int width = allocation.width - border_width * 2; | 711 int width = allocation.width - border_width * 2; |
712 int height = allocation.height - border_width * 2; | 712 int height = allocation.height - border_width * 2; |
713 | 713 |
714 if (IsDangerous()) { | 714 if (IsDangerous()) { |
715 // Draw a simple frame around the area when we're displaying the warning. | 715 // Draw a simple frame around the area when we're displaying the warning. |
716 gtk_paint_shadow(gtk_widget_get_style(widget), | 716 gtk_paint_shadow(gtk_widget_get_style(widget), |
717 gtk_widget_get_window(widget), | 717 gtk_widget_get_window(widget), |
718 static_cast<GtkStateType>(widget->state), | 718 gtk_widget_get_state(widget), |
719 static_cast<GtkShadowType>(GTK_SHADOW_OUT), | 719 static_cast<GtkShadowType>(GTK_SHADOW_OUT), |
720 &e->area, widget, "frame", | 720 &e->area, widget, "frame", |
721 x, y, width, height); | 721 x, y, width, height); |
722 } else { | 722 } else { |
723 // Manually draw the GTK button border around the download item. We draw | 723 // Manually draw the GTK button border around the download item. We draw |
724 // the left part of the button (the file), a divider, and then the right | 724 // the left part of the button (the file), a divider, and then the right |
725 // part of the button (the menu). We can't draw a button on top of each | 725 // part of the button (the menu). We can't draw a button on top of each |
726 // other (*cough*Clearlooks*cough*) so instead, to draw the left part of | 726 // other (*cough*Clearlooks*cough*) so instead, to draw the left part of |
727 // the button, we instruct GTK to draw the entire button...with a | 727 // the button, we instruct GTK to draw the entire button...with a |
728 // doctored clip rectangle to the left part of the button sans | 728 // doctored clip rectangle to the left part of the button sans |
729 // separator. We then repeat this for the right button. | 729 // separator. We then repeat this for the right button. |
730 GtkStyle* style = body_.get()->style; | 730 GtkStyle* style = gtk_widget_get_style(body_.get()); |
731 | 731 |
732 GtkAllocation left_clip; | 732 GtkAllocation left_clip; |
733 gtk_widget_get_allocation(body_.get(), &left_clip); | 733 gtk_widget_get_allocation(body_.get(), &left_clip); |
734 | 734 |
735 GtkAllocation right_clip; | 735 GtkAllocation right_clip; |
736 gtk_widget_get_allocation(menu_button_, &right_clip); | 736 gtk_widget_get_allocation(menu_button_, &right_clip); |
737 | 737 |
738 GtkShadowType body_shadow = | 738 GtkShadowType body_shadow = |
739 GTK_BUTTON(body_.get())->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT; | 739 GTK_BUTTON(body_.get())->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT; |
740 gtk_paint_box(style, | 740 gtk_paint_box(style, |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 get_download()->DangerousDownloadValidated(); | 896 get_download()->DangerousDownloadValidated(); |
897 } | 897 } |
898 | 898 |
899 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { | 899 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { |
900 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", | 900 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", |
901 base::Time::Now() - creation_time_); | 901 base::Time::Now() - creation_time_); |
902 if (get_download()->IsPartialDownload()) | 902 if (get_download()->IsPartialDownload()) |
903 get_download()->Cancel(true); | 903 get_download()->Cancel(true); |
904 get_download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); | 904 get_download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); |
905 } | 905 } |
OLD | NEW |