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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // BrowserView::ActiveTabChanged(). | 218 // BrowserView::ActiveTabChanged(). |
219 SelectRange(state->selection); | 219 SelectRange(state->selection); |
220 saved_selection_for_focus_change_ = state->saved_selection_for_focus_change; | 220 saved_selection_for_focus_change_ = state->saved_selection_for_focus_change; |
221 } | 221 } |
222 | 222 |
223 // TODO(msw|oshima): Consider saving/restoring edit history. | 223 // TODO(msw|oshima): Consider saving/restoring edit history. |
224 ClearEditHistory(); | 224 ClearEditHistory(); |
225 } | 225 } |
226 | 226 |
227 void OmniboxViewViews::Update() { | 227 void OmniboxViewViews::Update() { |
228 if (chrome::ShouldDisplayOriginChip() || chrome::ShouldDisplayOriginChipV2()) | 228 if (chrome::ShouldDisplayOriginChip()) |
229 set_placeholder_text(GetHintText()); | 229 set_placeholder_text(GetHintText()); |
230 | 230 |
231 const ToolbarModel::SecurityLevel old_security_level = security_level_; | 231 const ToolbarModel::SecurityLevel old_security_level = security_level_; |
232 security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false); | 232 security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false); |
233 if (model()->UpdatePermanentText()) { | 233 if (model()->UpdatePermanentText()) { |
234 // Something visibly changed. Re-enable URL replacement. | 234 // Something visibly changed. Re-enable URL replacement. |
235 controller()->GetToolbarModel()->set_url_replacement_enabled(true); | 235 controller()->GetToolbarModel()->set_url_replacement_enabled(true); |
236 controller()->GetToolbarModel()->set_origin_chip_enabled(true); | 236 controller()->GetToolbarModel()->set_origin_chip_enabled(true); |
237 model()->UpdatePermanentText(); | 237 model()->UpdatePermanentText(); |
238 | 238 |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 } | 1019 } |
1020 | 1020 |
1021 void OmniboxViewViews::UpdateContextMenu(ui::SimpleMenuModel* menu_contents) { | 1021 void OmniboxViewViews::UpdateContextMenu(ui::SimpleMenuModel* menu_contents) { |
1022 int paste_position = menu_contents->GetIndexOfCommandId(IDS_APP_PASTE); | 1022 int paste_position = menu_contents->GetIndexOfCommandId(IDS_APP_PASTE); |
1023 DCHECK_GE(paste_position, 0); | 1023 DCHECK_GE(paste_position, 0); |
1024 menu_contents->InsertItemWithStringIdAt( | 1024 menu_contents->InsertItemWithStringIdAt( |
1025 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); | 1025 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); |
1026 | 1026 |
1027 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); | 1027 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); |
1028 | 1028 |
1029 if (chrome::IsQueryExtractionEnabled() || chrome::ShouldDisplayOriginChip() || | 1029 if (chrome::IsQueryExtractionEnabled() || chrome::ShouldDisplayOriginChip()) { |
1030 chrome::ShouldDisplayOriginChipV2()) { | |
1031 int select_all_position = menu_contents->GetIndexOfCommandId( | 1030 int select_all_position = menu_contents->GetIndexOfCommandId( |
1032 IDS_APP_SELECT_ALL); | 1031 IDS_APP_SELECT_ALL); |
1033 DCHECK_GE(select_all_position, 0); | 1032 DCHECK_GE(select_all_position, 0); |
1034 menu_contents->InsertItemWithStringIdAt( | 1033 menu_contents->InsertItemWithStringIdAt( |
1035 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); | 1034 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); |
1036 } | 1035 } |
1037 | 1036 |
1038 // Minor note: We use IDC_ for command id here while the underlying textfield | 1037 // Minor note: We use IDC_ for command id here while the underlying textfield |
1039 // is using IDS_ for all its command ids. This is because views cannot depend | 1038 // is using IDS_ for all its command ids. This is because views cannot depend |
1040 // on IDC_ for now. | 1039 // on IDC_ for now. |
1041 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1040 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
1042 IDS_EDIT_SEARCH_ENGINES); | 1041 IDS_EDIT_SEARCH_ENGINES); |
1043 } | 1042 } |
OLD | NEW |