| 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/location.h" | 11 #include "base/location.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
| 17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "chrome/browser/themes/theme_properties.h" | 18 #include "chrome/browser/themes/theme_properties.h" |
| 19 #include "components/url_formatter/elide_url.h" | 19 #include "components/url_formatter/elide_url.h" |
| 20 #include "components/url_formatter/url_formatter.h" | 20 #include "components/url_formatter/url_formatter.h" |
| 21 #include "third_party/skia/include/core/SkPaint.h" | 21 #include "third_party/skia/include/core/SkPaint.h" |
| 22 #include "third_party/skia/include/core/SkRRect.h" | 22 #include "third_party/skia/include/core/SkRRect.h" |
| 23 #include "ui/base/theme_provider.h" | 23 #include "ui/base/theme_provider.h" |
| 24 #include "ui/display/screen.h" |
| 24 #include "ui/gfx/animation/animation_delegate.h" | 25 #include "ui/gfx/animation/animation_delegate.h" |
| 25 #include "ui/gfx/animation/linear_animation.h" | 26 #include "ui/gfx/animation/linear_animation.h" |
| 26 #include "ui/gfx/canvas.h" | 27 #include "ui/gfx/canvas.h" |
| 27 #include "ui/gfx/font_list.h" | 28 #include "ui/gfx/font_list.h" |
| 28 #include "ui/gfx/geometry/point.h" | 29 #include "ui/gfx/geometry/point.h" |
| 29 #include "ui/gfx/geometry/rect.h" | 30 #include "ui/gfx/geometry/rect.h" |
| 30 #include "ui/gfx/screen.h" | |
| 31 #include "ui/gfx/skia_util.h" | 31 #include "ui/gfx/skia_util.h" |
| 32 #include "ui/gfx/text_elider.h" | 32 #include "ui/gfx/text_elider.h" |
| 33 #include "ui/gfx/text_utils.h" | 33 #include "ui/gfx/text_utils.h" |
| 34 #include "ui/native_theme/native_theme.h" | 34 #include "ui/native_theme/native_theme.h" |
| 35 #include "ui/views/controls/scrollbar/native_scroll_bar.h" | 35 #include "ui/views/controls/scrollbar/native_scroll_bar.h" |
| 36 #include "ui/views/widget/root_view.h" | 36 #include "ui/views/widget/root_view.h" |
| 37 #include "ui/views/widget/widget.h" | 37 #include "ui/views/widget/widget.h" |
| 38 #include "url/gurl.h" | 38 #include "url/gurl.h" |
| 39 | 39 |
| 40 #if defined(USE_ASH) | 40 #if defined(USE_ASH) |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 view_->SetStyle(StatusView::STYLE_BOTTOM); | 800 view_->SetStyle(StatusView::STYLE_BOTTOM); |
| 801 } else if (offset > kBubbleCornerRadius / 2 - kShadowThickness) { | 801 } else if (offset > kBubbleCornerRadius / 2 - kShadowThickness) { |
| 802 view_->SetStyle(StatusView::STYLE_FLOATING); | 802 view_->SetStyle(StatusView::STYLE_FLOATING); |
| 803 } else { | 803 } else { |
| 804 view_->SetStyle(StatusView::STYLE_STANDARD); | 804 view_->SetStyle(StatusView::STYLE_STANDARD); |
| 805 } | 805 } |
| 806 | 806 |
| 807 // Check if the bubble sticks out from the monitor or will obscure | 807 // Check if the bubble sticks out from the monitor or will obscure |
| 808 // download shelf. | 808 // download shelf. |
| 809 gfx::NativeView window = base_view_->GetWidget()->GetNativeView(); | 809 gfx::NativeView window = base_view_->GetWidget()->GetNativeView(); |
| 810 gfx::Rect monitor_rect = | 810 gfx::Rect monitor_rect = display::Screen::GetScreen() |
| 811 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window).work_area(); | 811 ->GetDisplayNearestWindow(window) |
| 812 .work_area(); |
| 812 const int bubble_bottom_y = top_left.y() + position_.y() + size_.height(); | 813 const int bubble_bottom_y = top_left.y() + position_.y() + size_.height(); |
| 813 | 814 |
| 814 if (bubble_bottom_y + offset > monitor_rect.height() || | 815 if (bubble_bottom_y + offset > monitor_rect.height() || |
| 815 (download_shelf_is_visible_ && | 816 (download_shelf_is_visible_ && |
| 816 (view_->style() == StatusView::STYLE_FLOATING || | 817 (view_->style() == StatusView::STYLE_FLOATING || |
| 817 view_->style() == StatusView::STYLE_BOTTOM))) { | 818 view_->style() == StatusView::STYLE_BOTTOM))) { |
| 818 // The offset is still too large. Move the bubble to the right and reset | 819 // The offset is still too large. Move the bubble to the right and reset |
| 819 // Y offset_ to zero. | 820 // Y offset_ to zero. |
| 820 view_->SetStyle(StatusView::STYLE_STANDARD_RIGHT); | 821 view_->SetStyle(StatusView::STYLE_STANDARD_RIGHT); |
| 821 offset_ = 0; | 822 offset_ = 0; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 void StatusBubbleViews::SetBubbleWidth(int width) { | 889 void StatusBubbleViews::SetBubbleWidth(int width) { |
| 889 size_.set_width(width); | 890 size_.set_width(width); |
| 890 SetBounds(original_position_.x(), original_position_.y(), | 891 SetBounds(original_position_.x(), original_position_.y(), |
| 891 size_.width(), size_.height()); | 892 size_.width(), size_.height()); |
| 892 } | 893 } |
| 893 | 894 |
| 894 void StatusBubbleViews::CancelExpandTimer() { | 895 void StatusBubbleViews::CancelExpandTimer() { |
| 895 if (expand_timer_factory_.HasWeakPtrs()) | 896 if (expand_timer_factory_.HasWeakPtrs()) |
| 896 expand_timer_factory_.InvalidateWeakPtrs(); | 897 expand_timer_factory_.InvalidateWeakPtrs(); |
| 897 } | 898 } |
| OLD | NEW |