| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/autocomplete/autocomplete_edit_view_views.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_views.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| 11 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 11 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 12 #include "chrome/browser/autocomplete/autocomplete_match.h" | 12 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 13 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 13 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| 14 #include "chrome/browser/command_updater.h" | 14 #include "chrome/browser/command_updater.h" |
| 15 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.
h" | 15 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.
h" |
| 16 #include "chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents
_view.h" | 16 #include "chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents
_view.h" |
| 17 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 17 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 18 #include "chrome/common/notification_service.h" | 18 #include "chrome/common/notification_service.h" |
| 19 #include "content/browser/tab_contents/tab_contents.h" | 19 #include "content/browser/tab_contents/tab_contents.h" |
| 20 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
| 21 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
| 22 #include "net/base/escape.h" | 22 #include "net/base/escape.h" |
| 23 #include "ui/base/dragdrop/drag_drop_types.h" | 23 #include "ui/base/dragdrop/drag_drop_types.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "ui/gfx/font.h" | 25 #include "ui/gfx/font.h" |
| 26 #include "views/border.h" | 26 #include "views/border.h" |
| 27 #include "views/controls/textfield/textfield.h" |
| 27 #include "views/layout/fill_layout.h" | 28 #include "views/layout/fill_layout.h" |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 // Textfield for autocomplete that intercepts events that are necessary | 32 // Textfield for autocomplete that intercepts events that are necessary |
| 32 // for AutocompleteEditViewViews. | 33 // for AutocompleteEditViewViews. |
| 33 class AutocompleteTextfield : public views::Textfield { | 34 class AutocompleteTextfield : public views::Textfield { |
| 34 public: | 35 public: |
| 35 explicit AutocompleteTextfield( | 36 explicit AutocompleteTextfield( |
| 36 AutocompleteEditViewViews* autocomplete_edit_view) | 37 AutocompleteEditViewViews* autocomplete_edit_view) |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 // AutocompleteEditViewViews, NotificationObserver implementation: | 571 // AutocompleteEditViewViews, NotificationObserver implementation: |
| 571 | 572 |
| 572 void AutocompleteEditViewViews::Observe(NotificationType type, | 573 void AutocompleteEditViewViews::Observe(NotificationType type, |
| 573 const NotificationSource& source, | 574 const NotificationSource& source, |
| 574 const NotificationDetails& details) { | 575 const NotificationDetails& details) { |
| 575 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); | 576 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); |
| 576 SetBaseColor(); | 577 SetBaseColor(); |
| 577 } | 578 } |
| 578 | 579 |
| 579 //////////////////////////////////////////////////////////////////////////////// | 580 //////////////////////////////////////////////////////////////////////////////// |
| 580 // AutocompleteEditViewViews, Textfield::Controller implementation: | 581 // AutocompleteEditViewViews, views::TextfieldController implementation: |
| 581 | 582 |
| 582 void AutocompleteEditViewViews::ContentsChanged(views::Textfield* sender, | 583 void AutocompleteEditViewViews::ContentsChanged(views::Textfield* sender, |
| 583 const string16& new_contents) { | 584 const string16& new_contents) { |
| 584 if (handling_key_press_) | 585 if (handling_key_press_) |
| 585 content_maybe_changed_by_key_press_ = true; | 586 content_maybe_changed_by_key_press_ = true; |
| 586 } | 587 } |
| 587 | 588 |
| 588 bool AutocompleteEditViewViews::HandleKeyEvent( | 589 bool AutocompleteEditViewViews::HandleKeyEvent( |
| 589 views::Textfield* textfield, | 590 views::Textfield* textfield, |
| 590 const views::KeyEvent& event) { | 591 const views::KeyEvent& event) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 AutocompletePopupView* AutocompleteEditViewViews::CreatePopupView( | 653 AutocompletePopupView* AutocompleteEditViewViews::CreatePopupView( |
| 653 Profile* profile, | 654 Profile* profile, |
| 654 const View* location_bar) { | 655 const View* location_bar) { |
| 655 #if defined(TOUCH_UI) | 656 #if defined(TOUCH_UI) |
| 656 return new TouchAutocompletePopupContentsView( | 657 return new TouchAutocompletePopupContentsView( |
| 657 #else | 658 #else |
| 658 return new AutocompletePopupContentsView( | 659 return new AutocompletePopupContentsView( |
| 659 #endif | 660 #endif |
| 660 gfx::Font(), this, model_.get(), profile, location_bar); | 661 gfx::Font(), this, model_.get(), profile, location_bar); |
| 661 } | 662 } |
| OLD | NEW |