diff options
author | saintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-29 18:08:11 +0000 |
---|---|---|
committer | saintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-29 18:08:11 +0000 |
commit | 0f9aa0321fd8e7f37e1ca940e26c0ae80cc5ca26 (patch) | |
tree | 47fb67a0ebd4b20981e697b719eee1a4d846f486 | |
parent | 7f5684c5cdf51d9f9497c56ba77f60d61dabf43b (diff) | |
download | chromium_src-0f9aa0321fd8e7f37e1ca940e26c0ae80cc5ca26.zip chromium_src-0f9aa0321fd8e7f37e1ca940e26c0ae80cc5ca26.tar.gz chromium_src-0f9aa0321fd8e7f37e1ca940e26c0ae80cc5ca26.tar.bz2 |
Removed a couple of #ifdef TOUCH_UI and replaced with Widget::IsPureViews()
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7253058
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90978 0039d316-1c4b-4281-b951-d872f2087c98
18 files changed, 26 insertions, 93 deletions
diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc index 8da9bf7..e8c5b8c 100644 --- a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc +++ b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc @@ -881,7 +881,7 @@ OmniboxView* OmniboxViewGtk::Create(AutocompleteEditController* controller, CommandUpdater* command_updater, bool popup_window_mode, views::View* location_bar) { - if (views::NativeTextfieldViews::IsTextfieldViewsEnabled()) { + if (views::Widget::IsPureViews()) { OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller, toolbar_model, profile, diff --git a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc index 945d72f..6ce7597 100644 --- a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc +++ b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc @@ -42,6 +42,7 @@ #if defined(TOOLKIT_VIEWS) #include "views/controls/textfield/native_textfield_views.h" #include "views/events/event.h" +#include "views/widget/widget.h" #endif using base::Time; @@ -154,7 +155,7 @@ class OmniboxViewTest : public InProcessBrowserTest, ASSERT_NO_FATAL_FAILURE(SetupComponents()); browser()->FocusLocationBar(); #if defined(TOOLKIT_VIEWS) - if (views::NativeTextfieldViews::IsTextfieldViewsEnabled()) + if (views::Widget::IsPureViews()) return; #endif ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), @@ -1334,7 +1335,7 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewTest, FLAKY_PasteReplacingAll) { class OmniboxViewViewsTest : public OmniboxViewTest { public: OmniboxViewViewsTest() { - views::NativeTextfieldViews::SetEnableTextfieldViews(true); + views::Widget::IsPureViews(); } }; diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc index 8fcde88..5b320bb 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc @@ -173,7 +173,7 @@ void LocationBarView::Init() { // URL edit field. // View container for URL edit field. #if defined(OS_WIN) - if (UseViewsOmnibox()) { + if (views::Widget::IsPureViews()) { OmniboxViewViews* omnibox_view = new OmniboxViewViews(this, model_, profile_, browser_->command_updater(), mode_ == POPUP, this); @@ -431,7 +431,7 @@ void LocationBarView::SetInstantSuggestion(const string16& text, GetColor(ToolbarModel::NONE, LocationBarView::DEEMPHASIZED_TEXT)); suggested_text_view_->SetText(UTF16ToWide(text)); - if (UseViewsOmnibox()) + if (views::Widget::IsPureViews()) NOTIMPLEMENTED(); else suggested_text_view_->SetFont(GetOmniboxViewWin()->GetFont()); @@ -547,7 +547,7 @@ void LocationBarView::Layout() { #if defined(OS_WIN) int max_edit_width = entry_width; - if (UseViewsOmnibox()) { + if (views::Widget::IsPureViews()) { NOTIMPLEMENTED(); } else { RECT formatting_rect; @@ -675,7 +675,7 @@ void LocationBarView::Layout() { // keyword hints and suggested text is minimal and we're not confident this // is the right approach for suggested text. if (suggested_text_view_) { - if (UseViewsOmnibox()) { + if (views::Widget::IsPureViews()) { NOTIMPLEMENTED(); } else { // TODO(sky): need to layout when the user changes caret position. @@ -801,7 +801,7 @@ void LocationBarView::OnMouseReleased(const views::MouseEvent& event) { } void LocationBarView::OnMouseCaptureLost() { - if (UseViewsOmnibox()) + if (views::Widget::IsPureViews()) NOTIMPLEMENTED(); else GetOmniboxViewWin()->HandleExternalMsg(WM_CAPTURECHANGED, 0, CPoint()); @@ -997,7 +997,7 @@ void LocationBarView::OnMouseEvent(const views::MouseEvent& event, UINT msg) { UINT flags = event.GetWindowsFlags(); gfx::Point screen_point(event.location()); ConvertPointToScreen(this, &screen_point); - if (UseViewsOmnibox()) + if (views::Widget::IsPureViews()) NOTIMPLEMENTED(); else GetOmniboxViewWin()->HandleExternalMsg(msg, flags, screen_point.ToPOINT()); @@ -1032,7 +1032,7 @@ std::string LocationBarView::GetClassName() const { bool LocationBarView::SkipDefaultKeyEventProcessing( const views::KeyEvent& event) { #if defined(OS_WIN) - bool views_omnibox = UseViewsOmnibox(); + bool views_omnibox = views::Widget::IsPureViews(); if (views::FocusManager::IsTabTraversalKeyEvent(event)) { if (HasValidSuggestText()) { // Return true so that the edit sees the tab and commits the suggestion. @@ -1256,12 +1256,7 @@ bool LocationBarView::HasValidSuggestText() const { } OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { - CHECK(!UseViewsOmnibox()); + CHECK(!views::Widget::IsPureViews()); return static_cast<OmniboxViewWin*>(location_entry_.get()); } - -bool LocationBarView::UseViewsOmnibox() { - return views::Widget::IsPureViews() || - views::NativeTextfieldViews::IsTextfieldViewsEnabled(); -} #endif diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.h b/chrome/browser/ui/views/location_bar/location_bar_view.h index d27ce7a..f3d024d 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.h +++ b/chrome/browser/ui/views/location_bar/location_bar_view.h @@ -334,10 +334,6 @@ class LocationBarView : public LocationBar, // Returns |location_entry_| cast to OmniboxViewWin, or NULL if // |location_entry_| is of a different type. OmniboxViewWin* GetOmniboxViewWin(); - - // Returns true if the views-based omnibox should be used. When false, - // |location_entry_| can be cast to OmniboxViewWin. - static bool UseViewsOmnibox(); #endif // Helper to show the first run info bubble. diff --git a/views/controls/combobox/native_combobox_gtk.cc b/views/controls/combobox/native_combobox_gtk.cc index 2706e69..baf03c4 100644 --- a/views/controls/combobox/native_combobox_gtk.cc +++ b/views/controls/combobox/native_combobox_gtk.cc @@ -14,6 +14,7 @@ #include "views/controls/combobox/combobox.h" #include "views/controls/combobox/native_combobox_views.h" #include "views/views_delegate.h" +#include "views/widget/widget.h" using ui::ComboboxModel; // TODO(beng): remove @@ -226,7 +227,7 @@ void NativeComboboxGtk::CallMenuMoveCurrent( // static NativeComboboxWrapper* NativeComboboxWrapper::CreateWrapper( Combobox* combobox) { - if (NativeComboboxViews::IsComboboxViewsEnabled()) + if (Widget::IsPureViews()) return new NativeComboboxViews(combobox); return new NativeComboboxGtk(combobox); } diff --git a/views/controls/combobox/native_combobox_views.cc b/views/controls/combobox/native_combobox_views.cc index cf34ac1..6a7b318 100644 --- a/views/controls/combobox/native_combobox_views.cc +++ b/views/controls/combobox/native_combobox_views.cc @@ -28,9 +28,6 @@ namespace { -// A global flag to switch the Combobox wrapper to NativeComboboxViews. -bool combobox_view_enabled = false; - // Define the size of the insets. const int kTopInsetSize = 4; const int kLeftInsetSize = 4; @@ -266,30 +263,12 @@ bool NativeComboboxViews::GetAccelerator(int id, views::Accelerator* accel) { return false; } -// static -bool NativeComboboxViews::IsComboboxViewsEnabled() { -#if defined(TOUCH_UI) - return true; -#else - return combobox_view_enabled || Widget::IsPureViews(); -#endif -} - -// static -void NativeComboboxViews::SetEnableComboboxViews(bool enabled) { - combobox_view_enabled = enabled; -} - ///////////////////////////////////////////////////////////////// // NativeComboboxViews private methods: const gfx::Font& NativeComboboxViews::GetFont() const { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - #if 0 // For now the width calculation is off so stick with !defined(TOUCH_UI) - return rb.GetFont(ResourceBundle::LargeFont); - #else return rb.GetFont(ResourceBundle::BaseFont); - #endif } // tip_x and tip_y are the coordinates of the tip of an arrow head which is diff --git a/views/controls/combobox/native_combobox_views.h b/views/controls/combobox/native_combobox_views.h index 114837c..f4cb56b 100644 --- a/views/controls/combobox/native_combobox_views.h +++ b/views/controls/combobox/native_combobox_views.h @@ -62,14 +62,6 @@ class NativeComboboxViews : public views::View, // class name of internal static const char kViewClassName[]; - // Returns true when - // 1) built with GYP_DEFINES="touchui=1" - // 2) enabled by SetEnableComboboxViews(true) - // 3) enabled by the command line flag "--use-pure-views") - static bool IsComboboxViewsEnabled(); - // Enable/Disable NativeComboboxViews implementation for Combobox. - static void SetEnableComboboxViews(bool enabled); - private: // Returns the Combobox's font. const gfx::Font& GetFont() const; diff --git a/views/controls/combobox/native_combobox_views_unittest.cc b/views/controls/combobox/native_combobox_views_unittest.cc index eec8c54..31aa194 100644 --- a/views/controls/combobox/native_combobox_views_unittest.cc +++ b/views/controls/combobox/native_combobox_views_unittest.cc @@ -84,11 +84,11 @@ class NativeComboboxViewsTest : public ViewsTestBase { // ::testing::Test: virtual void SetUp() { ViewsTestBase::SetUp(); - NativeComboboxViews::SetEnableComboboxViews(true); + Widget::SetPureViews(true); } virtual void TearDown() { - NativeComboboxViews::SetEnableComboboxViews(false); + Widget::SetPureViews(false); if (widget_) widget_->Close(); ViewsTestBase::TearDown(); diff --git a/views/controls/combobox/native_combobox_win.cc b/views/controls/combobox/native_combobox_win.cc index 5395347..1ccad96 100644 --- a/views/controls/combobox/native_combobox_win.cc +++ b/views/controls/combobox/native_combobox_win.cc @@ -210,7 +210,7 @@ void NativeComboboxWin::UpdateFont() { // static NativeComboboxWrapper* NativeComboboxWrapper::CreateWrapper( Combobox* combobox) { - if (NativeComboboxViews::IsComboboxViewsEnabled()) + if (Widget::IsPureViews()) return new NativeComboboxViews(combobox); return new NativeComboboxWin(combobox); } diff --git a/views/controls/native/native_view_host_gtk.cc b/views/controls/native/native_view_host_gtk.cc index 6c709f8..fbe4d3e 100644 --- a/views/controls/native/native_view_host_gtk.cc +++ b/views/controls/native/native_view_host_gtk.cc @@ -379,8 +379,7 @@ NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper( NativeViewHost* host) { if (Widget::IsPureViews()) return new NativeViewHostViews(host); - else - return new NativeViewHostGtk(host); + return new NativeViewHostGtk(host); } } // namespace views diff --git a/views/controls/textfield/native_textfield_gtk.cc b/views/controls/textfield/native_textfield_gtk.cc index 8160891..d0d05b31 100644 --- a/views/controls/textfield/native_textfield_gtk.cc +++ b/views/controls/textfield/native_textfield_gtk.cc @@ -431,9 +431,8 @@ bool NativeTextfieldGtk::IsPassword() { // static NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( Textfield* field) { - if (NativeTextfieldViews::IsTextfieldViewsEnabled()) { + if (Widget::IsPureViews()) return new NativeTextfieldViews(field); - } return new NativeTextfieldGtk(field); } diff --git a/views/controls/textfield/native_textfield_views.cc b/views/controls/textfield/native_textfield_views.cc index 31c7e4d..2a6a4c6 100644 --- a/views/controls/textfield/native_textfield_views.cc +++ b/views/controls/textfield/native_textfield_views.cc @@ -37,9 +37,6 @@ namespace { -// A global flag to switch the Textfield wrapper to TextfieldViews. -bool textfield_view_enabled = false; - // Color settings for text, backgrounds and cursor. // These are tentative, and should be derived from theme, system // settings and current settings. @@ -554,25 +551,10 @@ void NativeTextfieldViews::ClearAllTextStyles() { SchedulePaint(); } -// static -bool NativeTextfieldViews::IsTextfieldViewsEnabled() { -#if defined(TOUCH_UI) - return true; -#else - return textfield_view_enabled || Widget::IsPureViews(); -#endif -} - -// static -void NativeTextfieldViews::SetEnableTextfieldViews(bool enabled) { - textfield_view_enabled = enabled; -} - void NativeTextfieldViews::OnBoundsChanged(const gfx::Rect& previous_bounds) { UpdateCursorBoundsAndTextOffset(model_->cursor_pos(), insert_); } - /////////////////////////////////////////////////////////////////////////////// // NativeTextfieldViews, TextInputClient implementation, private: diff --git a/views/controls/textfield/native_textfield_views.h b/views/controls/textfield/native_textfield_views.h index d425472..4851549 100644 --- a/views/controls/textfield/native_textfield_views.h +++ b/views/controls/textfield/native_textfield_views.h @@ -131,14 +131,6 @@ class NativeTextfieldViews : public View, // class name of internal static const char kViewClassName[]; - // Returns true when - // 1) built with GYP_DEFINES="touchui=1" - // 2) enabled by SetEnableTextfieldViews(true) - // 3) enabled by the command line flag "--enable-textfield-view". - static bool IsTextfieldViewsEnabled(); - // Enable/Disable TextfieldViews implementation for Textfield. - static void SetEnableTextfieldViews(bool enabled); - protected: // View override. virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; diff --git a/views/controls/textfield/native_textfield_views_unittest.cc b/views/controls/textfield/native_textfield_views_unittest.cc index 30a8d08..1b499ff 100644 --- a/views/controls/textfield/native_textfield_views_unittest.cc +++ b/views/controls/textfield/native_textfield_views_unittest.cc @@ -117,11 +117,11 @@ class NativeTextfieldViewsTest : public ViewsTestBase, // ::testing::Test: virtual void SetUp() { - NativeTextfieldViews::SetEnableTextfieldViews(true); + Widget::SetPureViews(true); } virtual void TearDown() { - NativeTextfieldViews::SetEnableTextfieldViews(false); + Widget::SetPureViews(false); if (widget_) widget_->Close(); ViewsTestBase::TearDown(); diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc index df352b7..5b4bad5 100644 --- a/views/controls/textfield/native_textfield_win.cc +++ b/views/controls/textfield/native_textfield_win.cc @@ -1156,11 +1156,9 @@ void NativeTextfieldWin::BuildContextMenu() { // static NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( Textfield* field) { - if (NativeTextfieldViews::IsTextfieldViewsEnabled()) { + if (views::Widget::IsPureViews()) return new NativeTextfieldViews(field); - } else { - return new NativeTextfieldWin(field); - } + return new NativeTextfieldWin(field); } } // namespace views diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc index 6f2edd5..9cd6185 100644 --- a/views/controls/textfield/textfield.cc +++ b/views/controls/textfield/textfield.cc @@ -404,7 +404,7 @@ void Textfield::ViewHierarchyChanged(bool is_add, View* parent, View* child) { UpdateAllProperties(); #if defined(OS_WIN) - if (!NativeTextfieldViews::IsTextfieldViewsEnabled()) { + if (!views::Widget::IsPureViews()) { // TODO(beng): remove this once NativeTextfieldWin subclasses // NativeControlWin. This is currently called to perform post-AddChildView // initialization for the wrapper. The GTK version subclasses things diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc index 2b0b135..fddcdc1 100644 --- a/views/widget/native_widget_gtk.cc +++ b/views/widget/native_widget_gtk.cc @@ -893,7 +893,7 @@ InputMethod* NativeWidgetGtk::GetInputMethodNative() { // Create input method when it is requested by a child view. // TODO(suzhe): Always enable input method when we start to use // RenderWidgetHostViewViews in normal ChromeOS. - if (!child_ && NativeTextfieldViews::IsTextfieldViewsEnabled()) { + if (!child_ && views::Widget::IsPureViews()) { #if defined(HAVE_IBUS) input_method_.reset(InputMethodIBus::IsInputMethodIBusEnabled() ? static_cast<InputMethod*>(new InputMethodIBus(this)) : diff --git a/views/widget/native_widget_win.cc b/views/widget/native_widget_win.cc index 29b3ec6..1254b24 100644 --- a/views/widget/native_widget_win.cc +++ b/views/widget/native_widget_win.cc @@ -1219,8 +1219,7 @@ LRESULT NativeWidgetWin::OnCreate(CREATESTRUCT* create_struct) { // delegate_->OnNativeWidgetCreated() creates the focus manager for top-level // widget. Only top-level widget should have an input method. - if (delegate_->HasFocusManager() && - NativeTextfieldViews::IsTextfieldViewsEnabled()) { + if (delegate_->HasFocusManager() && views::Widget::IsPureViews()) { input_method_.reset(new InputMethodWin(this)); input_method_->Init(GetWidget()); is_input_method_win_ = true; |