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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_popup_model.cc

Issue 354773002: Reduces dependency from AutocompleteMatch to Profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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 | Annotate | Revision Log
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/omnibox/omnibox_popup_model.h" 5 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 selected_line_state_ = NORMAL; 152 selected_line_state_ = NORMAL;
153 selected_line_ = line; 153 selected_line_ = line;
154 view_->InvalidateLine(prev_selected_line); 154 view_->InvalidateLine(prev_selected_line);
155 view_->InvalidateLine(selected_line_); 155 view_->InvalidateLine(selected_line_);
156 156
157 // Update the edit with the new data for this match. 157 // Update the edit with the new data for this match.
158 // TODO(pkasting): If |selected_line_| moves to the controller, this can be 158 // TODO(pkasting): If |selected_line_| moves to the controller, this can be
159 // eliminated and just become a call to the observer on the edit. 159 // eliminated and just become a call to the observer on the edit.
160 base::string16 keyword; 160 base::string16 keyword;
161 bool is_keyword_hint; 161 bool is_keyword_hint;
162 match.GetKeywordUIState(edit_model_->profile(), &keyword, &is_keyword_hint); 162 TemplateURLService* service =
163 TemplateURLServiceFactory::GetForProfile(edit_model_->profile());
164 match.GetKeywordUIState(service, &keyword, &is_keyword_hint);
163 165
164 if (reset_to_default) { 166 if (reset_to_default) {
165 edit_model_->OnPopupDataChanged(match.inline_autocompletion, NULL, 167 edit_model_->OnPopupDataChanged(match.inline_autocompletion, NULL,
166 keyword, is_keyword_hint); 168 keyword, is_keyword_hint);
167 } else { 169 } else {
168 edit_model_->OnPopupDataChanged(match.fill_into_edit, &current_destination, 170 edit_model_->OnPopupDataChanged(match.fill_into_edit, &current_destination,
169 keyword, is_keyword_hint); 171 keyword, is_keyword_hint);
170 } 172 }
171 173
172 // Repaint old and new selected lines immediately, so that the edit doesn't 174 // Repaint old and new selected lines immediately, so that the edit doesn't
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // before notifying us, reducing flicker. At that point the check for 237 // before notifying us, reducing flicker. At that point the check for
236 // deletability can move there too. 238 // deletability can move there too.
237 SetSelectedLine(selected_line, false, true); 239 SetSelectedLine(selected_line, false, true);
238 } 240 }
239 } 241 }
240 } 242 }
241 243
242 gfx::Image OmniboxPopupModel::GetIconIfExtensionMatch( 244 gfx::Image OmniboxPopupModel::GetIconIfExtensionMatch(
243 const AutocompleteMatch& match) const { 245 const AutocompleteMatch& match) const {
244 Profile* profile = edit_model_->profile(); 246 Profile* profile = edit_model_->profile();
245 const TemplateURL* template_url = match.GetTemplateURL(profile, false); 247 TemplateURLService* service =
248 TemplateURLServiceFactory::GetForProfile(profile);
249 const TemplateURL* template_url = match.GetTemplateURL(service, false);
246 if (template_url && 250 if (template_url &&
247 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { 251 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) {
248 return extensions::OmniboxAPI::Get(profile)->GetOmniboxPopupIcon( 252 return extensions::OmniboxAPI::Get(profile)->GetOmniboxPopupIcon(
249 template_url->GetExtensionId()); 253 template_url->GetExtensionId());
250 } 254 }
251 return gfx::Image(); 255 return gfx::Image();
252 } 256 }
253 257
254 void OmniboxPopupModel::OnResultChanged() { 258 void OmniboxPopupModel::OnResultChanged() {
255 const AutocompleteResult& result = this->result(); 259 const AutocompleteResult& result = this->result();
(...skipping 18 matching lines...) Expand all
274 } 278 }
275 } 279 }
276 280
277 void OmniboxPopupModel::AddObserver(OmniboxPopupModelObserver* observer) { 281 void OmniboxPopupModel::AddObserver(OmniboxPopupModelObserver* observer) {
278 observers_.AddObserver(observer); 282 observers_.AddObserver(observer);
279 } 283 }
280 284
281 void OmniboxPopupModel::RemoveObserver(OmniboxPopupModelObserver* observer) { 285 void OmniboxPopupModel::RemoveObserver(OmniboxPopupModelObserver* observer) {
282 observers_.RemoveObserver(observer); 286 observers_.RemoveObserver(observer);
283 } 287 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_navigation_observer.h ('k') | chrome/browser/ui/views/frame/test_with_browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698