diff options
-rw-r--r-- | chrome/browser/browser.cc | 2 | ||||
-rw-r--r-- | chrome/browser/browser.vcproj | 4 | ||||
-rw-r--r-- | chrome/browser/status_bubble.h | 40 | ||||
-rw-r--r-- | chrome/browser/views/browser_views.vcproj | 4 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 4 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.h | 4 | ||||
-rw-r--r-- | chrome/browser/views/status_bubble_views.cc (renamed from chrome/browser/views/status_bubble.cc) | 76 | ||||
-rw-r--r-- | chrome/browser/views/status_bubble_views.h (renamed from chrome/browser/views/status_bubble.h) | 44 |
8 files changed, 100 insertions, 78 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index ad50f67..3cc13be 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -49,6 +49,7 @@ #include "chrome/browser/profile.h" #include "chrome/browser/sessions/session_service.h" #include "chrome/browser/ssl/ssl_error_info.h" +#include "chrome/browser/status_bubble.h" #include "chrome/browser/tab_contents/interstitial_page.h" #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/navigation_entry.h" @@ -62,7 +63,6 @@ #include "chrome/browser/views/location_bar_view.h" #include "chrome/browser/views/new_profile_dialog.h" #include "chrome/browser/views/select_profile_dialog.h" -#include "chrome/browser/views/status_bubble.h" #include "chrome/browser/views/toolbar_star_toggle.h" #include "chrome/browser/window_sizer.h" #include "chrome/common/l10n_util.h" diff --git a/chrome/browser/browser.vcproj b/chrome/browser/browser.vcproj index 7deb350..48c6629 100644 --- a/chrome/browser/browser.vcproj +++ b/chrome/browser/browser.vcproj @@ -762,6 +762,10 @@ > </File> <File + RelativePath=".\status_bubble.h" + > + </File> + <File RelativePath=".\task_manager.cc" > </File> diff --git a/chrome/browser/status_bubble.h b/chrome/browser/status_bubble.h new file mode 100644 index 0000000..0f6cd04 --- /dev/null +++ b/chrome/browser/status_bubble.h @@ -0,0 +1,40 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_STATUS_BUBBLE_H_ +#define CHROME_BROWSER_STATUS_BUBBLE_H_ + +class GURL; + +//////////////////////////////////////////////////////////////////////////////// +// StatusBubble interface +// An interface implemented by an object providing the status display area of +// the browser window. +// +class StatusBubble { + public: + // Sets the bubble contents to a specific string and causes the bubble + // to display immediately. Subsequent empty SetURL calls (typically called + // when the cursor exits a link) will set the status bubble back to its + // status text. To hide the status bubble again, either call SetStatus + // with an empty string, or call Hide(). + virtual void SetStatus(const std::wstring& status) = 0; + + // Sets the bubble text to a URL - if given a non-empty URL, this will cause + // the bubble to fade in and remain open until given an empty URL or until + // the Hide() method is called. languages is the value of Accept-Language + // to determine what characters are understood by a user. + virtual void SetURL(const GURL& url, const std::wstring& languages) = 0; + + // Skip the fade and instant-hide the bubble. + virtual void Hide() = 0; + + // Called when the user's mouse has moved over web content. This is used to + // determine when the status area should move out of the way of the user's + // mouse. This may be windows specific pain due to the way messages are + // processed for child HWNDs. + virtual void MouseMoved() = 0; +}; + +#endif // #ifndef CHROME_BROWSER_STATUS_BUBBLE_H_
\ No newline at end of file diff --git a/chrome/browser/views/browser_views.vcproj b/chrome/browser/views/browser_views.vcproj index 557e4a2..c94205c 100644 --- a/chrome/browser/views/browser_views.vcproj +++ b/chrome/browser/views/browser_views.vcproj @@ -738,11 +738,11 @@ > </File> <File - RelativePath=".\status_bubble.cc" + RelativePath=".\status_bubble_views.cc" > </File> <File - RelativePath=".\status_bubble.h" + RelativePath=".\status_bubble_views.h" > </File> <File diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index da7adae..d9939f3 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -27,7 +27,7 @@ #include "chrome/browser/views/infobars/infobar_container.h" #include "chrome/browser/views/keyword_editor_view.h" #include "chrome/browser/views/password_manager_view.h" -#include "chrome/browser/views/status_bubble.h" +#include "chrome/browser/views/status_bubble_views.h" #include "chrome/browser/views/tab_contents_container_view.h" #include "chrome/browser/views/tabs/tab_strip.h" #include "chrome/browser/views/toolbar_view.h" @@ -352,7 +352,7 @@ void BrowserView::Init() { set_contents_view(contents_container_); AddChildView(contents_container_); - status_bubble_.reset(new StatusBubble(GetWidget())); + status_bubble_.reset(new StatusBubbleViews(GetWidget())); #ifdef CHROME_PERSONALIZATION const CommandLine& command_line = *CommandLine::ForCurrentProcess(); diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index d2df248..9473337 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -24,7 +24,7 @@ class BrowserToolbarView; class EncodingMenuControllerDelegate; class InfoBarContainer; class Menu; -class StatusBubble; +class StatusBubbleViews; class TabContentsContainerView; /////////////////////////////////////////////////////////////////////////////// @@ -355,7 +355,7 @@ class BrowserView : public BrowserWindow, TabContentsContainerView* contents_container_; // The Status information bubble that appears at the bottom of the window. - scoped_ptr<StatusBubble> status_bubble_; + scoped_ptr<StatusBubbleViews> status_bubble_; // A mapping between accelerators and commands. scoped_ptr<std::map<views::Accelerator, int>> accelerator_table_; diff --git a/chrome/browser/views/status_bubble.cc b/chrome/browser/views/status_bubble_views.cc index 6f0a375..a811892 100644 --- a/chrome/browser/views/status_bubble.cc +++ b/chrome/browser/views/status_bubble_views.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/views/status_bubble.h" +#include "chrome/browser/views/status_bubble_views.h" #include <algorithm> @@ -64,9 +64,9 @@ static const int kFramerate = 25; // View ----------------------------------------------------------------------- // StatusView manages the display of the bubble, applying text changes and // fading in or out the bubble as required. -class StatusBubble::StatusView : public views::Label, - public Animation, - public AnimationDelegate { +class StatusBubbleViews::StatusView : public views::Label, + public Animation, + public AnimationDelegate { public: StatusView(StatusBubble* status_bubble, views::WidgetWin* popup) : Animation(kFramerate, this), @@ -146,7 +146,7 @@ class StatusBubble::StatusView : public views::Label, BubbleStage stage_; BubbleStyle style_; - ScopedRunnableMethodFactory<StatusBubble::StatusView> timer_factory_; + ScopedRunnableMethodFactory<StatusBubbleViews::StatusView> timer_factory_; // Manager, owns us. StatusBubble* status_bubble_; @@ -164,7 +164,7 @@ class StatusBubble::StatusView : public views::Label, double opacity_end_; }; -void StatusBubble::StatusView::SetText(const std::wstring& text) { +void StatusBubbleViews::StatusView::SetText(const std::wstring& text) { if (text.empty()) { // The string was empty. StartHiding(); @@ -177,7 +177,7 @@ void StatusBubble::StatusView::SetText(const std::wstring& text) { SchedulePaint(); } -void StatusBubble::StatusView::Show() { +void StatusBubbleViews::StatusView::Show() { Stop(); CancelTimer(); SetOpacity(1.0); @@ -185,7 +185,7 @@ void StatusBubble::StatusView::Show() { PaintNow(); } -void StatusBubble::StatusView::Hide() { +void StatusBubbleViews::StatusView::Hide() { Stop(); CancelTimer(); SetOpacity(0.0); @@ -193,16 +193,16 @@ void StatusBubble::StatusView::Hide() { stage_ = BUBBLE_HIDDEN; } -void StatusBubble::StatusView::StartTimer(int time) { +void StatusBubbleViews::StatusView::StartTimer(int time) { if (!timer_factory_.empty()) timer_factory_.RevokeAll(); MessageLoop::current()->PostDelayedTask(FROM_HERE, - timer_factory_.NewRunnableMethod(&StatusBubble::StatusView::OnTimer), + timer_factory_.NewRunnableMethod(&StatusBubbleViews::StatusView::OnTimer), time); } -void StatusBubble::StatusView::OnTimer() { +void StatusBubbleViews::StatusView::OnTimer() { if (stage_ == BUBBLE_HIDING_TIMER) { stage_ = BUBBLE_HIDING_FADE; StartFade(1.0, 0.0, kHideFadeDurationMS); @@ -212,18 +212,18 @@ void StatusBubble::StatusView::OnTimer() { } } -void StatusBubble::StatusView::CancelTimer() { +void StatusBubbleViews::StatusView::CancelTimer() { if (!timer_factory_.empty()) { timer_factory_.RevokeAll(); } } -void StatusBubble::StatusView::RestartTimer(int delay) { +void StatusBubbleViews::StatusView::RestartTimer(int delay) { CancelTimer(); StartTimer(delay); } -void StatusBubble::StatusView::ResetTimer() { +void StatusBubbleViews::StatusView::ResetTimer() { if (stage_ == BUBBLE_SHOWING_TIMER) { // We hadn't yet begun showing anything when we received a new request // for something to show, so we start from scratch. @@ -231,9 +231,9 @@ void StatusBubble::StatusView::ResetTimer() { } } -void StatusBubble::StatusView::StartFade(double start, - double end, - int duration) { +void StatusBubbleViews::StatusView::StartFade(double start, + double end, + int duration) { opacity_start_ = start; opacity_end_ = end; @@ -242,7 +242,7 @@ void StatusBubble::StatusView::StartFade(double start, Start(); } -void StatusBubble::StatusView::StartHiding() { +void StatusBubbleViews::StatusView::StartHiding() { if (stage_ == BUBBLE_SHOWN) { stage_ = BUBBLE_HIDING_TIMER; StartTimer(kHideDelay); @@ -260,7 +260,7 @@ void StatusBubble::StatusView::StartHiding() { } } -void StatusBubble::StatusView::StartShowing() { +void StatusBubbleViews::StatusView::StartShowing() { if (stage_ == BUBBLE_HIDDEN) { stage_ = BUBBLE_SHOWING_TIMER; StartTimer(kShowDelay); @@ -285,21 +285,21 @@ void StatusBubble::StatusView::StartShowing() { } // Animation functions. -double StatusBubble::StatusView::GetCurrentOpacity() { +double StatusBubbleViews::StatusView::GetCurrentOpacity() { return opacity_start_ + (opacity_end_ - opacity_start_) * Animation::GetCurrentValue(); } -void StatusBubble::StatusView::SetOpacity(double opacity) { +void StatusBubbleViews::StatusView::SetOpacity(double opacity) { popup_->SetLayeredAlpha(static_cast<BYTE>(opacity * 255)); SchedulePaint(); } -void StatusBubble::StatusView::AnimateToState(double state) { +void StatusBubbleViews::StatusView::AnimateToState(double state) { SetOpacity(GetCurrentOpacity()); } -void StatusBubble::StatusView::AnimationEnded( +void StatusBubbleViews::StatusView::AnimationEnded( const Animation* animation) { SetOpacity(opacity_end_); @@ -310,14 +310,14 @@ void StatusBubble::StatusView::AnimationEnded( } } -void StatusBubble::StatusView::SetStyle(BubbleStyle style) { +void StatusBubbleViews::StatusView::SetStyle(BubbleStyle style) { if (style_ != style) { style_ = style; SchedulePaint(); } } -void StatusBubble::StatusView::Paint(ChromeCanvas* canvas) { +void StatusBubbleViews::StatusView::Paint(ChromeCanvas* canvas) { SkPaint paint; paint.setStyle(SkPaint::kFill_Style); paint.setFlags(SkPaint::kAntiAlias_Flag); @@ -443,7 +443,7 @@ void StatusBubble::StatusView::Paint(ChromeCanvas* canvas) { // StatusBubble --------------------------------------------------------------- -StatusBubble::StatusBubble(views::Widget* frame) +StatusBubbleViews::StatusBubbleViews(views::Widget* frame) : popup_(NULL), frame_(frame), view_(NULL), @@ -453,7 +453,7 @@ StatusBubble::StatusBubble(views::Widget* frame) offset_(0) { } -StatusBubble::~StatusBubble() { +StatusBubbleViews::~StatusBubbleViews() { if (popup_.get()) popup_->CloseNow(); @@ -461,7 +461,7 @@ StatusBubble::~StatusBubble() { size_ = NULL; } -void StatusBubble::Init() { +void StatusBubbleViews::Init() { if (!popup_.get()) { popup_.reset(new views::WidgetWin()); popup_->set_delete_on_destroy(false); @@ -483,7 +483,7 @@ void StatusBubble::Init() { } } -void StatusBubble::SetStatus(const std::wstring& status_text) { +void StatusBubbleViews::SetStatus(const std::wstring& status_text) { if (status_text_ == status_text) return; @@ -499,7 +499,7 @@ void StatusBubble::SetStatus(const std::wstring& status_text) { } } -void StatusBubble::SetURL(const GURL& url, const std::wstring& languages) { +void StatusBubbleViews::SetURL(const GURL& url, const std::wstring& languages) { Init(); // If we want to clear a displayed URL but there is a status still to @@ -528,20 +528,14 @@ void StatusBubble::SetURL(const GURL& url, const std::wstring& languages) { view_->SetText(url_text_); } -void StatusBubble::ClearURL() { - Init(); - url_text_ = std::wstring(); - view_->SetText(url_text_); -} - -void StatusBubble::Hide() { +void StatusBubbleViews::Hide() { status_text_ = std::wstring(); url_text_ = std::wstring(); if (view_) view_->Hide(); } -void StatusBubble::MouseMoved() { +void StatusBubbleViews::MouseMoved() { if (view_) { view_->ResetTimer(); @@ -553,7 +547,7 @@ void StatusBubble::MouseMoved() { } } -void StatusBubble::AvoidMouse() { +void StatusBubbleViews::AvoidMouse() { // Our status bubble is located in screen coordinates, so we should get // those rather than attempting to reverse decode the web contents // coordinates. @@ -613,7 +607,7 @@ void StatusBubble::AvoidMouse() { } } -void StatusBubble::Reposition() { +void StatusBubbleViews::Reposition() { if (popup_.get()) { gfx::Point top_left; views::View::ConvertPointToScreen(frame_->GetRootView(), &top_left); @@ -625,7 +619,7 @@ void StatusBubble::Reposition() { } } -void StatusBubble::SetBounds(int x, int y, int w, int h) { +void StatusBubbleViews::SetBounds(int x, int y, int w, int h) { // If the UI layout is RTL, we need to mirror the position of the bubble // relative to the parent. if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { diff --git a/chrome/browser/views/status_bubble.h b/chrome/browser/views/status_bubble_views.h index f54efdc..945290c 100644 --- a/chrome/browser/views/status_bubble.h +++ b/chrome/browser/views/status_bubble_views.h @@ -2,10 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_VIEWS_STATUS_BUBBLE_H_ -#define CHROME_BROWSER_VIEWS_STATUS_BUBBLE_H_ +#ifndef CHROME_BROWSER_VIEWS_STATUS_BUBBLE_VIEWS_H_ +#define CHROME_BROWSER_VIEWS_STATUS_BUBBLE_VIEWS_H_ #include "base/gfx/rect.h" +#include "chrome/browser/status_bubble.h" #include "chrome/views/widget.h" #include "chrome/views/widget_win.h" @@ -14,33 +15,10 @@ class GURL; // StatusBubble displays a bubble of text that fades in, hovers over the // browser chrome and fades away when not needed. It is primarily designed // to allow users to see where hovered links point to. -class StatusBubble { +class StatusBubbleViews : public StatusBubble { public: - explicit StatusBubble(views::Widget* frame); - ~StatusBubble(); - - // Sets the bubble contents to a specific string and causes the bubble - // to display immediately. Subsequent empty SetURL calls (typically called - // when the cursor exits a link) will set the status bubble back to its - // status text. To hide the status bubble again, either call SetStatus - // with an empty string, or call Hide(). - void SetStatus(const std::wstring& status); - - // Sets the bubble text to a URL - if given a non-empty URL, this will cause - // the bubble to fade in and remain open until given an empty URL or until - // the Hide() method is called. languages is the value of Accept-Language - // to determine what characters are understood by a user. - void SetURL(const GURL& url, const std::wstring& languages); - - // Clear the URL and begin the fadeout of the bubble if not status text - // needs to be displayed. - void ClearURL(); - - // Skip the fade and instant-hide the bubble. - void Hide(); - - // Called when the user's mouse has moved over web content. - void MouseMoved(); + explicit StatusBubbleViews(views::Widget* frame); + ~StatusBubbleViews(); // Set the bounds of the bubble relative to the browser window. void SetBounds(int x, int y, int w, int h); @@ -49,6 +27,12 @@ class StatusBubble { // we have to manually position it when the browser window moves. void Reposition(); + // Overridden from StatusBubble: + virtual void SetStatus(const std::wstring& status); + virtual void SetURL(const GURL& url, const std::wstring& languages); + virtual void Hide(); + virtual void MouseMoved(); + private: class StatusView; @@ -80,8 +64,8 @@ class StatusBubble { views::Widget* frame_; StatusView* view_; - DISALLOW_COPY_AND_ASSIGN(StatusBubble); + DISALLOW_COPY_AND_ASSIGN(StatusBubbleViews); }; -#endif // CHROME_BROWSER_VIEWS_STATUS_BUBBLE_H_ +#endif // CHROME_BROWSER_VIEWS_STATUS_BUBBLE_VIEWS_H_ |