| 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/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 // BrowserView::ActiveTabChanged(). | 214 // BrowserView::ActiveTabChanged(). |
| 215 SelectRange(state->selection); | 215 SelectRange(state->selection); |
| 216 saved_selection_for_focus_change_ = state->saved_selection_for_focus_change; | 216 saved_selection_for_focus_change_ = state->saved_selection_for_focus_change; |
| 217 } | 217 } |
| 218 | 218 |
| 219 // TODO(msw|oshima): Consider saving/restoring edit history. | 219 // TODO(msw|oshima): Consider saving/restoring edit history. |
| 220 ClearEditHistory(); | 220 ClearEditHistory(); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void OmniboxViewViews::Update() { | 223 void OmniboxViewViews::Update() { |
| 224 if (chrome::ShouldDisplayOriginChip() || chrome::ShouldDisplayOriginChipV2()) | 224 if (chrome::ShouldDisplayOriginChip()) |
| 225 set_placeholder_text(GetHintText()); | 225 set_placeholder_text(GetHintText()); |
| 226 | 226 |
| 227 const ToolbarModel::SecurityLevel old_security_level = security_level_; | 227 const ToolbarModel::SecurityLevel old_security_level = security_level_; |
| 228 security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false); | 228 security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false); |
| 229 if (model()->UpdatePermanentText()) { | 229 if (model()->UpdatePermanentText()) { |
| 230 // Something visibly changed. Re-enable URL replacement. | 230 // Something visibly changed. Re-enable URL replacement. |
| 231 controller()->GetToolbarModel()->set_url_replacement_enabled(true); | 231 controller()->GetToolbarModel()->set_url_replacement_enabled(true); |
| 232 model()->UpdatePermanentText(); | 232 model()->UpdatePermanentText(); |
| 233 | 233 |
| 234 // Select all the new text if the user had all the old text selected, or if | 234 // Select all the new text if the user had all the old text selected, or if |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 void OmniboxViewViews::UpdateContextMenu(ui::SimpleMenuModel* menu_contents) { | 1032 void OmniboxViewViews::UpdateContextMenu(ui::SimpleMenuModel* menu_contents) { |
| 1033 int paste_position = menu_contents->GetIndexOfCommandId(IDS_APP_PASTE); | 1033 int paste_position = menu_contents->GetIndexOfCommandId(IDS_APP_PASTE); |
| 1034 DCHECK_GE(paste_position, 0); | 1034 DCHECK_GE(paste_position, 0); |
| 1035 menu_contents->InsertItemWithStringIdAt( | 1035 menu_contents->InsertItemWithStringIdAt( |
| 1036 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); | 1036 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); |
| 1037 | 1037 |
| 1038 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); | 1038 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); |
| 1039 | 1039 |
| 1040 if (chrome::IsQueryExtractionEnabled() || chrome::ShouldDisplayOriginChip() || | 1040 if (chrome::IsQueryExtractionEnabled() || chrome::ShouldDisplayOriginChip()) { |
| 1041 chrome::ShouldDisplayOriginChipV2()) { | |
| 1042 int select_all_position = menu_contents->GetIndexOfCommandId( | 1041 int select_all_position = menu_contents->GetIndexOfCommandId( |
| 1043 IDS_APP_SELECT_ALL); | 1042 IDS_APP_SELECT_ALL); |
| 1044 DCHECK_GE(select_all_position, 0); | 1043 DCHECK_GE(select_all_position, 0); |
| 1045 menu_contents->InsertItemWithStringIdAt( | 1044 menu_contents->InsertItemWithStringIdAt( |
| 1046 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); | 1045 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); |
| 1047 } | 1046 } |
| 1048 | 1047 |
| 1049 // Minor note: We use IDC_ for command id here while the underlying textfield | 1048 // Minor note: We use IDC_ for command id here while the underlying textfield |
| 1050 // is using IDS_ for all its command ids. This is because views cannot depend | 1049 // is using IDS_ for all its command ids. This is because views cannot depend |
| 1051 // on IDC_ for now. | 1050 // on IDC_ for now. |
| 1052 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1051 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
| 1053 IDS_EDIT_SEARCH_ENGINES); | 1052 IDS_EDIT_SEARCH_ENGINES); |
| 1054 } | 1053 } |
| OLD | NEW |