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_view_views.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 32 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
33 #include "ui/base/dragdrop/drag_drop_types.h" | 33 #include "ui/base/dragdrop/drag_drop_types.h" |
34 #include "ui/base/dragdrop/os_exchange_data.h" | 34 #include "ui/base/dragdrop/os_exchange_data.h" |
35 #include "ui/base/events/event.h" | 35 #include "ui/base/events/event.h" |
36 #include "ui/base/ime/text_input_client.h" | 36 #include "ui/base/ime/text_input_client.h" |
37 #include "ui/base/ime/text_input_type.h" | 37 #include "ui/base/ime/text_input_type.h" |
38 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
39 #include "ui/base/models/simple_menu_model.h" | 39 #include "ui/base/models/simple_menu_model.h" |
40 #include "ui/base/resource/resource_bundle.h" | 40 #include "ui/base/resource/resource_bundle.h" |
41 #include "ui/gfx/canvas.h" | 41 #include "ui/gfx/canvas.h" |
42 #include "ui/gfx/font.h" | 42 #include "ui/gfx/font_list.h" |
43 #include "ui/gfx/selection_model.h" | 43 #include "ui/gfx/selection_model.h" |
44 #include "ui/views/border.h" | 44 #include "ui/views/border.h" |
45 #include "ui/views/button_drag_utils.h" | 45 #include "ui/views/button_drag_utils.h" |
46 #include "ui/views/controls/textfield/textfield.h" | 46 #include "ui/views/controls/textfield/textfield.h" |
47 #include "ui/views/ime/input_method.h" | 47 #include "ui/views/ime/input_method.h" |
48 #include "ui/views/layout/fill_layout.h" | 48 #include "ui/views/layout/fill_layout.h" |
49 #include "ui/views/views_delegate.h" | 49 #include "ui/views/views_delegate.h" |
50 #include "ui/views/widget/widget.h" | 50 #include "ui/views/widget/widget.h" |
51 #include "url/gurl.h" | 51 #include "url/gurl.h" |
52 | 52 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 // static | 98 // static |
99 const char OmniboxViewViews::kViewClassName[] = "OmniboxViewViews"; | 99 const char OmniboxViewViews::kViewClassName[] = "OmniboxViewViews"; |
100 | 100 |
101 OmniboxViewViews::OmniboxViewViews(OmniboxEditController* controller, | 101 OmniboxViewViews::OmniboxViewViews(OmniboxEditController* controller, |
102 ToolbarModel* toolbar_model, | 102 ToolbarModel* toolbar_model, |
103 Profile* profile, | 103 Profile* profile, |
104 CommandUpdater* command_updater, | 104 CommandUpdater* command_updater, |
105 bool popup_window_mode, | 105 bool popup_window_mode, |
106 LocationBarView* location_bar, | 106 LocationBarView* location_bar, |
107 const gfx::Font& font, | 107 const gfx::FontList& font_list, |
108 int font_y_offset) | 108 int font_y_offset) |
109 : OmniboxView(profile, controller, toolbar_model, command_updater), | 109 : OmniboxView(profile, controller, toolbar_model, command_updater), |
110 popup_window_mode_(popup_window_mode), | 110 popup_window_mode_(popup_window_mode), |
111 security_level_(ToolbarModel::NONE), | 111 security_level_(ToolbarModel::NONE), |
112 ime_composing_before_change_(false), | 112 ime_composing_before_change_(false), |
113 delete_at_end_pressed_(false), | 113 delete_at_end_pressed_(false), |
114 location_bar_view_(location_bar), | 114 location_bar_view_(location_bar), |
115 ime_candidate_window_open_(false), | 115 ime_candidate_window_open_(false), |
116 select_all_on_mouse_release_(false), | 116 select_all_on_mouse_release_(false), |
117 select_all_on_gesture_tap_(false) { | 117 select_all_on_gesture_tap_(false) { |
118 RemoveBorder(); | 118 RemoveBorder(); |
119 set_id(VIEW_ID_OMNIBOX); | 119 set_id(VIEW_ID_OMNIBOX); |
120 SetFont(font); | 120 SetFontList(font_list); |
121 SetVerticalMargins(font_y_offset, 0); | 121 SetVerticalMargins(font_y_offset, 0); |
122 SetVerticalAlignment(gfx::ALIGN_TOP); | 122 SetVerticalAlignment(gfx::ALIGN_TOP); |
123 } | 123 } |
124 | 124 |
125 OmniboxViewViews::~OmniboxViewViews() { | 125 OmniboxViewViews::~OmniboxViewViews() { |
126 #if defined(OS_CHROMEOS) | 126 #if defined(OS_CHROMEOS) |
127 chromeos::input_method::InputMethodManager::Get()-> | 127 chromeos::input_method::InputMethodManager::Get()-> |
128 RemoveCandidateWindowObserver(this); | 128 RemoveCandidateWindowObserver(this); |
129 #endif | 129 #endif |
130 | 130 |
131 // Explicitly teardown members which have a reference to us. Just to be safe | 131 // Explicitly teardown members which have a reference to us. Just to be safe |
132 // we want them to be destroyed before destroying any other internal state. | 132 // we want them to be destroyed before destroying any other internal state. |
133 popup_view_.reset(); | 133 popup_view_.reset(); |
134 } | 134 } |
135 | 135 |
136 //////////////////////////////////////////////////////////////////////////////// | 136 //////////////////////////////////////////////////////////////////////////////// |
137 // OmniboxViewViews public: | 137 // OmniboxViewViews public: |
138 | 138 |
139 void OmniboxViewViews::Init() { | 139 void OmniboxViewViews::Init() { |
140 SetController(this); | 140 SetController(this); |
141 SetTextInputType(ui::TEXT_INPUT_TYPE_URL); | 141 SetTextInputType(ui::TEXT_INPUT_TYPE_URL); |
142 SetBackgroundColor(location_bar_view_->GetColor( | 142 SetBackgroundColor(location_bar_view_->GetColor( |
143 ToolbarModel::NONE, LocationBarView::BACKGROUND)); | 143 ToolbarModel::NONE, LocationBarView::BACKGROUND)); |
144 | 144 |
145 if (popup_window_mode_) | 145 if (popup_window_mode_) |
146 SetReadOnly(true); | 146 SetReadOnly(true); |
147 | 147 |
148 // Initialize the popup view using the same font. | 148 // Initialize the popup view using the same font. |
149 popup_view_.reset(OmniboxPopupContentsView::Create( | 149 popup_view_.reset(OmniboxPopupContentsView::Create( |
150 font(), this, model(), location_bar_view_)); | 150 font_list(), this, model(), location_bar_view_)); |
151 | 151 |
152 #if defined(OS_CHROMEOS) | 152 #if defined(OS_CHROMEOS) |
153 chromeos::input_method::InputMethodManager::Get()-> | 153 chromeos::input_method::InputMethodManager::Get()-> |
154 AddCandidateWindowObserver(this); | 154 AddCandidateWindowObserver(this); |
155 #endif | 155 #endif |
156 } | 156 } |
157 | 157 |
158 //////////////////////////////////////////////////////////////////////////////// | 158 //////////////////////////////////////////////////////////////////////////////// |
159 // OmniboxViewViews, views::Textfield implementation: | 159 // OmniboxViewViews, views::Textfield implementation: |
160 | 160 |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 const string16 text(GetClipboardText()); | 904 const string16 text(GetClipboardText()); |
905 if (!text.empty()) { | 905 if (!text.empty()) { |
906 // Record this paste, so we can do different behavior. | 906 // Record this paste, so we can do different behavior. |
907 model()->on_paste(); | 907 model()->on_paste(); |
908 // Force a Paste operation to trigger the text_changed code in | 908 // Force a Paste operation to trigger the text_changed code in |
909 // OnAfterPossibleChange(), even if identical contents are pasted. | 909 // OnAfterPossibleChange(), even if identical contents are pasted. |
910 text_before_change_.clear(); | 910 text_before_change_.clear(); |
911 InsertOrReplaceText(text); | 911 InsertOrReplaceText(text); |
912 } | 912 } |
913 } | 913 } |
OLD | NEW |