diff options
-rw-r--r-- | ui/base/win/hwnd_util.cc | 18 | ||||
-rw-r--r-- | views/view.cc | 3 | ||||
-rw-r--r-- | views/widget/aero_tooltip_manager.cc | 26 | ||||
-rw-r--r-- | views/widget/aero_tooltip_manager.h | 1 | ||||
-rw-r--r-- | views/widget/native_widget_win.cc | 9 | ||||
-rw-r--r-- | views/widget/native_widget_win.h | 3 | ||||
-rw-r--r-- | views/widget/tooltip_manager_win.cc | 13 | ||||
-rw-r--r-- | views/widget/tooltip_manager_win.h | 7 |
8 files changed, 28 insertions, 52 deletions
diff --git a/ui/base/win/hwnd_util.cc b/ui/base/win/hwnd_util.cc index e71dac8..923c85c 100644 --- a/ui/base/win/hwnd_util.cc +++ b/ui/base/win/hwnd_util.cc @@ -170,22 +170,8 @@ void CenterAndSizeWindow(HWND parent, } void CheckWindowCreated(HWND hwnd) { - if (hwnd) - return; - - LPWSTR error_string = NULL; - DWORD last_error = GetLastError(); - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM, - 0, // Use the internal message table. - last_error, - 0, // Use default language. - reinterpret_cast<LPWSTR>(&error_string), - 0, // Buffer size. - 0); // Arguments (unused). - // Typical reason for failure is ERROR_NOT_ENOUGH_MEMORY (8). - CHECK(false) << "Create failed error=" << last_error << - " message=" << error_string; + if (!hwnd) + LOG_GETLASTERROR(FATAL); } } // namespace ui diff --git a/views/view.cc b/views/view.cc index 060ffbe..ddf81bf 100644 --- a/views/view.cc +++ b/views/view.cc @@ -1245,7 +1245,8 @@ void View::Blur() { void View::TooltipTextChanged() { Widget* widget = GetWidget(); - if (widget) + // TooltipManager may be null if there is a problem creating it. + if (widget && widget->native_widget()->GetTooltipManager()) widget->native_widget()->GetTooltipManager()->TooltipTextChanged(this); } 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(); |