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/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/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 } | 551 } |
552 | 552 |
553 StatusBubbleViews::~StatusBubbleViews() { | 553 StatusBubbleViews::~StatusBubbleViews() { |
554 CancelExpandTimer(); | 554 CancelExpandTimer(); |
555 if (popup_.get()) | 555 if (popup_.get()) |
556 popup_->CloseNow(); | 556 popup_->CloseNow(); |
557 } | 557 } |
558 | 558 |
559 void StatusBubbleViews::Init() { | 559 void StatusBubbleViews::Init() { |
560 if (!popup_.get()) { | 560 if (!popup_.get()) { |
561 popup_.reset(Widget::CreateWidget()); | 561 popup_.reset(new Widget); |
562 views::Widget* frame = base_view_->GetWidget(); | 562 views::Widget* frame = base_view_->GetWidget(); |
563 if (!view_) | 563 if (!view_) |
564 view_ = new StatusView(this, popup_.get(), frame->GetThemeProvider()); | 564 view_ = new StatusView(this, popup_.get(), frame->GetThemeProvider()); |
565 if (!expand_view_.get()) | 565 if (!expand_view_.get()) |
566 expand_view_.reset(new StatusViewExpander(this, view_)); | 566 expand_view_.reset(new StatusViewExpander(this, view_)); |
567 popup_->SetOpacity(0x00); | |
568 Widget::InitParams params(Widget::InitParams::TYPE_POPUP); | 567 Widget::InitParams params(Widget::InitParams::TYPE_POPUP); |
569 params.transparent = true; | 568 params.transparent = true; |
570 params.accept_events = false; | 569 params.accept_events = false; |
571 params.delete_on_destroy = false; | 570 params.delete_on_destroy = false; |
572 params.parent = frame->GetNativeView(); | 571 params.parent = frame->GetNativeView(); |
573 popup_->Init(params); | 572 popup_->Init(params); |
| 573 popup_->SetOpacity(0x00); |
574 popup_->SetContentsView(view_); | 574 popup_->SetContentsView(view_); |
575 Reposition(); | 575 Reposition(); |
576 popup_->Show(); | 576 popup_->Show(); |
577 } | 577 } |
578 } | 578 } |
579 | 579 |
580 void StatusBubbleViews::Reposition() { | 580 void StatusBubbleViews::Reposition() { |
581 if (popup_.get()) { | 581 if (popup_.get()) { |
582 gfx::Point top_left; | 582 gfx::Point top_left; |
583 views::View::ConvertPointToScreen(base_view_, &top_left); | 583 views::View::ConvertPointToScreen(base_view_, &top_left); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 top_left.y() + position_.y(), | 787 top_left.y() + position_.y(), |
788 size_.width(), size_.height())); | 788 size_.width(), size_.height())); |
789 } | 789 } |
790 } | 790 } |
791 | 791 |
792 bool StatusBubbleViews::IsFrameVisible() { | 792 bool StatusBubbleViews::IsFrameVisible() { |
793 views::Widget* frame = base_view_->GetWidget(); | 793 views::Widget* frame = base_view_->GetWidget(); |
794 if (!frame->IsVisible()) | 794 if (!frame->IsVisible()) |
795 return false; | 795 return false; |
796 | 796 |
797 views::Window* window = frame->GetWindow(); | 797 views::Window* window = frame->GetContainingWindow(); |
798 return !window || !window->IsMinimized(); | 798 return !window || !window->IsMinimized(); |
799 } | 799 } |
800 | 800 |
801 void StatusBubbleViews::ExpandBubble() { | 801 void StatusBubbleViews::ExpandBubble() { |
802 // Elide URL to maximum possible size, then check actual length (it may | 802 // Elide URL to maximum possible size, then check actual length (it may |
803 // still be too long to fit) before expanding bubble. | 803 // still be too long to fit) before expanding bubble. |
804 gfx::Rect popup_bounds = popup_->GetWindowScreenBounds(); | 804 gfx::Rect popup_bounds = popup_->GetWindowScreenBounds(); |
805 int max_status_bubble_width = GetMaxStatusBubbleWidth(); | 805 int max_status_bubble_width = GetMaxStatusBubbleWidth(); |
806 url_text_ = ui::ElideUrl(url_, view_->Label::font(), | 806 url_text_ = ui::ElideUrl(url_, view_->Label::font(), |
807 max_status_bubble_width, UTF16ToUTF8(languages_)); | 807 max_status_bubble_width, UTF16ToUTF8(languages_)); |
(...skipping 20 matching lines...) Expand all Loading... |
828 void StatusBubbleViews::SetBubbleWidth(int width) { | 828 void StatusBubbleViews::SetBubbleWidth(int width) { |
829 size_.set_width(width); | 829 size_.set_width(width); |
830 SetBounds(original_position_.x(), original_position_.y(), | 830 SetBounds(original_position_.x(), original_position_.y(), |
831 size_.width(), size_.height()); | 831 size_.width(), size_.height()); |
832 } | 832 } |
833 | 833 |
834 void StatusBubbleViews::CancelExpandTimer() { | 834 void StatusBubbleViews::CancelExpandTimer() { |
835 if (!expand_timer_factory_.empty()) | 835 if (!expand_timer_factory_.empty()) |
836 expand_timer_factory_.RevokeAll(); | 836 expand_timer_factory_.RevokeAll(); |
837 } | 837 } |
OLD | NEW |