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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 GtkAllocation allocation; | 706 GtkAllocation allocation; |
707 gtk_widget_get_allocation(widget, &allocation); | 707 gtk_widget_get_allocation(widget, &allocation); |
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(widget->style, widget->window, | 716 gtk_paint_shadow(gtk_widget_get_style(widget), |
| 717 gtk_widget_get_window(widget), |
717 static_cast<GtkStateType>(widget->state), | 718 static_cast<GtkStateType>(widget->state), |
718 static_cast<GtkShadowType>(GTK_SHADOW_OUT), | 719 static_cast<GtkShadowType>(GTK_SHADOW_OUT), |
719 &e->area, widget, "frame", | 720 &e->area, widget, "frame", |
720 x, y, width, height); | 721 x, y, width, height); |
721 } else { | 722 } else { |
722 // 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 |
723 // 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 |
724 // 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 |
725 // 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 |
726 // 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 |
727 // doctored clip rectangle to the left part of the button sans | 728 // doctored clip rectangle to the left part of the button sans |
728 // separator. We then repeat this for the right button. | 729 // separator. We then repeat this for the right button. |
729 GtkStyle* style = body_.get()->style; | 730 GtkStyle* style = body_.get()->style; |
730 | 731 |
731 GtkAllocation left_clip; | 732 GtkAllocation left_clip; |
732 gtk_widget_get_allocation(body_.get(), &left_clip); | 733 gtk_widget_get_allocation(body_.get(), &left_clip); |
733 | 734 |
734 GtkAllocation right_clip; | 735 GtkAllocation right_clip; |
735 gtk_widget_get_allocation(menu_button_, &right_clip); | 736 gtk_widget_get_allocation(menu_button_, &right_clip); |
736 | 737 |
737 GtkShadowType body_shadow = | 738 GtkShadowType body_shadow = |
738 GTK_BUTTON(body_.get())->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT; | 739 GTK_BUTTON(body_.get())->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT; |
739 gtk_paint_box(style, widget->window, | 740 gtk_paint_box(style, |
| 741 gtk_widget_get_window(widget), |
740 gtk_widget_get_state(body_.get()), | 742 gtk_widget_get_state(body_.get()), |
741 body_shadow, | 743 body_shadow, |
742 &left_clip, widget, "button", | 744 &left_clip, widget, "button", |
743 x, y, width, height); | 745 x, y, width, height); |
744 | 746 |
745 GtkShadowType menu_shadow = | 747 GtkShadowType menu_shadow = |
746 GTK_BUTTON(menu_button_)->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT; | 748 GTK_BUTTON(menu_button_)->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT; |
747 gtk_paint_box(style, widget->window, | 749 gtk_paint_box(style, |
| 750 gtk_widget_get_window(widget), |
748 gtk_widget_get_state(menu_button_), | 751 gtk_widget_get_state(menu_button_), |
749 menu_shadow, | 752 menu_shadow, |
750 &right_clip, widget, "button", | 753 &right_clip, widget, "button", |
751 x, y, width, height); | 754 x, y, width, height); |
752 | 755 |
753 // Doing the math to reverse engineer where we should be drawing our line | 756 // Doing the math to reverse engineer where we should be drawing our line |
754 // is hard and relies on copying GTK internals, so instead steal the | 757 // is hard and relies on copying GTK internals, so instead steal the |
755 // allocation of the gtk arrow which is close enough (and will error on | 758 // allocation of the gtk arrow which is close enough (and will error on |
756 // the conservative side). | 759 // the conservative side). |
757 GtkAllocation arrow_allocation; | 760 GtkAllocation arrow_allocation; |
758 gtk_widget_get_allocation(arrow_, &arrow_allocation); | 761 gtk_widget_get_allocation(arrow_, &arrow_allocation); |
759 gtk_paint_vline(style, widget->window, | 762 gtk_paint_vline(style, |
| 763 gtk_widget_get_window(widget), |
760 gtk_widget_get_state(widget), | 764 gtk_widget_get_state(widget), |
761 &e->area, widget, "button", | 765 &e->area, widget, "button", |
762 arrow_allocation.y, | 766 arrow_allocation.y, |
763 arrow_allocation.y + arrow_allocation.height, | 767 arrow_allocation.y + arrow_allocation.height, |
764 left_clip.x + left_clip.width); | 768 left_clip.x + left_clip.width); |
765 } | 769 } |
766 } | 770 } |
767 return FALSE; | 771 return FALSE; |
768 } | 772 } |
769 | 773 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 get_download()->DangerousDownloadValidated(); | 896 get_download()->DangerousDownloadValidated(); |
893 } | 897 } |
894 | 898 |
895 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { | 899 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { |
896 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", | 900 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", |
897 base::Time::Now() - creation_time_); | 901 base::Time::Now() - creation_time_); |
898 if (get_download()->IsPartialDownload()) | 902 if (get_download()->IsPartialDownload()) |
899 get_download()->Cancel(true); | 903 get_download()->Cancel(true); |
900 get_download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); | 904 get_download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); |
901 } | 905 } |
OLD | NEW |