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

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

Issue 20747002: Make a copy of PageClassification enum outside the metrics code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ilya's comment Created 7 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
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_edit_model.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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_edit_model.h" 5 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 bool OmniboxEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { 1247 bool OmniboxEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) {
1248 switch (c) { 1248 switch (c) {
1249 case 0x0020: // Space 1249 case 0x0020: // Space
1250 case 0x3000: // Ideographic Space 1250 case 0x3000: // Ideographic Space
1251 return true; 1251 return true;
1252 default: 1252 default:
1253 return false; 1253 return false;
1254 } 1254 }
1255 } 1255 }
1256 1256
1257 metrics::OmniboxEventProto::PageClassification 1257 AutocompleteInput::PageClassification OmniboxEditModel::ClassifyPage() const {
1258 OmniboxEditModel::ClassifyPage() const {
1259 if (!delegate_->CurrentPageExists()) 1258 if (!delegate_->CurrentPageExists())
1260 return metrics::OmniboxEventProto::OTHER; 1259 return AutocompleteInput::OTHER;
1261 if (delegate_->IsInstantNTP()) 1260 if (delegate_->IsInstantNTP())
1262 return metrics::OmniboxEventProto::INSTANT_NEW_TAB_PAGE; 1261 return AutocompleteInput::INSTANT_NEW_TAB_PAGE;
1263 const GURL& gurl = delegate_->GetURL(); 1262 const GURL& gurl = delegate_->GetURL();
1264 if (!gurl.is_valid()) 1263 if (!gurl.is_valid())
1265 return metrics::OmniboxEventProto::INVALID_SPEC; 1264 return AutocompleteInput::INVALID_SPEC;
1266 const std::string& url = gurl.spec(); 1265 const std::string& url = gurl.spec();
1267 if (url == chrome::kChromeUINewTabURL) 1266 if (url == chrome::kChromeUINewTabURL)
1268 return metrics::OmniboxEventProto::NEW_TAB_PAGE; 1267 return AutocompleteInput::NEW_TAB_PAGE;
1269 if (url == content::kAboutBlankURL) 1268 if (url == content::kAboutBlankURL)
1270 return metrics::OmniboxEventProto::BLANK; 1269 return AutocompleteInput::BLANK;
1271 if (url == profile()->GetPrefs()->GetString(prefs::kHomePage)) 1270 if (url == profile()->GetPrefs()->GetString(prefs::kHomePage))
1272 return metrics::OmniboxEventProto::HOMEPAGE; 1271 return AutocompleteInput::HOMEPAGE;
1273 if (view_->toolbar_model()->WouldReplaceSearchURLWithSearchTerms(true)) { 1272 if (view_->toolbar_model()->WouldReplaceSearchURLWithSearchTerms(true)) {
1274 return metrics:: 1273 return AutocompleteInput::SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT;
1275 OmniboxEventProto::SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT;
1276 } 1274 }
1277 return metrics::OmniboxEventProto::OTHER; 1275 return AutocompleteInput::OTHER;
1278 } 1276 }
1279 1277
1280 void OmniboxEditModel::ClassifyStringForPasteAndGo( 1278 void OmniboxEditModel::ClassifyStringForPasteAndGo(
1281 const string16& text, 1279 const string16& text,
1282 AutocompleteMatch* match, 1280 AutocompleteMatch* match,
1283 GURL* alternate_nav_url) const { 1281 GURL* alternate_nav_url) const {
1284 DCHECK(match); 1282 DCHECK(match);
1285 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, 1283 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text,
1286 false, false, match, alternate_nav_url); 1284 false, false, match, alternate_nav_url);
1287 } 1285 }
1288 1286
1289 void OmniboxEditModel::SetFocusState(OmniboxFocusState state, 1287 void OmniboxEditModel::SetFocusState(OmniboxFocusState state,
1290 OmniboxFocusChangeReason reason) { 1288 OmniboxFocusChangeReason reason) {
1291 if (state == focus_state_) 1289 if (state == focus_state_)
1292 return; 1290 return;
1293 1291
1294 InstantController* instant = GetInstantController(); 1292 InstantController* instant = GetInstantController();
1295 if (instant) 1293 if (instant)
1296 instant->OmniboxFocusChanged(state, reason, NULL); 1294 instant->OmniboxFocusChanged(state, reason, NULL);
1297 1295
1298 // Update state and notify view if the omnibox has focus and the caret 1296 // Update state and notify view if the omnibox has focus and the caret
1299 // visibility changed. 1297 // visibility changed.
1300 const bool was_caret_visible = is_caret_visible(); 1298 const bool was_caret_visible = is_caret_visible();
1301 focus_state_ = state; 1299 focus_state_ = state;
1302 if (focus_state_ != OMNIBOX_FOCUS_NONE && 1300 if (focus_state_ != OMNIBOX_FOCUS_NONE &&
1303 is_caret_visible() != was_caret_visible) 1301 is_caret_visible() != was_caret_visible)
1304 view_->ApplyCaretVisibility(); 1302 view_->ApplyCaretVisibility();
1305 } 1303 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_edit_model.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698