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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 // static | 93 // static |
94 const char OmniboxViewViews::kViewClassName[] = "OmniboxViewViews"; | 94 const char OmniboxViewViews::kViewClassName[] = "OmniboxViewViews"; |
95 | 95 |
96 OmniboxViewViews::OmniboxViewViews(OmniboxEditController* controller, | 96 OmniboxViewViews::OmniboxViewViews(OmniboxEditController* controller, |
97 ToolbarModel* toolbar_model, | 97 ToolbarModel* toolbar_model, |
98 Profile* profile, | 98 Profile* profile, |
99 CommandUpdater* command_updater, | 99 CommandUpdater* command_updater, |
100 bool popup_window_mode, | 100 bool popup_window_mode, |
101 LocationBarView* location_bar, | 101 LocationBarView* location_bar, |
102 const gfx::Font& font, | 102 const gfx::FontList& font_list, |
103 int font_y_offset) | 103 int font_y_offset) |
104 : OmniboxView(profile, controller, toolbar_model, command_updater), | 104 : OmniboxView(profile, controller, toolbar_model, command_updater), |
105 popup_window_mode_(popup_window_mode), | 105 popup_window_mode_(popup_window_mode), |
106 security_level_(ToolbarModel::NONE), | 106 security_level_(ToolbarModel::NONE), |
107 ime_composing_before_change_(false), | 107 ime_composing_before_change_(false), |
108 delete_at_end_pressed_(false), | 108 delete_at_end_pressed_(false), |
109 location_bar_view_(location_bar), | 109 location_bar_view_(location_bar), |
110 ime_candidate_window_open_(false), | 110 ime_candidate_window_open_(false), |
111 select_all_on_mouse_release_(false), | 111 select_all_on_mouse_release_(false), |
112 select_all_on_gesture_tap_(false) { | 112 select_all_on_gesture_tap_(false) { |
113 RemoveBorder(); | 113 RemoveBorder(); |
114 set_id(VIEW_ID_OMNIBOX); | 114 set_id(VIEW_ID_OMNIBOX); |
115 SetFont(font); | 115 SetFontList(font_list); |
116 SetVerticalMargins(font_y_offset, 0); | 116 SetVerticalMargins(font_y_offset, 0); |
117 SetVerticalAlignment(gfx::ALIGN_TOP); | 117 SetVerticalAlignment(gfx::ALIGN_TOP); |
118 } | 118 } |
119 | 119 |
120 OmniboxViewViews::~OmniboxViewViews() { | 120 OmniboxViewViews::~OmniboxViewViews() { |
121 #if defined(OS_CHROMEOS) | 121 #if defined(OS_CHROMEOS) |
122 chromeos::input_method::InputMethodManager::Get()-> | 122 chromeos::input_method::InputMethodManager::Get()-> |
123 RemoveCandidateWindowObserver(this); | 123 RemoveCandidateWindowObserver(this); |
124 #endif | 124 #endif |
125 | 125 |
126 // Explicitly teardown members which have a reference to us. Just to be safe | 126 // Explicitly teardown members which have a reference to us. Just to be safe |
127 // we want them to be destroyed before destroying any other internal state. | 127 // we want them to be destroyed before destroying any other internal state. |
128 popup_view_.reset(); | 128 popup_view_.reset(); |
129 } | 129 } |
130 | 130 |
131 //////////////////////////////////////////////////////////////////////////////// | 131 //////////////////////////////////////////////////////////////////////////////// |
132 // OmniboxViewViews public: | 132 // OmniboxViewViews public: |
133 | 133 |
134 void OmniboxViewViews::Init() { | 134 void OmniboxViewViews::Init() { |
135 SetController(this); | 135 SetController(this); |
136 SetTextInputType(ui::TEXT_INPUT_TYPE_URL); | 136 SetTextInputType(ui::TEXT_INPUT_TYPE_URL); |
137 SetBackgroundColor(location_bar_view_->GetColor( | 137 SetBackgroundColor(location_bar_view_->GetColor( |
138 ToolbarModel::NONE, LocationBarView::BACKGROUND)); | 138 ToolbarModel::NONE, LocationBarView::BACKGROUND)); |
139 | 139 |
140 if (popup_window_mode_) | 140 if (popup_window_mode_) |
141 SetReadOnly(true); | 141 SetReadOnly(true); |
142 | 142 |
143 // Initialize the popup view using the same font. | 143 // Initialize the popup view using the same font. |
144 popup_view_.reset(OmniboxPopupContentsView::Create( | 144 popup_view_.reset(OmniboxPopupContentsView::Create( |
145 font(), this, model(), location_bar_view_)); | 145 font_list(), this, model(), location_bar_view_)); |
146 | 146 |
147 #if defined(OS_CHROMEOS) | 147 #if defined(OS_CHROMEOS) |
148 chromeos::input_method::InputMethodManager::Get()-> | 148 chromeos::input_method::InputMethodManager::Get()-> |
149 AddCandidateWindowObserver(this); | 149 AddCandidateWindowObserver(this); |
150 #endif | 150 #endif |
151 } | 151 } |
152 | 152 |
153 //////////////////////////////////////////////////////////////////////////////// | 153 //////////////////////////////////////////////////////////////////////////////// |
154 // OmniboxViewViews, views::Textfield implementation: | 154 // OmniboxViewViews, views::Textfield implementation: |
155 | 155 |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 const string16 text(GetClipboardText()); | 908 const string16 text(GetClipboardText()); |
909 if (!text.empty()) { | 909 if (!text.empty()) { |
910 // Record this paste, so we can do different behavior. | 910 // Record this paste, so we can do different behavior. |
911 model()->on_paste(); | 911 model()->on_paste(); |
912 // Force a Paste operation to trigger the text_changed code in | 912 // Force a Paste operation to trigger the text_changed code in |
913 // OnAfterPossibleChange(), even if identical contents are pasted. | 913 // OnAfterPossibleChange(), even if identical contents are pasted. |
914 text_before_change_.clear(); | 914 text_before_change_.clear(); |
915 InsertOrReplaceText(text); | 915 InsertOrReplaceText(text); |
916 } | 916 } |
917 } | 917 } |
OLD | NEW |