| 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 "ash/wm/window_state.h" | |
| 10 #include "base/bind.h" | 9 #include "base/bind.h" |
| 11 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| 12 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 13 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 15 #include "chrome/browser/themes/theme_properties.h" | 14 #include "chrome/browser/themes/theme_properties.h" |
| 16 #include "chrome/browser/ui/elide_url.h" | 15 #include "chrome/browser/ui/elide_url.h" |
| 17 #include "net/base/net_util.h" | 16 #include "net/base/net_util.h" |
| 18 #include "third_party/skia/include/core/SkPaint.h" | 17 #include "third_party/skia/include/core/SkPaint.h" |
| 19 #include "third_party/skia/include/core/SkRect.h" | 18 #include "third_party/skia/include/core/SkRect.h" |
| 20 #include "ui/aura/window.h" | |
| 21 #include "ui/base/theme_provider.h" | 19 #include "ui/base/theme_provider.h" |
| 22 #include "ui/gfx/animation/animation_delegate.h" | 20 #include "ui/gfx/animation/animation_delegate.h" |
| 23 #include "ui/gfx/animation/linear_animation.h" | 21 #include "ui/gfx/animation/linear_animation.h" |
| 24 #include "ui/gfx/canvas.h" | 22 #include "ui/gfx/canvas.h" |
| 25 #include "ui/gfx/font_list.h" | 23 #include "ui/gfx/font_list.h" |
| 26 #include "ui/gfx/point.h" | 24 #include "ui/gfx/point.h" |
| 27 #include "ui/gfx/rect.h" | 25 #include "ui/gfx/rect.h" |
| 28 #include "ui/gfx/screen.h" | 26 #include "ui/gfx/screen.h" |
| 29 #include "ui/gfx/skia_util.h" | 27 #include "ui/gfx/skia_util.h" |
| 30 #include "ui/gfx/text_elider.h" | 28 #include "ui/gfx/text_elider.h" |
| 31 #include "ui/gfx/text_utils.h" | 29 #include "ui/gfx/text_utils.h" |
| 32 #include "ui/native_theme/native_theme.h" | 30 #include "ui/native_theme/native_theme.h" |
| 33 #include "ui/views/controls/scrollbar/native_scroll_bar.h" | 31 #include "ui/views/controls/scrollbar/native_scroll_bar.h" |
| 34 #include "ui/views/widget/root_view.h" | 32 #include "ui/views/widget/root_view.h" |
| 35 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
| 36 #include "url/gurl.h" | 34 #include "url/gurl.h" |
| 37 | 35 |
| 36 #if defined(USE_ASH) |
| 37 #include "ash/wm/window_state.h" |
| 38 #endif |
| 39 |
| 38 // The alpha and color of the bubble's shadow. | 40 // The alpha and color of the bubble's shadow. |
| 39 static const SkColor kShadowColor = SkColorSetARGB(30, 0, 0, 0); | 41 static const SkColor kShadowColor = SkColorSetARGB(30, 0, 0, 0); |
| 40 | 42 |
| 41 // The roundedness of the edges of our bubble. | 43 // The roundedness of the edges of our bubble. |
| 42 static const int kBubbleCornerRadius = 4; | 44 static const int kBubbleCornerRadius = 4; |
| 43 | 45 |
| 44 // How close the mouse can get to the infobubble before it starts sliding | 46 // How close the mouse can get to the infobubble before it starts sliding |
| 45 // off-screen. | 47 // off-screen. |
| 46 static const int kMousePadding = 20; | 48 static const int kMousePadding = 20; |
| 47 | 49 |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 view_ = new StatusView(popup_.get(), frame->GetThemeProvider()); | 575 view_ = new StatusView(popup_.get(), frame->GetThemeProvider()); |
| 574 if (!expand_view_.get()) | 576 if (!expand_view_.get()) |
| 575 expand_view_.reset(new StatusViewExpander(this, view_)); | 577 expand_view_.reset(new StatusViewExpander(this, view_)); |
| 576 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 578 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
| 577 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 579 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 578 params.accept_events = false; | 580 params.accept_events = false; |
| 579 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 581 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 580 params.parent = frame->GetNativeView(); | 582 params.parent = frame->GetNativeView(); |
| 581 params.context = frame->GetNativeWindow(); | 583 params.context = frame->GetNativeWindow(); |
| 582 popup_->Init(params); | 584 popup_->Init(params); |
| 583 popup_->GetNativeView()->SetName("StatusBubbleViews"); | |
| 584 // We do our own animation and don't want any from the system. | 585 // We do our own animation and don't want any from the system. |
| 585 popup_->SetVisibilityChangedAnimationsEnabled(false); | 586 popup_->SetVisibilityChangedAnimationsEnabled(false); |
| 586 popup_->SetOpacity(0x00); | 587 popup_->SetOpacity(0x00); |
| 587 popup_->SetContentsView(view_); | 588 popup_->SetContentsView(view_); |
| 589 #if defined(USE_ASH) |
| 588 ash::wm::GetWindowState(popup_->GetNativeWindow())-> | 590 ash::wm::GetWindowState(popup_->GetNativeWindow())-> |
| 589 set_ignored_by_shelf(true); | 591 set_ignored_by_shelf(true); |
| 592 #endif |
| 590 RepositionPopup(); | 593 RepositionPopup(); |
| 591 } | 594 } |
| 592 } | 595 } |
| 593 | 596 |
| 594 void StatusBubbleViews::Reposition() { | 597 void StatusBubbleViews::Reposition() { |
| 595 // In restored mode, the client area has a client edge between it and the | 598 // In restored mode, the client area has a client edge between it and the |
| 596 // frame. | 599 // frame. |
| 597 int overlap = kShadowThickness; | 600 int overlap = kShadowThickness; |
| 598 int height = GetPreferredSize().height(); | 601 int height = GetPreferredSize().height(); |
| 599 int base_view_height = base_view()->bounds().height(); | 602 int base_view_height = base_view()->bounds().height(); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 void StatusBubbleViews::SetBubbleWidth(int width) { | 867 void StatusBubbleViews::SetBubbleWidth(int width) { |
| 865 size_.set_width(width); | 868 size_.set_width(width); |
| 866 SetBounds(original_position_.x(), original_position_.y(), | 869 SetBounds(original_position_.x(), original_position_.y(), |
| 867 size_.width(), size_.height()); | 870 size_.width(), size_.height()); |
| 868 } | 871 } |
| 869 | 872 |
| 870 void StatusBubbleViews::CancelExpandTimer() { | 873 void StatusBubbleViews::CancelExpandTimer() { |
| 871 if (expand_timer_factory_.HasWeakPtrs()) | 874 if (expand_timer_factory_.HasWeakPtrs()) |
| 872 expand_timer_factory_.InvalidateWeakPtrs(); | 875 expand_timer_factory_.InvalidateWeakPtrs(); |
| 873 } | 876 } |
| OLD | NEW |