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 <set> | 7 #include <set> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 EmphasizeURLComponents(); | 264 EmphasizeURLComponents(); |
265 } | 265 } |
266 } | 266 } |
267 | 267 |
268 base::string16 OmniboxViewViews::GetText() const { | 268 base::string16 OmniboxViewViews::GetText() const { |
269 // TODO(oshima): IME support | 269 // TODO(oshima): IME support |
270 return text(); | 270 return text(); |
271 } | 271 } |
272 | 272 |
273 void OmniboxViewViews::SetUserText(const base::string16& text, | 273 void OmniboxViewViews::SetUserText(const base::string16& text, |
274 const base::string16& display_text, | |
275 bool update_popup) { | 274 bool update_popup) { |
276 saved_selection_for_focus_change_ = gfx::Range::InvalidRange(); | 275 saved_selection_for_focus_change_ = gfx::Range::InvalidRange(); |
277 OmniboxView::SetUserText(text, display_text, update_popup); | 276 OmniboxView::SetUserText(text, update_popup); |
278 } | 277 } |
279 | 278 |
280 void OmniboxViewViews::SetForcedQuery() { | 279 void OmniboxViewViews::SetForcedQuery() { |
281 const base::string16 current_text(text()); | 280 const base::string16 current_text(text()); |
282 const size_t start = current_text.find_first_not_of(base::kWhitespaceUTF16); | 281 const size_t start = current_text.find_first_not_of(base::kWhitespaceUTF16); |
283 if (start == base::string16::npos || (current_text[start] != '?')) | 282 if (start == base::string16::npos || (current_text[start] != '?')) |
284 OmniboxView::SetUserText(base::ASCIIToUTF16("?")); | 283 OmniboxView::SetUserText(base::ASCIIToUTF16("?")); |
285 else | 284 else |
286 SelectRange(gfx::Range(current_text.size(), start + 1)); | 285 SelectRange(gfx::Range(current_text.size(), start + 1)); |
287 } | 286 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 (model()->popup_model()->selected_line_state() == | 427 (model()->popup_model()->selected_line_state() == |
429 OmniboxPopupModel::KEYWORD)) | 428 OmniboxPopupModel::KEYWORD)) |
430 model()->ClearKeyword(); | 429 model()->ClearKeyword(); |
431 else | 430 else |
432 model()->OnUpOrDownKeyPressed(event.IsShiftDown() ? -1 : 1); | 431 model()->OnUpOrDownKeyPressed(event.IsShiftDown() ? -1 : 1); |
433 | 432 |
434 return true; | 433 return true; |
435 } | 434 } |
436 | 435 |
437 void OmniboxViewViews::AccessibilitySetValue(const base::string16& new_value) { | 436 void OmniboxViewViews::AccessibilitySetValue(const base::string16& new_value) { |
438 SetUserText(new_value, new_value, true); | 437 SetUserText(new_value, true); |
439 } | 438 } |
440 | 439 |
441 void OmniboxViewViews::UpdateSecurityLevel() { | 440 void OmniboxViewViews::UpdateSecurityLevel() { |
442 security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false); | 441 security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false); |
443 } | 442 } |
444 | 443 |
445 void OmniboxViewViews::SetWindowTextAndCaretPos(const base::string16& text, | 444 void OmniboxViewViews::SetWindowTextAndCaretPos(const base::string16& text, |
446 size_t caret_pos, | 445 size_t caret_pos, |
447 bool update_popup, | 446 bool update_popup, |
448 bool notify_text_changed) { | 447 bool notify_text_changed) { |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 menu_contents->InsertItemWithStringIdAt( | 1074 menu_contents->InsertItemWithStringIdAt( |
1076 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); | 1075 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); |
1077 } | 1076 } |
1078 | 1077 |
1079 // Minor note: We use IDC_ for command id here while the underlying textfield | 1078 // Minor note: We use IDC_ for command id here while the underlying textfield |
1080 // is using IDS_ for all its command ids. This is because views cannot depend | 1079 // is using IDS_ for all its command ids. This is because views cannot depend |
1081 // on IDC_ for now. | 1080 // on IDC_ for now. |
1082 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1081 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
1083 IDS_EDIT_SEARCH_ENGINES); | 1082 IDS_EDIT_SEARCH_ENGINES); |
1084 } | 1083 } |
OLD | NEW |