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

Side by Side Diff: ui/base/ime/input_method_factory.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/base/ime/input_method_factory.h" 5 #include "ui/base/ime/input_method_factory.h"
6 6
7 #include "base/memory/ptr_util.h"
7 #include "build/build_config.h" 8 #include "build/build_config.h"
8 #include "ui/base/ime/mock_input_method.h" 9 #include "ui/base/ime/mock_input_method.h"
9 10
10 #if defined(OS_CHROMEOS) 11 #if defined(OS_CHROMEOS)
11 #include "ui/base/ime/input_method_chromeos.h" 12 #include "ui/base/ime/input_method_chromeos.h"
12 #elif defined(OS_WIN) 13 #elif defined(OS_WIN)
13 #include "ui/base/ime/input_method_win.h" 14 #include "ui/base/ime/input_method_win.h"
14 #elif defined(OS_MACOSX) 15 #elif defined(OS_MACOSX)
15 #include "ui/base/ime/input_method_mac.h" 16 #include "ui/base/ime/input_method_mac.h"
16 #elif defined(USE_AURA) && defined(OS_LINUX) && defined(USE_X11) && \ 17 #elif defined(USE_AURA) && defined(OS_LINUX) && defined(USE_X11) && \
(...skipping 10 matching lines...) Expand all
27 ui::InputMethod* g_input_method_for_testing = nullptr; 28 ui::InputMethod* g_input_method_for_testing = nullptr;
28 29
29 bool g_input_method_set_for_testing = false; 30 bool g_input_method_set_for_testing = false;
30 31
31 bool g_create_input_method_called = false; 32 bool g_create_input_method_called = false;
32 33
33 } // namespace 34 } // namespace
34 35
35 namespace ui { 36 namespace ui {
36 37
37 scoped_ptr<InputMethod> CreateInputMethod( 38 std::unique_ptr<InputMethod> CreateInputMethod(
38 internal::InputMethodDelegate* delegate, 39 internal::InputMethodDelegate* delegate,
39 gfx::AcceleratedWidget widget) { 40 gfx::AcceleratedWidget widget) {
40 if (!g_create_input_method_called) 41 if (!g_create_input_method_called)
41 g_create_input_method_called = true; 42 g_create_input_method_called = true;
42 43
43 if (g_input_method_for_testing) { 44 if (g_input_method_for_testing) {
44 ui::InputMethod* ret = g_input_method_for_testing; 45 ui::InputMethod* ret = g_input_method_for_testing;
45 g_input_method_for_testing = nullptr; 46 g_input_method_for_testing = nullptr;
46 return make_scoped_ptr(ret); 47 return base::WrapUnique(ret);
47 } 48 }
48 49
49 if (g_input_method_set_for_testing) 50 if (g_input_method_set_for_testing)
50 return make_scoped_ptr(new MockInputMethod(delegate)); 51 return base::WrapUnique(new MockInputMethod(delegate));
51 52
52 #if defined(OS_CHROMEOS) 53 #if defined(OS_CHROMEOS)
53 return make_scoped_ptr(new InputMethodChromeOS(delegate)); 54 return base::WrapUnique(new InputMethodChromeOS(delegate));
54 #elif defined(OS_WIN) 55 #elif defined(OS_WIN)
55 return make_scoped_ptr(new InputMethodWin(delegate, widget)); 56 return base::WrapUnique(new InputMethodWin(delegate, widget));
56 #elif defined(OS_MACOSX) 57 #elif defined(OS_MACOSX)
57 return make_scoped_ptr(new InputMethodMac(delegate)); 58 return base::WrapUnique(new InputMethodMac(delegate));
58 #elif defined(USE_AURA) && defined(OS_LINUX) && defined(USE_X11) && \ 59 #elif defined(USE_AURA) && defined(OS_LINUX) && defined(USE_X11) && \
59 !defined(OS_CHROMEOS) 60 !defined(OS_CHROMEOS)
60 return make_scoped_ptr(new InputMethodAuraLinux(delegate)); 61 return base::WrapUnique(new InputMethodAuraLinux(delegate));
61 #elif defined(OS_ANDROID) 62 #elif defined(OS_ANDROID)
62 return make_scoped_ptr(new InputMethodAndroid(delegate)); 63 return base::WrapUnique(new InputMethodAndroid(delegate));
63 #else 64 #else
64 return make_scoped_ptr(new InputMethodMinimal(delegate)); 65 return base::WrapUnique(new InputMethodMinimal(delegate));
65 #endif 66 #endif
66 } 67 }
67 68
68 void SetUpInputMethodFactoryForTesting() { 69 void SetUpInputMethodFactoryForTesting() {
69 if (g_input_method_set_for_testing) 70 if (g_input_method_set_for_testing)
70 return; 71 return;
71 72
72 CHECK(!g_create_input_method_called) 73 CHECK(!g_create_input_method_called)
73 << "ui::SetUpInputMethodFactoryForTesting was called after use of " 74 << "ui::SetUpInputMethodFactoryForTesting was called after use of "
74 << "ui::CreateInputMethod. You must call " 75 << "ui::CreateInputMethod. You must call "
75 << "ui::SetUpInputMethodFactoryForTesting earlier."; 76 << "ui::SetUpInputMethodFactoryForTesting earlier.";
76 77
77 g_input_method_set_for_testing = true; 78 g_input_method_set_for_testing = true;
78 } 79 }
79 80
80 void SetUpInputMethodForTesting(InputMethod* input_method) { 81 void SetUpInputMethodForTesting(InputMethod* input_method) {
81 g_input_method_for_testing = input_method; 82 g_input_method_for_testing = input_method;
82 } 83 }
83 84
84 } // namespace ui 85 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_factory.h ('k') | ui/base/ime/linux/fake_input_method_context_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698