Destroy tooltip manager if the native window is destroyed.

Also revert the previous attempt to fix this issue:

Revert "Aura build fix: Make TooltipManagerViews an observer of parent Widget and"

This reverts commit 67498136.

BUG=none
TEST=none


Review URL: http://codereview.chromium.org/8418028

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107776 0039d316-1c4b-4281-b951-d872f2087c98
parent 222e4548
...@@ -540,6 +540,9 @@ void NativeWidgetAura::OnPaint(gfx::Canvas* canvas) { ...@@ -540,6 +540,9 @@ void NativeWidgetAura::OnPaint(gfx::Canvas* canvas) {
void NativeWidgetAura::OnWindowDestroying() { void NativeWidgetAura::OnWindowDestroying() {
delegate_->OnNativeWidgetDestroying(); delegate_->OnNativeWidgetDestroying();
// If the aura::Window is destroyed, we can no longer show tooltips.
tooltip_manager_.reset();
} }
void NativeWidgetAura::OnWindowDestroyed() { void NativeWidgetAura::OnWindowDestroyed() {
......
...@@ -75,8 +75,7 @@ int TooltipManager::GetMaxWidth(int x, int y) { ...@@ -75,8 +75,7 @@ int TooltipManager::GetMaxWidth(int x, int y) {
TooltipManagerViews::TooltipManagerViews(views::View* root_view) TooltipManagerViews::TooltipManagerViews(views::View* root_view)
: root_view_(root_view), : root_view_(root_view),
tooltip_view_(NULL), tooltip_view_(NULL) {
widget_closed_(false) {
tooltip_label_.set_background( tooltip_label_.set_background(
views::Background::CreateSolidBackground(kTooltipBackground)); views::Background::CreateSolidBackground(kTooltipBackground));
tooltip_widget_.reset(CreateTooltip()); tooltip_widget_.reset(CreateTooltip());
...@@ -87,7 +86,6 @@ TooltipManagerViews::TooltipManagerViews(views::View* root_view) ...@@ -87,7 +86,6 @@ TooltipManagerViews::TooltipManagerViews(views::View* root_view)
base::TimeDelta::FromMilliseconds(kTooltipTimeoutMs), base::TimeDelta::FromMilliseconds(kTooltipTimeoutMs),
this, &TooltipManagerViews::TooltipTimerFired); this, &TooltipManagerViews::TooltipTimerFired);
MessageLoopForUI::current()->AddObserver(this); MessageLoopForUI::current()->AddObserver(this);
root_view_->GetWidget()->AddObserver(this);
} }
TooltipManagerViews::~TooltipManagerViews() { TooltipManagerViews::~TooltipManagerViews() {
...@@ -152,11 +150,6 @@ void TooltipManagerViews::DidProcessEvent(const base::NativeEvent& event) { ...@@ -152,11 +150,6 @@ void TooltipManagerViews::DidProcessEvent(const base::NativeEvent& event) {
} }
#endif #endif
void TooltipManagerViews::OnWidgetClosing(Widget* widget) {
tooltip_timer_.Stop();
widget_closed_ = true;
}
void TooltipManagerViews::TooltipTimerFired() { void TooltipManagerViews::TooltipTimerFired() {
UpdateIfRequired(curr_mouse_pos_.x(), curr_mouse_pos_.y(), false); UpdateIfRequired(curr_mouse_pos_.x(), curr_mouse_pos_.y(), false);
} }
...@@ -179,9 +172,6 @@ View* TooltipManagerViews::GetViewForTooltip(int x, int y, bool for_keyboard) { ...@@ -179,9 +172,6 @@ View* TooltipManagerViews::GetViewForTooltip(int x, int y, bool for_keyboard) {
} }
void TooltipManagerViews::UpdateIfRequired(int x, int y, bool for_keyboard) { void TooltipManagerViews::UpdateIfRequired(int x, int y, bool for_keyboard) {
if (widget_closed_)
return;
View* view = GetViewForTooltip(x, y, for_keyboard); View* view = GetViewForTooltip(x, y, for_keyboard);
string16 tooltip_text; string16 tooltip_text;
if (view) if (view)
......
...@@ -27,8 +27,7 @@ class Widget; ...@@ -27,8 +27,7 @@ class Widget;
// TooltipManager implementation for Views. // TooltipManager implementation for Views.
class TooltipManagerViews : public TooltipManager, class TooltipManagerViews : public TooltipManager,
public MessageLoopForUI::Observer, public MessageLoopForUI::Observer {
public Widget::Observer {
public: public:
explicit TooltipManagerViews(views::View* root_view); explicit TooltipManagerViews(views::View* root_view);
virtual ~TooltipManagerViews(); virtual ~TooltipManagerViews();
...@@ -49,9 +48,6 @@ class TooltipManagerViews : public TooltipManager, ...@@ -49,9 +48,6 @@ class TooltipManagerViews : public TooltipManager,
virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE; virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE;
#endif #endif
// Widget::Observer
virtual void OnWidgetClosing(Widget* widget) OVERRIDE;
private: private:
void TooltipTimerFired(); void TooltipTimerFired();
View* GetViewForTooltip(int x, int y, bool for_keyboard); View* GetViewForTooltip(int x, int y, bool for_keyboard);
...@@ -84,9 +80,6 @@ class TooltipManagerViews : public TooltipManager, ...@@ -84,9 +80,6 @@ class TooltipManagerViews : public TooltipManager,
gfx::Point curr_mouse_pos_; gfx::Point curr_mouse_pos_;
base::RepeatingTimer<TooltipManagerViews> tooltip_timer_; base::RepeatingTimer<TooltipManagerViews> tooltip_timer_;
// true when the widget that owns us has closed.
bool widget_closed_;
DISALLOW_COPY_AND_ASSIGN(TooltipManagerViews); DISALLOW_COPY_AND_ASSIGN(TooltipManagerViews);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment