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/tab_contents/tab_contents.h" | 15 #include "chrome/browser/tab_contents/tab_contents.h" |
16 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view. h" | 16 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view. h" |
17 #include "chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents _view.h" | |
17 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 18 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
18 #include "chrome/common/notification_service.h" | 19 #include "chrome/common/notification_service.h" |
19 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
20 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
21 #include "net/base/escape.h" | 22 #include "net/base/escape.h" |
22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
23 #include "ui/gfx/font.h" | 24 #include "ui/gfx/font.h" |
24 #include "views/border.h" | 25 #include "views/border.h" |
25 #include "views/layout/fill_layout.h" | 26 #include "views/layout/fill_layout.h" |
26 | 27 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 } // namespace | 104 } // namespace |
104 | 105 |
105 AutocompleteEditViewViews::AutocompleteEditViewViews( | 106 AutocompleteEditViewViews::AutocompleteEditViewViews( |
106 AutocompleteEditController* controller, | 107 AutocompleteEditController* controller, |
107 ToolbarModel* toolbar_model, | 108 ToolbarModel* toolbar_model, |
108 Profile* profile, | 109 Profile* profile, |
109 CommandUpdater* command_updater, | 110 CommandUpdater* command_updater, |
110 bool popup_window_mode, | 111 bool popup_window_mode, |
111 const views::View* location_bar) | 112 const views::View* location_bar) |
112 : model_(new AutocompleteEditModel(this, controller, profile)), | 113 : model_(new AutocompleteEditModel(this, controller, profile)), |
113 popup_view_(new AutocompletePopupContentsView( | 114 popup_view_(CreatePopupView(profile, location_bar)), |
114 gfx::Font(), this, model_.get(), profile, location_bar)), | |
115 controller_(controller), | 115 controller_(controller), |
116 toolbar_model_(toolbar_model), | 116 toolbar_model_(toolbar_model), |
117 command_updater_(command_updater), | 117 command_updater_(command_updater), |
118 popup_window_mode_(popup_window_mode), | 118 popup_window_mode_(popup_window_mode), |
119 security_level_(ToolbarModel::NONE), | 119 security_level_(ToolbarModel::NONE), |
120 delete_was_pressed_(false), | 120 delete_was_pressed_(false), |
121 delete_at_end_pressed_(false) { | 121 delete_at_end_pressed_(false) { |
122 set_border(views::Border::CreateEmptyBorder(kAutocompleteVerticalMargin, 0, | 122 set_border(views::Border::CreateEmptyBorder(kAutocompleteVerticalMargin, 0, |
123 kAutocompleteVerticalMargin, 0)); | 123 kAutocompleteVerticalMargin, 0)); |
124 } | 124 } |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
634 | 634 |
635 string16 AutocompleteEditViewViews::GetSelectedText() const { | 635 string16 AutocompleteEditViewViews::GetSelectedText() const { |
636 // TODO(oshima): Support instant, IME. | 636 // TODO(oshima): Support instant, IME. |
637 return textfield_->GetSelectedText(); | 637 return textfield_->GetSelectedText(); |
638 } | 638 } |
639 | 639 |
640 void AutocompleteEditViewViews::SelectRange(size_t caret, size_t end) { | 640 void AutocompleteEditViewViews::SelectRange(size_t caret, size_t end) { |
641 const views::TextRange range(caret, end); | 641 const views::TextRange range(caret, end); |
642 textfield_->SelectRange(range); | 642 textfield_->SelectRange(range); |
643 } | 643 } |
644 | |
645 AutocompletePopupView* AutocompleteEditViewViews::CreatePopupView( | |
646 Profile* profile, const views::View* location_bar) { | |
Peter Kasting
2011/02/17 23:08:57
Nit: One arg per line
varunjain
2011/02/18 00:16:34
Done.
| |
647 #if defined(TOUCH_UI) | |
648 return new TouchAutocompletePopupContentsView( | |
649 gfx::Font(), this, model_.get(), profile, location_bar); | |
Peter Kasting
2011/02/17 23:08:57
Nit: Why not bring this second line out of the #if
varunjain
2011/02/18 00:16:34
It looked better to me that way... but anyways. Do
| |
650 #else | |
651 return new AutocompletePopupContentsView( | |
652 gfx::Font(), this, model_.get(), profile, location_bar); | |
653 #endif | |
654 } | |
OLD | NEW |