summaryrefslogtreecommitdiffstats
path: root/views/widget
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-13 21:11:37 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-13 21:11:37 +0000
commit2463b91b1b318bfdbc669aaf757baa2417ba1091 (patch)
tree736c9e2933adeefa3155a303a6c12b798bbe4483 /views/widget
parentbdcb2ccce86b01f748ecd18b3330c0a42df8ee0e (diff)
downloadchromium_src-2463b91b1b318bfdbc669aaf757baa2417ba1091.zip
chromium_src-2463b91b1b318bfdbc669aaf757baa2417ba1091.tar.gz
chromium_src-2463b91b1b318bfdbc669aaf757baa2417ba1091.tar.bz2
Disables tooltips if we can't create the tooltip window. I still don't
understand why we can't create tooltips for some folks, but this should at least keep us from crashing. BUG=82193 TEST=none R=ben@chromium.org Review URL: http://codereview.chromium.org/6995157 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88897 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget')
-rw-r--r--views/widget/aero_tooltip_manager.cc26
-rw-r--r--views/widget/aero_tooltip_manager.h1
-rw-r--r--views/widget/native_widget_win.cc9
-rw-r--r--views/widget/native_widget_win.h3
-rw-r--r--views/widget/tooltip_manager_win.cc13
-rw-r--r--views/widget/tooltip_manager_win.h7
6 files changed, 24 insertions, 35 deletions
diff --git a/views/widget/aero_tooltip_manager.cc b/views/widget/aero_tooltip_manager.cc
index 855271e..bd30e2d 100644
--- a/views/widget/aero_tooltip_manager.cc
+++ b/views/widget/aero_tooltip_manager.cc
@@ -72,32 +72,6 @@ void AeroTooltipManager::OnMouse(UINT u_msg, WPARAM w_param, LPARAM l_param) {
///////////////////////////////////////////////////////////////////////////////
// AeroTooltipManager, private:
-void AeroTooltipManager::Init() {
- // Create the tooltip control.
- tooltip_hwnd_ = CreateWindowEx(
- WS_EX_TRANSPARENT | l10n_util::GetExtendedTooltipStyles(),
- TOOLTIPS_CLASS, NULL, TTS_NOPREFIX, 0, 0, 0, 0,
- GetParent(), NULL, NULL, NULL);
- ui::CheckWindowCreated(tooltip_hwnd_);
-
- l10n_util::AdjustUIFontForWindow(tooltip_hwnd_);
-
- // Add one tool that is used for all tooltips.
- toolinfo_.cbSize = sizeof(toolinfo_);
-
- // We use tracking tooltips on Vista to allow us to manually control the
- // visibility of the tooltip.
- toolinfo_.uFlags = TTF_TRANSPARENT | TTF_IDISHWND | TTF_TRACK | TTF_ABSOLUTE;
- toolinfo_.hwnd = GetParent();
- toolinfo_.uId = (UINT_PTR)GetParent();
-
- // Setting this tells windows to call GetParent() back (using a WM_NOTIFY
- // message) for the actual tooltip contents.
- toolinfo_.lpszText = LPSTR_TEXTCALLBACK;
- SetRectEmpty(&toolinfo_.rect);
- ::SendMessage(tooltip_hwnd_, TTM_ADDTOOL, 0, (LPARAM)&toolinfo_);
-}
-
void AeroTooltipManager::OnTimer() {
initial_timer_ = NULL;
diff --git a/views/widget/aero_tooltip_manager.h b/views/widget/aero_tooltip_manager.h
index 025e428..12efd0c 100644
--- a/views/widget/aero_tooltip_manager.h
+++ b/views/widget/aero_tooltip_manager.h
@@ -35,7 +35,6 @@ class AeroTooltipManager : public TooltipManagerWin {
virtual void OnMouse(UINT u_msg, WPARAM w_param, LPARAM l_param);
private:
- void Init();
void OnTimer();
class InitialTimer : public base::RefCounted<InitialTimer> {
diff --git a/views/widget/native_widget_win.cc b/views/widget/native_widget_win.cc
index 599bdd5..d06b47e 100644
--- a/views/widget/native_widget_win.cc
+++ b/views/widget/native_widget_win.cc
@@ -1162,6 +1162,12 @@ LRESULT NativeWidgetWin::OnCreate(CREATESTRUCT* create_struct) {
} else {
tooltip_manager_.reset(new TooltipManagerWin(GetWidget()));
}
+ if (!tooltip_manager_->Init()) {
+ // There was a problem creating the TooltipManager. Common error is 127.
+ // See 82193 for details.
+ LOG_GETLASTERROR(WARNING) << "tooltip creation failed, disabling tooltips";
+ tooltip_manager_.reset();
+ }
// This message initializes the window so that focus border are shown for
// windows.
@@ -1478,7 +1484,8 @@ LRESULT NativeWidgetWin::OnMouseRange(UINT message,
MouseEvent event(msg);
if (!(event.flags() & ui::EF_IS_NON_CLIENT))
- tooltip_manager_->OnMouse(message, w_param, l_param);
+ if (tooltip_manager_.get())
+ tooltip_manager_->OnMouse(message, w_param, l_param);
if (event.type() == ui::ET_MOUSE_MOVED && !HasMouseCapture()) {
// Windows only fires WM_MOUSELEAVE events if the application begins
diff --git a/views/widget/native_widget_win.h b/views/widget/native_widget_win.h
index 94bf6e2..524fd84 100644
--- a/views/widget/native_widget_win.h
+++ b/views/widget/native_widget_win.h
@@ -461,7 +461,8 @@ class NativeWidgetWin : public ui::WindowImpl,
focus_on_creation_ = focus_on_creation;
}
- // The TooltipManager.
+ // The TooltipManager. This is NULL if there is a problem creating the
+ // underlying tooltip window.
// WARNING: RootView's destructor calls into the TooltipManager. As such, this
// must be destroyed AFTER root_view_.
scoped_ptr<TooltipManagerWin> tooltip_manager_;
diff --git a/views/widget/tooltip_manager_win.cc b/views/widget/tooltip_manager_win.cc
index 9158818..68714b9 100644
--- a/views/widget/tooltip_manager_win.cc
+++ b/views/widget/tooltip_manager_win.cc
@@ -36,7 +36,8 @@ static gfx::Font DetermineDefaultFont() {
HWND window = CreateWindowEx(
WS_EX_TRANSPARENT | l10n_util::GetExtendedTooltipStyles(),
TOOLTIPS_CLASS, NULL, 0 , 0, 0, 0, 0, NULL, NULL, NULL, NULL);
- ui::CheckWindowCreated(window);
+ if (!window)
+ return gfx::Font();
HFONT hfont = reinterpret_cast<HFONT>(SendMessage(window, WM_GETFONT, 0, 0));
gfx::Font font = hfont ? gfx::Font(hfont) : gfx::Font();
DestroyWindow(window);
@@ -90,13 +91,14 @@ TooltipManagerWin::~TooltipManagerWin() {
DestroyWindow(keyboard_tooltip_hwnd_);
}
-void TooltipManagerWin::Init() {
+bool TooltipManagerWin::Init() {
// Create the tooltip control.
tooltip_hwnd_ = CreateWindowEx(
WS_EX_TRANSPARENT | l10n_util::GetExtendedTooltipStyles(),
TOOLTIPS_CLASS, NULL, TTS_NOPREFIX, 0, 0, 0, 0,
GetParent(), NULL, NULL, NULL);
- ui::CheckWindowCreated(tooltip_hwnd_);
+ if (!tooltip_hwnd_)
+ return false;
l10n_util::AdjustUIFontForWindow(tooltip_hwnd_);
@@ -117,6 +119,7 @@ void TooltipManagerWin::Init() {
toolinfo_.lpszText = LPSTR_TEXTCALLBACK;
SetRectEmpty(&toolinfo_.rect);
SendMessage(tooltip_hwnd_, TTM_ADDTOOL, 0, (LPARAM)&toolinfo_);
+ return true;
}
gfx::NativeView TooltipManagerWin::GetParent() {
@@ -335,7 +338,9 @@ void TooltipManagerWin::ShowKeyboardTooltip(View* focused_view) {
keyboard_tooltip_hwnd_ = CreateWindowEx(
WS_EX_TRANSPARENT | l10n_util::GetExtendedTooltipStyles(),
TOOLTIPS_CLASS, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
- ui::CheckWindowCreated(keyboard_tooltip_hwnd_);
+ if (!keyboard_tooltip_hwnd_)
+ return;
+
SendMessage(keyboard_tooltip_hwnd_, TTM_SETMAXTIPWIDTH, 0,
std::numeric_limits<short>::max());
int tooltip_width;
diff --git a/views/widget/tooltip_manager_win.h b/views/widget/tooltip_manager_win.h
index 881ce20..dd7741f 100644
--- a/views/widget/tooltip_manager_win.h
+++ b/views/widget/tooltip_manager_win.h
@@ -62,6 +62,11 @@ class TooltipManagerWin : public TooltipManager {
explicit TooltipManagerWin(Widget* widget);
virtual ~TooltipManagerWin();
+ // Initializes the TooltipManager returning whether initialization was
+ // successful. If this returns false the TooltipManager should be destroyed
+ // and not used.
+ bool Init();
+
// Notification that the view hierarchy has changed in some way.
virtual void UpdateTooltip();
@@ -79,8 +84,6 @@ class TooltipManagerWin : public TooltipManager {
LRESULT OnNotify(int w_param, NMHDR* l_param, bool* handled);
protected:
- virtual void Init();
-
// Returns the Widget we're showing tooltips for.
gfx::NativeView GetParent();