OLD | NEW |
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 "chrome/browser/ui/views/omnibox/omnibox_views.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_views.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
9 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 9 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
10 #include "ui/base/ui_base_switches.h" | 10 #include "ui/base/ui_base_switches.h" |
11 | 11 |
12 #if defined(OS_WIN) && !defined(USE_AURA) | 12 #if defined(OS_WIN) && !defined(USE_AURA) |
13 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" | 13 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" |
14 #endif | 14 #endif |
15 | 15 |
| 16 bool UseOmniboxViews() { |
| 17 #if defined(OS_WIN) && !defined(USE_AURA) |
| 18 static bool kUseOmniboxViews = CommandLine::ForCurrentProcess()-> |
| 19 HasSwitch(switches::kEnableViewsTextfield); |
| 20 return kUseOmniboxViews; |
| 21 #endif |
| 22 return true; |
| 23 } |
| 24 |
| 25 OmniboxViewViews* GetOmniboxViewViews(OmniboxView* view) { |
| 26 return UseOmniboxViews() ? static_cast<OmniboxViewViews*>(view) : NULL; |
| 27 } |
| 28 |
| 29 #if defined(OS_WIN) && !defined(USE_AURA) |
| 30 OmniboxViewWin* GetOmniboxViewWin(OmniboxView* view) { |
| 31 return UseOmniboxViews() ? NULL : static_cast<OmniboxViewWin*>(view); |
| 32 } |
| 33 #endif |
| 34 |
16 OmniboxView* CreateOmniboxView(AutocompleteEditController* controller, | 35 OmniboxView* CreateOmniboxView(AutocompleteEditController* controller, |
17 ToolbarModel* toolbar_model, | 36 ToolbarModel* toolbar_model, |
18 Profile* profile, | 37 Profile* profile, |
19 CommandUpdater* command_updater, | 38 CommandUpdater* command_updater, |
20 bool popup_window_mode, | 39 bool popup_window_mode, |
21 LocationBarView* location_bar) { | 40 LocationBarView* location_bar) { |
22 #if defined(OS_WIN) && !defined(USE_AURA) | 41 #if defined(OS_WIN) && !defined(USE_AURA) |
23 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 42 if (!UseOmniboxViews()) |
24 if (!command_line->HasSwitch(switches::kEnableViewsTextfield)) | |
25 return new OmniboxViewWin(controller, toolbar_model, location_bar, | 43 return new OmniboxViewWin(controller, toolbar_model, location_bar, |
26 command_updater, popup_window_mode, location_bar); | 44 command_updater, popup_window_mode, location_bar); |
27 #endif | 45 #endif |
28 OmniboxViewViews* omnibox = new OmniboxViewViews(controller, toolbar_model, | 46 OmniboxViewViews* omnibox = new OmniboxViewViews(controller, toolbar_model, |
29 profile, command_updater, popup_window_mode, location_bar); | 47 profile, command_updater, popup_window_mode, location_bar); |
30 omnibox->Init(); | 48 omnibox->Init(); |
31 return omnibox; | 49 return omnibox; |
32 } | 50 } |
OLD | NEW |