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/views/status_bubble_views.h" | 5 #include "chrome/browser/ui/views/status_bubble_views.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/themes/theme_properties.h" | 14 #include "chrome/browser/themes/theme_properties.h" |
15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
16 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
17 #include "grit/theme_resources.h" | 17 #include "grit/theme_resources.h" |
18 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
19 #include "third_party/skia/include/core/SkPaint.h" | 19 #include "third_party/skia/include/core/SkPaint.h" |
20 #include "third_party/skia/include/core/SkPath.h" | 20 #include "third_party/skia/include/core/SkPath.h" |
21 #include "third_party/skia/include/core/SkRect.h" | 21 #include "third_party/skia/include/core/SkRect.h" |
22 #include "ui/base/animation/animation_delegate.h" | 22 #include "ui/base/animation/animation_delegate.h" |
23 #include "ui/base/animation/linear_animation.h" | 23 #include "ui/base/animation/linear_animation.h" |
24 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
25 #include "ui/base/text/text_elider.h" | 25 #include "ui/base/text/text_elider.h" |
26 #include "ui/base/theme_provider.h" | 26 #include "ui/base/theme_provider.h" |
27 #include "ui/gfx/canvas.h" | 27 #include "ui/gfx/canvas.h" |
| 28 #include "ui/gfx/font.h" |
28 #include "ui/gfx/point.h" | 29 #include "ui/gfx/point.h" |
29 #include "ui/gfx/screen.h" | 30 #include "ui/gfx/screen.h" |
30 #include "ui/gfx/skia_util.h" | 31 #include "ui/gfx/skia_util.h" |
31 #include "ui/native_theme/native_theme.h" | 32 #include "ui/native_theme/native_theme.h" |
32 #include "ui/views/controls/label.h" | 33 #include "ui/views/controls/label.h" |
33 #include "ui/views/controls/scrollbar/native_scroll_bar.h" | 34 #include "ui/views/controls/scrollbar/native_scroll_bar.h" |
34 #include "ui/views/widget/root_view.h" | 35 #include "ui/views/widget/root_view.h" |
35 #include "ui/views/widget/widget.h" | 36 #include "ui/views/widget/widget.h" |
36 | 37 |
37 #if defined(USE_ASH) | 38 #if defined(USE_ASH) |
38 #include "ash/wm/property_util.h" | 39 #include "ash/wm/property_util.h" |
39 #endif | 40 #endif |
40 | 41 |
| 42 #if defined(OS_WIN) |
| 43 #include "ui/base/win/dpi.h" |
| 44 #endif |
| 45 |
41 // The alpha and color of the bubble's shadow. | 46 // The alpha and color of the bubble's shadow. |
42 static const SkColor kShadowColor = SkColorSetARGB(30, 0, 0, 0); | 47 static const SkColor kShadowColor = SkColorSetARGB(30, 0, 0, 0); |
43 | 48 |
44 // The roundedness of the edges of our bubble. | 49 // The roundedness of the edges of our bubble. |
45 static const int kBubbleCornerRadius = 4; | 50 static const int kBubbleCornerRadius = 4; |
46 | 51 |
47 // How close the mouse can get to the infobubble before it starts sliding | 52 // How close the mouse can get to the infobubble before it starts sliding |
48 // off-screen. | 53 // off-screen. |
49 static const int kMousePadding = 20; | 54 static const int kMousePadding = 20; |
50 | 55 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 : ui::LinearAnimation(kFramerate, this), | 88 : ui::LinearAnimation(kFramerate, this), |
84 stage_(BUBBLE_HIDDEN), | 89 stage_(BUBBLE_HIDDEN), |
85 style_(STYLE_STANDARD), | 90 style_(STYLE_STANDARD), |
86 timer_factory_(this), | 91 timer_factory_(this), |
87 status_bubble_(status_bubble), | 92 status_bubble_(status_bubble), |
88 popup_(popup), | 93 popup_(popup), |
89 opacity_start_(0), | 94 opacity_start_(0), |
90 opacity_end_(0), | 95 opacity_end_(0), |
91 theme_service_(theme_provider) { | 96 theme_service_(theme_provider) { |
92 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 97 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 98 #if defined(OS_WIN) |
| 99 SetFont(rb.GetFont(ui::ResourceBundle::BaseFont).DeriveFontScaled( |
| 100 ui::win::GetDeviceScaleFactor())); |
| 101 #else |
93 SetFont(rb.GetFont(ui::ResourceBundle::BaseFont)); | 102 SetFont(rb.GetFont(ui::ResourceBundle::BaseFont)); |
| 103 #endif |
94 } | 104 } |
95 | 105 |
96 virtual ~StatusView() { | 106 virtual ~StatusView() { |
97 // Remove ourself as a delegate so that we don't get notified when | 107 // Remove ourself as a delegate so that we don't get notified when |
98 // animations end as a result of destruction. | 108 // animations end as a result of destruction. |
99 set_delegate(NULL); | 109 set_delegate(NULL); |
100 Stop(); | 110 Stop(); |
101 CancelTimer(); | 111 CancelTimer(); |
102 } | 112 } |
103 | 113 |
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 void StatusBubbleViews::SetBubbleWidth(int width) { | 855 void StatusBubbleViews::SetBubbleWidth(int width) { |
846 size_.set_width(width); | 856 size_.set_width(width); |
847 SetBounds(original_position_.x(), original_position_.y(), | 857 SetBounds(original_position_.x(), original_position_.y(), |
848 size_.width(), size_.height()); | 858 size_.width(), size_.height()); |
849 } | 859 } |
850 | 860 |
851 void StatusBubbleViews::CancelExpandTimer() { | 861 void StatusBubbleViews::CancelExpandTimer() { |
852 if (expand_timer_factory_.HasWeakPtrs()) | 862 if (expand_timer_factory_.HasWeakPtrs()) |
853 expand_timer_factory_.InvalidateWeakPtrs(); | 863 expand_timer_factory_.InvalidateWeakPtrs(); |
854 } | 864 } |
OLD | NEW |