views: Don't leak ViewsDelegate.

This commit is contained in:
Cheng Zhao 2014-07-04 21:41:22 +08:00
parent 651ebdde65
commit 7a196933bb
3 changed files with 10 additions and 3 deletions

View file

@ -50,9 +50,7 @@ void BrowserMainParts::ToolkitInitialized() {
#endif
#if defined(TOOLKIT_VIEWS)
if (!views::ViewsDelegate::views_delegate)
views::ViewsDelegate::views_delegate = new ViewsDelegate;
views_delegate_.reset(new ViewsDelegate);
wm_state_.reset(new wm::WMState);
#endif
}

View file

@ -10,6 +10,10 @@
#include "content/public/browser/browser_main_parts.h"
#if defined(TOOLKIT_VIEWS)
namespace brightray {
class ViewsDelegate;
}
namespace wm {
class WMState;
}
@ -53,6 +57,7 @@ class BrowserMainParts : public content::BrowserMainParts {
scoped_ptr<WebUIControllerFactory> web_ui_controller_factory_;
#if defined(TOOLKIT_VIEWS)
scoped_ptr<ViewsDelegate> views_delegate_;
scoped_ptr<wm::WMState> wm_state_;
#endif

View file

@ -9,9 +9,13 @@
namespace brightray {
ViewsDelegate::ViewsDelegate() {
DCHECK(!views::ViewsDelegate::views_delegate);
views::ViewsDelegate::views_delegate = this;
}
ViewsDelegate::~ViewsDelegate() {
DCHECK_EQ(views::ViewsDelegate::views_delegate, this);
views::ViewsDelegate::views_delegate = NULL;
}
void ViewsDelegate::SaveWindowPlacement(const views::Widget* window,