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

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

Issue 415053002: Remove AutocompleteMatch::is_starred (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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"
11 #include "chrome/browser/autocomplete/autocomplete_match.h" 11 #include "chrome/browser/autocomplete/autocomplete_match.h"
12 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
12 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" 13 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/search_engines/template_url_service_factory.h" 15 #include "chrome/browser/search_engines/template_url_service_factory.h"
15 #include "chrome/browser/ui/omnibox/omnibox_popup_model_observer.h" 16 #include "chrome/browser/ui/omnibox/omnibox_popup_model_observer.h"
16 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" 17 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h"
18 #include "components/bookmarks/browser/bookmark_model.h"
17 #include "components/search_engines/template_url.h" 19 #include "components/search_engines/template_url.h"
18 #include "components/search_engines/template_url_service.h" 20 #include "components/search_engines/template_url_service.h"
19 #include "third_party/icu/source/common/unicode/ubidi.h" 21 #include "third_party/icu/source/common/unicode/ubidi.h"
20 #include "ui/gfx/image/image.h" 22 #include "ui/gfx/image/image.h"
21 #include "ui/gfx/rect.h" 23 #include "ui/gfx/rect.h"
22 24
23 /////////////////////////////////////////////////////////////////////////////// 25 ///////////////////////////////////////////////////////////////////////////////
24 // OmniboxPopupModel 26 // OmniboxPopupModel
25 27
26 const size_t OmniboxPopupModel::kNoMatch = static_cast<size_t>(-1); 28 const size_t OmniboxPopupModel::kNoMatch = static_cast<size_t>(-1);
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 TemplateURLServiceFactory::GetForProfile(profile); 250 TemplateURLServiceFactory::GetForProfile(profile);
249 const TemplateURL* template_url = match.GetTemplateURL(service, false); 251 const TemplateURL* template_url = match.GetTemplateURL(service, false);
250 if (template_url && 252 if (template_url &&
251 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { 253 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) {
252 return extensions::OmniboxAPI::Get(profile)->GetOmniboxPopupIcon( 254 return extensions::OmniboxAPI::Get(profile)->GetOmniboxPopupIcon(
253 template_url->GetExtensionId()); 255 template_url->GetExtensionId());
254 } 256 }
255 return gfx::Image(); 257 return gfx::Image();
256 } 258 }
257 259
260 bool OmniboxPopupModel::IsStarredMatch(const AutocompleteMatch& match) const {
261 Profile* profile = edit_model_->profile();
262 BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile);
263 return bookmark_model && bookmark_model->IsBookmarked(match.destination_url);
264 }
265
258 void OmniboxPopupModel::OnResultChanged() { 266 void OmniboxPopupModel::OnResultChanged() {
259 const AutocompleteResult& result = this->result(); 267 const AutocompleteResult& result = this->result();
260 selected_line_ = result.default_match() == result.end() ? 268 selected_line_ = result.default_match() == result.end() ?
261 kNoMatch : static_cast<size_t>(result.default_match() - result.begin()); 269 kNoMatch : static_cast<size_t>(result.default_match() - result.begin());
262 // There had better not be a nonempty result set with no default match. 270 // There had better not be a nonempty result set with no default match.
263 CHECK((selected_line_ != kNoMatch) || result.empty()); 271 CHECK((selected_line_ != kNoMatch) || result.empty());
264 manually_selected_match_.Clear(); 272 manually_selected_match_.Clear();
265 selected_line_state_ = NORMAL; 273 selected_line_state_ = NORMAL;
266 // If we're going to trim the window size to no longer include the hovered 274 // If we're going to trim the window size to no longer include the hovered
267 // line, turn hover off. Practically, this shouldn't happen, but it 275 // line, turn hover off. Practically, this shouldn't happen, but it
(...skipping 10 matching lines...) Expand all
278 } 286 }
279 } 287 }
280 288
281 void OmniboxPopupModel::AddObserver(OmniboxPopupModelObserver* observer) { 289 void OmniboxPopupModel::AddObserver(OmniboxPopupModelObserver* observer) {
282 observers_.AddObserver(observer); 290 observers_.AddObserver(observer);
283 } 291 }
284 292
285 void OmniboxPopupModel::RemoveObserver(OmniboxPopupModelObserver* observer) { 293 void OmniboxPopupModel::RemoveObserver(OmniboxPopupModelObserver* observer) {
286 observers_.RemoveObserver(observer); 294 observers_.RemoveObserver(observer);
287 } 295 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_popup_model.h ('k') | chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698