Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_views.cc

Issue 2731123002: Fix some issues with OmniboxViewViews' use of OmniboxClient. (Closed)
Patch Set: Review comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "chrome/app/chrome_command_ids.h" 16 #include "chrome/app/chrome_command_ids.h"
17 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
18 #include "chrome/browser/command_updater.h" 17 #include "chrome/browser/command_updater.h"
19 #include "chrome/browser/ui/omnibox/chrome_omnibox_client.h"
20 #include "chrome/browser/ui/omnibox/clipboard_utils.h" 18 #include "chrome/browser/ui/omnibox/clipboard_utils.h"
21 #include "chrome/browser/ui/view_ids.h" 19 #include "chrome/browser/ui/view_ids.h"
22 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 20 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
23 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" 21 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h"
24 #include "chrome/grit/generated_resources.h" 22 #include "chrome/grit/generated_resources.h"
25 #include "components/omnibox/browser/autocomplete_input.h" 23 #include "components/omnibox/browser/autocomplete_input.h"
26 #include "components/omnibox/browser/autocomplete_match.h" 24 #include "components/omnibox/browser/autocomplete_match.h"
25 #include "components/omnibox/browser/omnibox_client.h"
27 #include "components/omnibox/browser/omnibox_edit_controller.h" 26 #include "components/omnibox/browser/omnibox_edit_controller.h"
28 #include "components/omnibox/browser/omnibox_edit_model.h" 27 #include "components/omnibox/browser/omnibox_edit_model.h"
29 #include "components/omnibox/browser/omnibox_field_trial.h" 28 #include "components/omnibox/browser/omnibox_field_trial.h"
30 #include "components/omnibox/browser/omnibox_popup_model.h" 29 #include "components/omnibox/browser/omnibox_popup_model.h"
31 #include "components/strings/grit/components_strings.h" 30 #include "components/strings/grit/components_strings.h"
32 #include "components/toolbar/toolbar_model.h" 31 #include "components/toolbar/toolbar_model.h"
33 #include "content/public/browser/web_contents.h" 32 #include "content/public/browser/web_contents.h"
34 #include "net/base/escape.h" 33 #include "net/base/escape.h"
35 #include "third_party/skia/include/core/SkColor.h" 34 #include "third_party/skia/include/core/SkColor.h"
36 #include "ui/accessibility/ax_action_data.h" 35 #include "ui/accessibility/ax_action_data.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 98
100 } // namespace 99 } // namespace
101 100
102 101
103 // OmniboxViewViews ----------------------------------------------------------- 102 // OmniboxViewViews -----------------------------------------------------------
104 103
105 // static 104 // static
106 const char OmniboxViewViews::kViewClassName[] = "OmniboxViewViews"; 105 const char OmniboxViewViews::kViewClassName[] = "OmniboxViewViews";
107 106
108 OmniboxViewViews::OmniboxViewViews(OmniboxEditController* controller, 107 OmniboxViewViews::OmniboxViewViews(OmniboxEditController* controller,
109 Profile* profile, 108 std::unique_ptr<OmniboxClient> client,
110 CommandUpdater* command_updater, 109 CommandUpdater* command_updater,
111 bool popup_window_mode, 110 bool popup_window_mode,
112 LocationBarView* location_bar, 111 LocationBarView* location_bar,
113 const gfx::FontList& font_list) 112 const gfx::FontList& font_list)
114 : OmniboxView( 113 : OmniboxView(controller, std::move(client)),
115 controller,
116 base::WrapUnique(new ChromeOmniboxClient(controller, profile))),
117 profile_(profile),
118 popup_window_mode_(popup_window_mode), 114 popup_window_mode_(popup_window_mode),
119 security_level_(security_state::NONE), 115 security_level_(security_state::NONE),
120 saved_selection_for_focus_change_(gfx::Range::InvalidRange()), 116 saved_selection_for_focus_change_(gfx::Range::InvalidRange()),
121 ime_composing_before_change_(false), 117 ime_composing_before_change_(false),
122 delete_at_end_pressed_(false), 118 delete_at_end_pressed_(false),
123 location_bar_view_(location_bar), 119 location_bar_view_(location_bar),
124 ime_candidate_window_open_(false), 120 ime_candidate_window_open_(false),
125 select_all_on_mouse_release_(false), 121 select_all_on_mouse_release_(false),
126 select_all_on_gesture_tap_(false) { 122 select_all_on_gesture_tap_(false) {
127 set_id(VIEW_ID_OMNIBOX); 123 set_id(VIEW_ID_OMNIBOX);
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 583
588 // If the current contents is a URL, force left-to-right rendering at the 584 // If the current contents is a URL, force left-to-right rendering at the
589 // paragraph level. Right-to-left runs are still rendered RTL, but will not 585 // paragraph level. Right-to-left runs are still rendered RTL, but will not
590 // flip the whole URL around. For example (if "ABC" is Hebrew), this will 586 // flip the whole URL around. For example (if "ABC" is Hebrew), this will
591 // render "ABC.com" as "CBA.com", rather than "com.CBA". 587 // render "ABC.com" as "CBA.com", rather than "com.CBA".
592 bool text_is_url = model()->CurrentTextIsURL(); 588 bool text_is_url = model()->CurrentTextIsURL();
593 GetRenderText()->SetDirectionalityMode(text_is_url 589 GetRenderText()->SetDirectionalityMode(text_is_url
594 ? gfx::DIRECTIONALITY_FORCE_LTR 590 ? gfx::DIRECTIONALITY_FORCE_LTR
595 : gfx::DIRECTIONALITY_FROM_TEXT); 591 : gfx::DIRECTIONALITY_FROM_TEXT);
596 SetStyle(gfx::DIAGONAL_STRIKE, false); 592 SetStyle(gfx::DIAGONAL_STRIKE, false);
597 UpdateTextStyle(text(), ChromeAutocompleteSchemeClassifier(profile_)); 593 UpdateTextStyle(text(), model()->client()->GetSchemeClassifier());
598 } 594 }
599 595
600 bool OmniboxViewViews::IsItemForCommandIdDynamic(int command_id) const { 596 bool OmniboxViewViews::IsItemForCommandIdDynamic(int command_id) const {
601 return command_id == IDS_PASTE_AND_GO; 597 return command_id == IDS_PASTE_AND_GO;
602 } 598 }
603 599
604 base::string16 OmniboxViewViews::GetLabelForCommandId(int command_id) const { 600 base::string16 OmniboxViewViews::GetLabelForCommandId(int command_id) const {
605 DCHECK_EQ(IDS_PASTE_AND_GO, command_id); 601 DCHECK_EQ(IDS_PASTE_AND_GO, command_id);
606 return l10n_util::GetStringUTF16( 602 return l10n_util::GetStringUTF16(
607 model()->IsPasteAndSearch(GetClipboardText()) ? 603 model()->IsPasteAndSearch(GetClipboardText()) ?
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); 1053 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO);
1058 1054
1059 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); 1055 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR);
1060 1056
1061 // Minor note: We use IDC_ for command id here while the underlying textfield 1057 // Minor note: We use IDC_ for command id here while the underlying textfield
1062 // is using IDS_ for all its command ids. This is because views cannot depend 1058 // is using IDS_ for all its command ids. This is because views cannot depend
1063 // on IDC_ for now. 1059 // on IDC_ for now.
1064 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, 1060 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES,
1065 IDS_EDIT_SEARCH_ENGINES); 1061 IDS_EDIT_SEARCH_ENGINES);
1066 } 1062 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.h ('k') | chrome/browser/ui/views/omnibox/omnibox_view_views_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698