summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/external_tab_container.cc29
-rw-r--r--chrome/browser/external_tab_container.h8
-rw-r--r--chrome/browser/views/browser_bubble_win.cc2
-rw-r--r--chrome/browser/views/download_started_animation_win.cc6
-rw-r--r--chrome/browser/views/frame/browser_view.cc2
-rw-r--r--chrome/browser/views/fullscreen_exit_bubble.cc2
-rw-r--r--chrome/browser/views/html_dialog_view.cc3
-rw-r--r--chrome/browser/views/status_bubble_views.cc145
-rw-r--r--chrome/browser/views/status_bubble_views.h13
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.cc4
-rw-r--r--chrome/browser/views/tabs/dragged_tab_view.cc4
11 files changed, 134 insertions, 84 deletions
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc
index a32ed53..608b34e 100644
--- a/chrome/browser/external_tab_container.cc
+++ b/chrome/browser/external_tab_container.cc
@@ -323,6 +323,31 @@ void ExternalTabContainer::GetBounds(gfx::Rect* out,
*out = gfx::Rect(crect);
}
+void ExternalTabContainer::SetBounds(const gfx::Rect& bounds) {
+ SetBounds(bounds, NULL);
+}
+
+void ExternalTabContainer::SetBounds(const gfx::Rect& bounds,
+ gfx::NativeView other_window) {
+ NOTIMPLEMENTED();
+}
+
+void ExternalTabContainer::Close() {
+ NOTIMPLEMENTED();
+}
+
+void ExternalTabContainer::CloseNow() {
+ NOTIMPLEMENTED();
+}
+
+void ExternalTabContainer::Show() {
+ NOTIMPLEMENTED();
+}
+
+void ExternalTabContainer::Hide() {
+ NOTIMPLEMENTED();
+}
+
gfx::NativeView ExternalTabContainer::GetNativeView() const {
return m_hWnd;
}
@@ -334,6 +359,10 @@ void ExternalTabContainer::PaintNow(const gfx::Rect& update_rect) {
RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_NOERASE);
}
+void ExternalTabContainer::SetOpacity(unsigned char opacity) {
+ NOTIMPLEMENTED();
+}
+
views::RootView* ExternalTabContainer::GetRootView() {
return const_cast<views::RootView*>(&root_view_);
}
diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h
index ee111e7..536dd52 100644
--- a/chrome/browser/external_tab_container.h
+++ b/chrome/browser/external_tab_container.h
@@ -110,8 +110,16 @@ class ExternalTabContainer : public TabContentsDelegate,
// views::Widget
/////////////////////////////////////////////////////////////////////////////
virtual void GetBounds(gfx::Rect* out, bool including_frame) const;
+ virtual void SetBounds(const gfx::Rect& bounds);
+ virtual void SetBounds(const gfx::Rect& bounds,
+ gfx::NativeWindow other_window);
+ virtual void Close();
+ virtual void CloseNow();
+ virtual void Show();
+ virtual void Hide();
virtual gfx::NativeView GetNativeView() const;
virtual void PaintNow(const gfx::Rect& update_rect);
+ virtual void SetOpacity(unsigned char opacity);
virtual views::RootView* GetRootView();
virtual Widget* GetRootWidget() const { return NULL; }
virtual bool IsVisible() const;
diff --git a/chrome/browser/views/browser_bubble_win.cc b/chrome/browser/views/browser_bubble_win.cc
index 1adb229..47924ec 100644
--- a/chrome/browser/views/browser_bubble_win.cc
+++ b/chrome/browser/views/browser_bubble_win.cc
@@ -16,7 +16,7 @@ void BrowserBubble::InitPopup() {
pop->set_window_ex_style(WS_EX_LAYERED |
WS_EX_TOOLWINDOW |
l10n_util::GetExtendedTooltipStyles());
- pop->SetLayeredAlpha(0xFF);
+ pop->SetOpacity(0xFF);
pop->Init(native_view, bounds_, false);
pop->SetContentsView(view_);
popup_.reset(pop);
diff --git a/chrome/browser/views/download_started_animation_win.cc b/chrome/browser/views/download_started_animation_win.cc
index 799d2ec..4de387e 100644
--- a/chrome/browser/views/download_started_animation_win.cc
+++ b/chrome/browser/views/download_started_animation_win.cc
@@ -105,7 +105,7 @@ DownloadStartedAnimationWin::DownloadStartedAnimationWin(
popup_->set_window_style(WS_POPUP);
popup_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW |
WS_EX_TRANSPARENT);
- popup_->SetLayeredAlpha(0x00);
+ popup_->SetOpacity(0x00);
popup_->Init(tab_contents_->GetNativeView(), rc, false);
popup_->SetContentsView(this);
Reposition();
@@ -157,8 +157,8 @@ void DownloadStartedAnimationWin::AnimateToState(double state) {
double opacity = std::min(1.0 - pow(GetCurrentValue() - 0.5, 2) * 4.0,
static_cast<double>(1.0));
- popup_->SetLayeredAlpha(
- static_cast<BYTE>(opacity * 255.0));
+ popup_->SetOpacity(
+ static_cast<SkColor>(opacity * 255.0));
SchedulePaint(); // Reposition() calls MoveWindow() which never picks up
// alpha changes, so we need to force a paint.
}
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 5235fcd..677653a 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -569,7 +569,7 @@ void BrowserView::Show() {
}
void BrowserView::SetBounds(const gfx::Rect& bounds) {
- frame_->GetWindow()->SetBounds(bounds);
+ GetWidget()->SetBounds(bounds);
}
void BrowserView::Close() {
diff --git a/chrome/browser/views/fullscreen_exit_bubble.cc b/chrome/browser/views/fullscreen_exit_bubble.cc
index 1623779..3b5e60c 100644
--- a/chrome/browser/views/fullscreen_exit_bubble.cc
+++ b/chrome/browser/views/fullscreen_exit_bubble.cc
@@ -144,7 +144,7 @@ FullscreenExitBubble::FullscreenExitBubble(
popup_->set_window_style(WS_POPUP);
popup_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW |
l10n_util::GetExtendedTooltipStyles());
- popup_->SetLayeredAlpha(static_cast<int>(0xff * kOpacity));
+ popup_->SetOpacity(static_cast<unsigned char>(0xff * kOpacity));
popup_->Init(frame->GetNativeView(), GetPopupRect(false), false);
popup_->SetContentsView(view_);
popup_->Show(); // This does not activate the popup.
diff --git a/chrome/browser/views/html_dialog_view.cc b/chrome/browser/views/html_dialog_view.cc
index 4be7870..afb23ad 100644
--- a/chrome/browser/views/html_dialog_view.cc
+++ b/chrome/browser/views/html_dialog_view.cc
@@ -7,6 +7,7 @@
#include "chrome/browser/browser.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "views/widget/root_view.h"
+#include "views/widget/widget.h"
#include "views/window/window.h"
namespace browser {
@@ -157,7 +158,7 @@ void HtmlDialogView::CloseContents(TabContents* source) {
void HtmlDialogView::MoveContents(TabContents* source, const gfx::Rect& pos) {
// The contained web page wishes to resize itself. We let it do this because
// if it's a dialog we know about, we trust it not to be mean to the user.
- window()->SetBounds(pos);
+ GetWidget()->SetBounds(pos);
}
bool HtmlDialogView::IsPopup(TabContents* source) {
diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc
index 59b78ef..9c8748a 100644
--- a/chrome/browser/views/status_bubble_views.cc
+++ b/chrome/browser/views/status_bubble_views.cc
@@ -9,7 +9,9 @@
#include "app/gfx/canvas.h"
#include "app/gfx/text_elider.h"
#include "app/l10n_util.h"
+#if defined(OS_WIN)
#include "app/l10n_util_win.h"
+#endif
#include "app/animation.h"
#include "app/resource_bundle.h"
#include "base/string_util.h"
@@ -22,7 +24,10 @@
#include "third_party/skia/include/core/SkRect.h"
#include "views/controls/label.h"
#include "views/widget/root_view.h"
+#include "views/widget/widget.h"
+#if defined(OS_WIN)
#include "views/widget/widget_win.h"
+#endif
// The color of the background bubble.
static const SkColor kBubbleColor = SkColorSetRGB(222, 234, 248);
@@ -69,13 +74,13 @@ class StatusBubbleViews::StatusView : public views::Label,
public Animation,
public AnimationDelegate {
public:
- StatusView(StatusBubble* status_bubble, views::WidgetWin* popup)
+ StatusView(StatusBubble* status_bubble, views::Widget* popup)
: Animation(kFramerate, this),
- status_bubble_(status_bubble),
- popup_(popup),
stage_(BUBBLE_HIDDEN),
style_(STYLE_STANDARD),
timer_factory_(this),
+ status_bubble_(status_bubble),
+ popup_(popup),
opacity_start_(0),
opacity_end_(0) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
@@ -83,7 +88,7 @@ class StatusBubbleViews::StatusView : public views::Label,
SetFont(font);
}
- ~StatusView() {
+ virtual ~StatusView() {
Stop();
CancelTimer();
}
@@ -155,8 +160,8 @@ class StatusBubbleViews::StatusView : public views::Label,
// Manager, owns us.
StatusBubble* status_bubble_;
- // Handle to the HWND that contains us.
- views::WidgetWin* popup_;
+ // Handle to the widget that contains us.
+ views::Widget* popup_;
// The currently-displayed text.
std::wstring text_;
@@ -219,9 +224,8 @@ void StatusBubbleViews::StatusView::OnTimer() {
}
void StatusBubbleViews::StatusView::CancelTimer() {
- if (!timer_factory_.empty()) {
+ if (!timer_factory_.empty())
timer_factory_.RevokeAll();
- }
}
void StatusBubbleViews::StatusView::RestartTimer(int delay) {
@@ -298,7 +302,7 @@ double StatusBubbleViews::StatusView::GetCurrentOpacity() {
}
void StatusBubbleViews::StatusView::SetOpacity(double opacity) {
- popup_->SetLayeredAlpha(static_cast<BYTE>(opacity * 255));
+ popup_->SetOpacity(static_cast<unsigned char>(opacity * 255));
SchedulePaint();
}
@@ -331,8 +335,8 @@ void StatusBubbleViews::StatusView::Paint(gfx::Canvas* canvas) {
paint.setFlags(SkPaint::kAntiAlias_Flag);
paint.setColor(kBubbleColor);
- RECT parent_rect;
- ::GetWindowRect(popup_->GetNativeView(), &parent_rect);
+ gfx::Rect popup_bounds;
+ popup_->GetBounds(&popup_bounds, true);
// Figure out how to round the bubble's four corners.
SkScalar rad[8];
@@ -392,8 +396,8 @@ void StatusBubbleViews::StatusView::Paint(gfx::Canvas* canvas) {
}
// Draw the bubble's shadow.
- int width = parent_rect.right - parent_rect.left;
- int height = parent_rect.bottom - parent_rect.top;
+ int width = popup_bounds.width();
+ int height = popup_bounds.height();
SkRect rect;
rect.set(0, 0,
SkIntToScalar(width),
@@ -449,42 +453,40 @@ void StatusBubbleViews::StatusView::Paint(gfx::Canvas* canvas) {
const int StatusBubbleViews::kShadowThickness = 1;
StatusBubbleViews::StatusBubbleViews(views::Widget* frame)
- : popup_(NULL),
- frame_(frame),
- view_(NULL),
+ : offset_(0),
+ popup_(NULL),
opacity_(0),
- position_(0, 0),
- size_(0, 0),
- offset_(0) {
+ frame_(frame),
+ view_(NULL) {
}
StatusBubbleViews::~StatusBubbleViews() {
if (popup_.get())
popup_->CloseNow();
-
- position_ = NULL;
- size_ = NULL;
}
void StatusBubbleViews::Init() {
if (!popup_.get()) {
- popup_.reset(new views::WidgetWin());
- popup_->set_delete_on_destroy(false);
+#if defined(OS_WIN)
+ views::WidgetWin* popup = new views::WidgetWin;
+ popup->set_delete_on_destroy(false);
if (!view_)
- view_ = new StatusView(this, popup_.get());
-
- gfx::Rect rc(0, 0, 0, 0);
-
- popup_->set_window_style(WS_POPUP);
- popup_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW |
- WS_EX_TRANSPARENT |
- l10n_util::GetExtendedTooltipStyles());
- popup_->SetLayeredAlpha(0x00);
- popup_->Init(frame_->GetNativeView(), rc, false);
- popup_->SetContentsView(view_);
+ view_ = new StatusView(this, popup);
+
+ popup->set_window_style(WS_POPUP);
+ popup->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW |
+ WS_EX_TRANSPARENT |
+ l10n_util::GetExtendedTooltipStyles());
+ popup->SetOpacity(0x00);
+ popup->Init(frame_->GetNativeView(), gfx::Rect(), false);
+ popup->SetContentsView(view_);
Reposition();
- popup_->Show();
+ popup->Show();
+ popup_.reset(popup);
+#else
+ NOTIMPLEMENTED();
+#endif
}
}
@@ -516,9 +518,9 @@ void StatusBubbleViews::SetURL(const GURL& url, const std::wstring& languages) {
}
// Set Elided Text corresponding to the GURL object.
- RECT parent_rect;
- ::GetWindowRect(popup_->GetNativeView(), &parent_rect);
- int text_width = static_cast<int>(parent_rect.right - parent_rect.left -
+ gfx::Rect popup_bounds;
+ popup_->GetBounds(&popup_bounds, true);
+ int text_width = static_cast<int>(popup_bounds.width() -
(kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1);
url_text_ = gfx::ElideUrl(url, view_->Label::GetFont(), text_width,
languages);
@@ -555,8 +557,14 @@ 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.
- CPoint cursor_location;
- GetCursorPos(&cursor_location);
+ gfx::Point cursor_location;
+#if defined(OS_WIN)
+ POINT tmp = { 0, 0 };
+ GetCursorPos(&tmp);
+ cursor_location = tmp;
+#else
+ NOTIMPLEMENTED();
+#endif
// Get the position of the frame.
gfx::Point top_left;
@@ -564,32 +572,32 @@ void StatusBubbleViews::AvoidMouse() {
views::View::ConvertPointToScreen(root, &top_left);
// Get the cursor position relative to the popup.
- cursor_location.x -= (top_left.x() + position_.x);
- cursor_location.y -= (top_left.y() + position_.y);
+ cursor_location.set_x(cursor_location.x() - (top_left.x() + position_.x()));
+ cursor_location.set_y(cursor_location.y() - (top_left.y() + position_.y()));
// If the mouse is in a position where we think it would move the
// status bubble, figure out where and how the bubble should be moved.
- if (cursor_location.y > -kMousePadding &&
- cursor_location.x < size_.cx + kMousePadding) {
- int offset = kMousePadding + cursor_location.y;
+ if (cursor_location.y() > -kMousePadding &&
+ cursor_location.x() < size_.width() + kMousePadding) {
+ int offset = kMousePadding + cursor_location.y();
// Make the movement non-linear.
offset = offset * offset / kMousePadding;
// When the mouse is entering from the right, we want the offset to be
// scaled by how horizontally far away the cursor is from the bubble.
- if (cursor_location.x > size_.cx) {
+ if (cursor_location.x() > size_.width()) {
offset = static_cast<int>(static_cast<float>(offset) * (
static_cast<float>(kMousePadding -
- (cursor_location.x - size_.cx)) /
+ (cursor_location.x() - size_.width())) /
static_cast<float>(kMousePadding)));
}
// Cap the offset and change the visual presentation of the bubble
// depending on where it ends up (so that rounded corners square off
// and mate to the edges of the tab content).
- if (offset >= size_.cy - kShadowThickness * 2) {
- offset = size_.cy - kShadowThickness * 2;
+ if (offset >= size_.height() - kShadowThickness * 2) {
+ offset = size_.height() - kShadowThickness * 2;
view_->SetStyle(StatusView::STYLE_BOTTOM);
} else if (offset > kBubbleCornerRadius / 2 - kShadowThickness) {
view_->SetStyle(StatusView::STYLE_FLOATING);
@@ -598,12 +606,17 @@ void StatusBubbleViews::AvoidMouse() {
}
// Check if the bubble sticks out from the monitor.
+#if defined(OS_WIN)
MONITORINFO monitor_info;
monitor_info.cbSize = sizeof(monitor_info);
GetMonitorInfo(MonitorFromWindow(frame_->GetNativeView(),
MONITOR_DEFAULTTONEAREST), &monitor_info);
gfx::Rect monitor_rect(monitor_info.rcWork);
- const int bubble_bottom_y = top_left.y() + position_.y + size_.cy;
+#else
+ gfx::Rect monitor_rect;
+ NOTIMPLEMENTED();
+#endif
+ const int bubble_bottom_y = top_left.y() + position_.y() + size_.height();
if (bubble_bottom_y + offset > monitor_rect.height()) {
// The offset is still too large. Move the bubble to the right and reset
@@ -613,26 +626,23 @@ void StatusBubbleViews::AvoidMouse() {
int root_width = root->GetLocalBounds(true).width(); // border included.
// Substract border width + bubble width.
- int right_position_x = root_width - (position_.x + size_.cx);
- popup_->MoveWindow(top_left.x() + right_position_x,
- top_left.y() + position_.y,
- size_.cx,
- size_.cy);
+ int right_position_x = root_width - (position_.x() + size_.width());
+ popup_->SetBounds(gfx::Rect(top_left.x() + right_position_x,
+ top_left.y() + position_.y(),
+ size_.width(), size_.height()));
} else {
offset_ = offset;
- popup_->MoveWindow(top_left.x() + position_.x,
- top_left.y() + position_.y + offset_,
- size_.cx,
- size_.cy);
+ popup_->SetBounds(gfx::Rect(top_left.x() + position_.x(),
+ top_left.y() + position_.y() + offset_,
+ size_.width(), size_.height()));
}
} else if (offset_ != 0 ||
view_->GetStyle() == StatusView::STYLE_STANDARD_RIGHT) {
offset_ = 0;
view_->SetStyle(StatusView::STYLE_STANDARD);
- popup_->MoveWindow(top_left.x() + position_.x,
- top_left.y() + position_.y,
- size_.cx,
- size_.cy);
+ popup_->SetBounds(gfx::Rect(top_left.x() + position_.x(),
+ top_left.y() + position_.y(),
+ size_.width(), size_.height()));
}
}
@@ -641,10 +651,9 @@ void StatusBubbleViews::Reposition() {
gfx::Point top_left;
views::View::ConvertPointToScreen(frame_->GetRootView(), &top_left);
- popup_->MoveWindow(top_left.x() + position_.x,
- top_left.y() + position_.y,
- size_.cx,
- size_.cy);
+ popup_->SetBounds(gfx::Rect(top_left.x() + position_.x(),
+ top_left.y() + position_.y(),
+ size_.width(), size_.height()));
}
}
diff --git a/chrome/browser/views/status_bubble_views.h b/chrome/browser/views/status_bubble_views.h
index cdda382..5a94bb2 100644
--- a/chrome/browser/views/status_bubble_views.h
+++ b/chrome/browser/views/status_bubble_views.h
@@ -6,11 +6,14 @@
#define CHROME_BROWSER_VIEWS_STATUS_BUBBLE_VIEWS_H_
#include "base/gfx/rect.h"
+#include "base/logging.h"
+#include "base/scoped_ptr.h"
#include "chrome/browser/status_bubble.h"
-#include "views/widget/widget.h"
-#include "views/widget/widget_win.h"
class GURL;
+namespace views {
+class Widget;
+}
// StatusBubble displays a bubble of text that fades in, hovers over the
// browser chrome and fades away when not needed. It is primarily designed
@@ -53,15 +56,15 @@ class StatusBubbleViews : public StatusBubble {
std::wstring url_text_;
// Position relative to the parent window.
- CPoint position_;
- CSize size_;
+ gfx::Point position_;
+ gfx::Size size_;
// How vertically offset the bubble is from its root position_.
int offset_;
// We use a HWND for the popup so that it may float above any HWNDs in our
// UI (the location bar, for example).
- scoped_ptr<views::WidgetWin> popup_;
+ scoped_ptr<views::Widget> popup_;
double opacity_;
views::Widget* frame_;
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc
index b3ac3bf..06ca3ad 100644
--- a/chrome/browser/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/views/tabs/dragged_tab_controller.cc
@@ -169,7 +169,7 @@ class DraggedTabController::DockDisplayer : public AnimationDelegate {
popup->set_window_style(WS_POPUP);
popup->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW |
WS_EX_TOPMOST);
- popup->SetLayeredAlpha(0x00);
+ popup->SetOpacity(0x00);
popup->Init(NULL, info.GetPopupRect(), false);
popup->SetContentsView(new DockView(info.type()));
if (info.in_enable_area())
@@ -237,7 +237,7 @@ class DraggedTabController::DockDisplayer : public AnimationDelegate {
virtual void UpdateLayeredAlpha() {
#if defined(OS_WIN)
double scale = in_enable_area_ ? 1 : .5;
- static_cast<views::WidgetWin*>(popup_)->SetLayeredAlpha(
+ static_cast<views::WidgetWin*>(popup_)->SetOpacity(
static_cast<BYTE>(animation_.GetCurrentValue() * scale * 255.0));
popup_->GetRootView()->SchedulePaint();
#else
diff --git a/chrome/browser/views/tabs/dragged_tab_view.cc b/chrome/browser/views/tabs/dragged_tab_view.cc
index c805db1..77fd7c7 100644
--- a/chrome/browser/views/tabs/dragged_tab_view.cc
+++ b/chrome/browser/views/tabs/dragged_tab_view.cc
@@ -104,7 +104,7 @@ void DraggedTabView::Attach(int selected_width) {
photobooth_ = NULL;
attached_tab_size_.set_width(selected_width);
#if defined(OS_WIN)
- container_->SetLayeredAlpha(kOpaqueAlpha);
+ container_->SetOpacity(kOpaqueAlpha);
#else
NOTIMPLEMENTED();
#endif
@@ -116,7 +116,7 @@ void DraggedTabView::Detach(NativeViewPhotobooth* photobooth) {
attached_ = false;
photobooth_ = photobooth;
#if defined(OS_WIN)
- container_->SetLayeredAlpha(kTransparentAlpha);
+ container_->SetOpacity(kTransparentAlpha);
#else
NOTIMPLEMENTED();
#endif