| 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/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/themes/theme_properties.h" | 14 #include "chrome/browser/themes/theme_properties.h" |
| 15 #include "chrome/browser/ui/elide_url.h" | 15 #include "chrome/browser/ui/elide_url.h" |
| 16 #include "net/base/net_util.h" | 16 #include "net/base/net_util.h" |
| 17 #include "third_party/skia/include/core/SkPaint.h" | 17 #include "third_party/skia/include/core/SkPaint.h" |
| 18 #include "third_party/skia/include/core/SkPath.h" | 18 #include "third_party/skia/include/core/SkPath.h" |
| 19 #include "third_party/skia/include/core/SkRect.h" | 19 #include "third_party/skia/include/core/SkRect.h" |
| 20 #include "ui/aura/window.h" |
| 20 #include "ui/base/theme_provider.h" | 21 #include "ui/base/theme_provider.h" |
| 21 #include "ui/gfx/animation/animation_delegate.h" | 22 #include "ui/gfx/animation/animation_delegate.h" |
| 22 #include "ui/gfx/animation/linear_animation.h" | 23 #include "ui/gfx/animation/linear_animation.h" |
| 23 #include "ui/gfx/canvas.h" | 24 #include "ui/gfx/canvas.h" |
| 24 #include "ui/gfx/font_list.h" | 25 #include "ui/gfx/font_list.h" |
| 25 #include "ui/gfx/point.h" | 26 #include "ui/gfx/point.h" |
| 26 #include "ui/gfx/rect.h" | 27 #include "ui/gfx/rect.h" |
| 27 #include "ui/gfx/screen.h" | 28 #include "ui/gfx/screen.h" |
| 28 #include "ui/gfx/skia_util.h" | 29 #include "ui/gfx/skia_util.h" |
| 29 #include "ui/gfx/text_elider.h" | 30 #include "ui/gfx/text_elider.h" |
| 30 #include "ui/gfx/text_utils.h" | 31 #include "ui/gfx/text_utils.h" |
| 31 #include "ui/native_theme/native_theme.h" | 32 #include "ui/native_theme/native_theme.h" |
| 32 #include "ui/views/controls/scrollbar/native_scroll_bar.h" | 33 #include "ui/views/controls/scrollbar/native_scroll_bar.h" |
| 33 #include "ui/views/widget/root_view.h" | 34 #include "ui/views/widget/root_view.h" |
| 34 #include "ui/views/widget/widget.h" | 35 #include "ui/views/widget/widget.h" |
| 35 #include "url/gurl.h" | 36 #include "url/gurl.h" |
| 36 | 37 |
| 37 #if defined(USE_AURA) | |
| 38 #include "ui/aura/window.h" | |
| 39 #endif | |
| 40 | |
| 41 #if defined(USE_ASH) | 38 #if defined(USE_ASH) |
| 42 #include "ash/wm/window_state.h" | 39 #include "ash/wm/window_state.h" |
| 43 #endif | 40 #endif |
| 44 | 41 |
| 45 // The alpha and color of the bubble's shadow. | 42 // The alpha and color of the bubble's shadow. |
| 46 static const SkColor kShadowColor = SkColorSetARGB(30, 0, 0, 0); | 43 static const SkColor kShadowColor = SkColorSetARGB(30, 0, 0, 0); |
| 47 | 44 |
| 48 // The roundedness of the edges of our bubble. | 45 // The roundedness of the edges of our bubble. |
| 49 static const int kBubbleCornerRadius = 4; | 46 static const int kBubbleCornerRadius = 4; |
| 50 | 47 |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 view_ = new StatusView(popup_.get(), frame->GetThemeProvider()); | 602 view_ = new StatusView(popup_.get(), frame->GetThemeProvider()); |
| 606 if (!expand_view_.get()) | 603 if (!expand_view_.get()) |
| 607 expand_view_.reset(new StatusViewExpander(this, view_)); | 604 expand_view_.reset(new StatusViewExpander(this, view_)); |
| 608 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 605 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
| 609 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 606 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 610 params.accept_events = false; | 607 params.accept_events = false; |
| 611 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 608 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 612 params.parent = frame->GetNativeView(); | 609 params.parent = frame->GetNativeView(); |
| 613 params.context = frame->GetNativeView(); | 610 params.context = frame->GetNativeView(); |
| 614 popup_->Init(params); | 611 popup_->Init(params); |
| 615 #if defined(USE_AURA) | |
| 616 popup_->GetNativeView()->SetName("StatusBubbleViews"); | 612 popup_->GetNativeView()->SetName("StatusBubbleViews"); |
| 617 #endif | |
| 618 // We do our own animation and don't want any from the system. | 613 // We do our own animation and don't want any from the system. |
| 619 popup_->SetVisibilityChangedAnimationsEnabled(false); | 614 popup_->SetVisibilityChangedAnimationsEnabled(false); |
| 620 popup_->SetOpacity(0x00); | 615 popup_->SetOpacity(0x00); |
| 621 popup_->SetContentsView(view_); | 616 popup_->SetContentsView(view_); |
| 622 #if defined(USE_ASH) | 617 #if defined(USE_ASH) |
| 623 ash::wm::GetWindowState(popup_->GetNativeWindow())-> | 618 ash::wm::GetWindowState(popup_->GetNativeWindow())-> |
| 624 set_ignored_by_shelf(true); | 619 set_ignored_by_shelf(true); |
| 625 #endif | 620 #endif |
| 626 RepositionPopup(); | 621 RepositionPopup(); |
| 627 } | 622 } |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 void StatusBubbleViews::SetBubbleWidth(int width) { | 901 void StatusBubbleViews::SetBubbleWidth(int width) { |
| 907 size_.set_width(width); | 902 size_.set_width(width); |
| 908 SetBounds(original_position_.x(), original_position_.y(), | 903 SetBounds(original_position_.x(), original_position_.y(), |
| 909 size_.width(), size_.height()); | 904 size_.width(), size_.height()); |
| 910 } | 905 } |
| 911 | 906 |
| 912 void StatusBubbleViews::CancelExpandTimer() { | 907 void StatusBubbleViews::CancelExpandTimer() { |
| 913 if (expand_timer_factory_.HasWeakPtrs()) | 908 if (expand_timer_factory_.HasWeakPtrs()) |
| 914 expand_timer_factory_.InvalidateWeakPtrs(); | 909 expand_timer_factory_.InvalidateWeakPtrs(); |
| 915 } | 910 } |
| OLD | NEW |