Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1454)

Unified Diff: ui/views/views_delegate.cc

Issue 1159033008: Refactor ViewsDelegate singleton (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Destroy ash ViewsDelegate Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/views_delegate.h ('k') | ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/views_delegate.cc
diff --git a/ui/views/views_delegate.cc b/ui/views/views_delegate.cc
index 507b038a7b6e7547007a2a5112ae644b7171a3aa..a676ae16610dc50286b5074f65c1c815ded22f6d 100644
--- a/ui/views/views_delegate.cc
+++ b/ui/views/views_delegate.cc
@@ -12,18 +12,21 @@
#endif
namespace views {
+namespace {
-ViewsDelegate::ViewsDelegate()
- : views_tsc_factory_(new ViewsTouchEditingControllerFactory) {
- ui::TouchEditingControllerFactory::SetInstance(views_tsc_factory_.get());
+ViewsDelegate* views_delegate = nullptr;
-#if defined(USE_AURA)
- touch_selection_menu_runner_.reset(new TouchSelectionMenuRunnerViews());
-#endif
}
ViewsDelegate::~ViewsDelegate() {
- ui::TouchEditingControllerFactory::SetInstance(NULL);
+ ui::TouchEditingControllerFactory::SetInstance(nullptr);
+
+ DCHECK_EQ(this, views_delegate);
+ views_delegate = nullptr;
+}
+
+ViewsDelegate* ViewsDelegate::GetInstance() {
+ return views_delegate;
}
void ViewsDelegate::SaveWindowPlacement(const Widget* widget,
@@ -53,7 +56,7 @@ void ViewsDelegate::NotifyMenuItemFocused(const base::string16& menu_name,
#if defined(OS_WIN)
HICON ViewsDelegate::GetDefaultWindowIcon() const {
- return NULL;
+ return nullptr;
}
bool ViewsDelegate::IsWindowInMetro(gfx::NativeWindow window) const {
@@ -61,13 +64,13 @@ bool ViewsDelegate::IsWindowInMetro(gfx::NativeWindow window) const {
}
#elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
gfx::ImageSkia* ViewsDelegate::GetDefaultWindowIcon() const {
- return NULL;
+ return nullptr;
}
#endif
NonClientFrameView* ViewsDelegate::CreateDefaultNonClientFrameView(
Widget* widget) {
- return NULL;
+ return nullptr;
}
void ViewsDelegate::AddRef() {
@@ -79,7 +82,7 @@ void ViewsDelegate::ReleaseRef() {
content::WebContents* ViewsDelegate::CreateWebContents(
content::BrowserContext* browser_context,
content::SiteInstance* site_instance) {
- return NULL;
+ return nullptr;
}
base::TimeDelta ViewsDelegate::GetDefaultTextfieldObscuredRevealDuration() {
@@ -91,7 +94,7 @@ bool ViewsDelegate::WindowManagerProvidesTitleBar(bool maximized) {
}
ui::ContextFactory* ViewsDelegate::GetContextFactory() {
- return NULL;
+ return nullptr;
}
std::string ViewsDelegate::GetApplicationName() {
@@ -110,4 +113,16 @@ scoped_refptr<base::TaskRunner> ViewsDelegate::GetBlockingPoolTaskRunner() {
return nullptr;
}
+ViewsDelegate::ViewsDelegate()
+ : views_tsc_factory_(new ViewsTouchEditingControllerFactory) {
+ DCHECK(!views_delegate);
+ views_delegate = this;
+
+ ui::TouchEditingControllerFactory::SetInstance(views_tsc_factory_.get());
+
+#if defined(USE_AURA)
+ touch_selection_menu_runner_.reset(new TouchSelectionMenuRunnerViews());
+#endif
+}
+
} // namespace views
« no previous file with comments | « ui/views/views_delegate.h ('k') | ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698