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