OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/views_delegate.h" | 5 #include "ui/views/views_delegate.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "ui/views/views_touch_selection_controller_factory.h" | 8 #include "ui/views/views_touch_selection_controller_factory.h" |
9 | 9 |
10 #if defined(USE_AURA) | 10 #if defined(USE_AURA) |
11 #include "ui/views/touchui/touch_selection_menu_runner_views.h" | 11 #include "ui/views/touchui/touch_selection_menu_runner_views.h" |
12 #endif | 12 #endif |
13 | 13 |
14 namespace views { | 14 namespace views { |
| 15 namespace { |
15 | 16 |
16 ViewsDelegate::ViewsDelegate() | 17 ViewsDelegate* g_views_delegate = nullptr; |
17 : views_tsc_factory_(new ViewsTouchEditingControllerFactory) { | |
18 ui::TouchEditingControllerFactory::SetInstance(views_tsc_factory_.get()); | |
19 | 18 |
20 #if defined(USE_AURA) | |
21 touch_selection_menu_runner_.reset(new TouchSelectionMenuRunnerViews()); | |
22 #endif | |
23 } | 19 } |
24 | 20 |
25 ViewsDelegate::~ViewsDelegate() { | 21 ViewsDelegate::~ViewsDelegate() { |
26 ui::TouchEditingControllerFactory::SetInstance(NULL); | 22 ui::TouchEditingControllerFactory::SetInstance(nullptr); |
| 23 |
| 24 DCHECK_EQ(this, g_views_delegate); |
| 25 g_views_delegate = nullptr; |
| 26 } |
| 27 |
| 28 ViewsDelegate* ViewsDelegate::GetInstance() { |
| 29 return g_views_delegate; |
27 } | 30 } |
28 | 31 |
29 void ViewsDelegate::SaveWindowPlacement(const Widget* widget, | 32 void ViewsDelegate::SaveWindowPlacement(const Widget* widget, |
30 const std::string& window_name, | 33 const std::string& window_name, |
31 const gfx::Rect& bounds, | 34 const gfx::Rect& bounds, |
32 ui::WindowShowState show_state) { | 35 ui::WindowShowState show_state) { |
33 } | 36 } |
34 | 37 |
35 bool ViewsDelegate::GetSavedWindowPlacement( | 38 bool ViewsDelegate::GetSavedWindowPlacement( |
36 const Widget* widget, | 39 const Widget* widget, |
37 const std::string& window_name, | 40 const std::string& window_name, |
38 gfx::Rect* bounds, | 41 gfx::Rect* bounds, |
39 ui::WindowShowState* show_state) const { | 42 ui::WindowShowState* show_state) const { |
40 return false; | 43 return false; |
41 } | 44 } |
42 | 45 |
43 void ViewsDelegate::NotifyAccessibilityEvent(View* view, | 46 void ViewsDelegate::NotifyAccessibilityEvent(View* view, |
44 ui::AXEvent event_type) { | 47 ui::AXEvent event_type) { |
45 } | 48 } |
46 | 49 |
47 void ViewsDelegate::NotifyMenuItemFocused(const base::string16& menu_name, | 50 void ViewsDelegate::NotifyMenuItemFocused(const base::string16& menu_name, |
48 const base::string16& menu_item_name, | 51 const base::string16& menu_item_name, |
49 int item_index, | 52 int item_index, |
50 int item_count, | 53 int item_count, |
51 bool has_submenu) { | 54 bool has_submenu) { |
52 } | 55 } |
53 | 56 |
54 #if defined(OS_WIN) | 57 #if defined(OS_WIN) |
55 HICON ViewsDelegate::GetDefaultWindowIcon() const { | 58 HICON ViewsDelegate::GetDefaultWindowIcon() const { |
56 return NULL; | 59 return nullptr; |
57 } | 60 } |
58 | 61 |
59 bool ViewsDelegate::IsWindowInMetro(gfx::NativeWindow window) const { | 62 bool ViewsDelegate::IsWindowInMetro(gfx::NativeWindow window) const { |
60 return false; | 63 return false; |
61 } | 64 } |
62 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) | 65 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) |
63 gfx::ImageSkia* ViewsDelegate::GetDefaultWindowIcon() const { | 66 gfx::ImageSkia* ViewsDelegate::GetDefaultWindowIcon() const { |
64 return NULL; | 67 return nullptr; |
65 } | 68 } |
66 #endif | 69 #endif |
67 | 70 |
68 NonClientFrameView* ViewsDelegate::CreateDefaultNonClientFrameView( | 71 NonClientFrameView* ViewsDelegate::CreateDefaultNonClientFrameView( |
69 Widget* widget) { | 72 Widget* widget) { |
70 return NULL; | 73 return nullptr; |
71 } | 74 } |
72 | 75 |
73 void ViewsDelegate::AddRef() { | 76 void ViewsDelegate::AddRef() { |
74 } | 77 } |
75 | 78 |
76 void ViewsDelegate::ReleaseRef() { | 79 void ViewsDelegate::ReleaseRef() { |
77 } | 80 } |
78 | 81 |
79 content::WebContents* ViewsDelegate::CreateWebContents( | 82 content::WebContents* ViewsDelegate::CreateWebContents( |
80 content::BrowserContext* browser_context, | 83 content::BrowserContext* browser_context, |
81 content::SiteInstance* site_instance) { | 84 content::SiteInstance* site_instance) { |
82 return NULL; | 85 return nullptr; |
83 } | 86 } |
84 | 87 |
85 base::TimeDelta ViewsDelegate::GetDefaultTextfieldObscuredRevealDuration() { | 88 base::TimeDelta ViewsDelegate::GetDefaultTextfieldObscuredRevealDuration() { |
86 return base::TimeDelta(); | 89 return base::TimeDelta(); |
87 } | 90 } |
88 | 91 |
89 bool ViewsDelegate::WindowManagerProvidesTitleBar(bool maximized) { | 92 bool ViewsDelegate::WindowManagerProvidesTitleBar(bool maximized) { |
90 return false; | 93 return false; |
91 } | 94 } |
92 | 95 |
93 ui::ContextFactory* ViewsDelegate::GetContextFactory() { | 96 ui::ContextFactory* ViewsDelegate::GetContextFactory() { |
94 return NULL; | 97 return nullptr; |
95 } | 98 } |
96 | 99 |
97 std::string ViewsDelegate::GetApplicationName() { | 100 std::string ViewsDelegate::GetApplicationName() { |
98 base::FilePath program = base::CommandLine::ForCurrentProcess()->GetProgram(); | 101 base::FilePath program = base::CommandLine::ForCurrentProcess()->GetProgram(); |
99 return program.BaseName().AsUTF8Unsafe(); | 102 return program.BaseName().AsUTF8Unsafe(); |
100 } | 103 } |
101 | 104 |
102 #if defined(OS_WIN) | 105 #if defined(OS_WIN) |
103 int ViewsDelegate::GetAppbarAutohideEdges(HMONITOR monitor, | 106 int ViewsDelegate::GetAppbarAutohideEdges(HMONITOR monitor, |
104 const base::Closure& callback) { | 107 const base::Closure& callback) { |
105 return EDGE_BOTTOM; | 108 return EDGE_BOTTOM; |
106 } | 109 } |
107 #endif | 110 #endif |
108 | 111 |
109 scoped_refptr<base::TaskRunner> ViewsDelegate::GetBlockingPoolTaskRunner() { | 112 scoped_refptr<base::TaskRunner> ViewsDelegate::GetBlockingPoolTaskRunner() { |
110 return nullptr; | 113 return nullptr; |
111 } | 114 } |
112 | 115 |
| 116 ViewsDelegate::ViewsDelegate() |
| 117 : views_tsc_factory_(new ViewsTouchEditingControllerFactory) { |
| 118 DCHECK(!g_views_delegate); |
| 119 g_views_delegate = this; |
| 120 |
| 121 ui::TouchEditingControllerFactory::SetInstance(views_tsc_factory_.get()); |
| 122 |
| 123 #if defined(USE_AURA) |
| 124 touch_selection_menu_runner_.reset(new TouchSelectionMenuRunnerViews()); |
| 125 #endif |
| 126 } |
| 127 |
113 } // namespace views | 128 } // namespace views |
OLD | NEW |