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

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

Issue 19810002: Omnibox Logging: Record Whether User Was on a Search Result Page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: consistency Created 7 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
« no previous file with comments | « no previous file | chrome/common/metrics/proto/omnibox_event.proto » ('j') | 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 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 case 0x3000: // Ideographic Space 1260 case 0x3000: // Ideographic Space
1261 return true; 1261 return true;
1262 default: 1262 default:
1263 return false; 1263 return false;
1264 } 1264 }
1265 } 1265 }
1266 1266
1267 metrics::OmniboxEventProto::PageClassification 1267 metrics::OmniboxEventProto::PageClassification
1268 OmniboxEditModel::ClassifyPage() const { 1268 OmniboxEditModel::ClassifyPage() const {
1269 if (!delegate_->CurrentPageExists()) 1269 if (!delegate_->CurrentPageExists())
1270 return metrics::OmniboxEventProto_PageClassification_OTHER; 1270 return metrics::OmniboxEventProto::OTHER;
1271 if (delegate_->IsInstantNTP()) 1271 if (delegate_->IsInstantNTP())
1272 return metrics::OmniboxEventProto_PageClassification_INSTANT_NEW_TAB_PAGE; 1272 return metrics::OmniboxEventProto::INSTANT_NEW_TAB_PAGE;
1273 const GURL& gurl = delegate_->GetURL(); 1273 const GURL& gurl = delegate_->GetURL();
1274 if (!gurl.is_valid()) 1274 if (!gurl.is_valid())
1275 return metrics::OmniboxEventProto_PageClassification_INVALID_SPEC; 1275 return metrics::OmniboxEventProto::INVALID_SPEC;
1276 const std::string& url = gurl.spec(); 1276 const std::string& url = gurl.spec();
1277 if (url == chrome::kChromeUINewTabURL) 1277 if (url == chrome::kChromeUINewTabURL)
1278 return metrics::OmniboxEventProto_PageClassification_NEW_TAB_PAGE; 1278 return metrics::OmniboxEventProto::NEW_TAB_PAGE;
1279 if (url == content::kAboutBlankURL) 1279 if (url == content::kAboutBlankURL)
1280 return metrics::OmniboxEventProto_PageClassification_BLANK; 1280 return metrics::OmniboxEventProto::BLANK;
1281 if (url == profile()->GetPrefs()->GetString(prefs::kHomePage)) 1281 if (url == profile()->GetPrefs()->GetString(prefs::kHomePage))
1282 return metrics::OmniboxEventProto_PageClassification_HOMEPAGE; 1282 return metrics::OmniboxEventProto::HOMEPAGE;
1283 return metrics::OmniboxEventProto_PageClassification_OTHER; 1283 if (view_->toolbar_model()->WouldReplaceSearchURLWithSearchTerms(true)) {
1284 return metrics::
1285 OmniboxEventProto::SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT;
1286 }
1287 return metrics::OmniboxEventProto::OTHER;
1284 } 1288 }
1285 1289
1286 void OmniboxEditModel::ClassifyStringForPasteAndGo( 1290 void OmniboxEditModel::ClassifyStringForPasteAndGo(
1287 const string16& text, 1291 const string16& text,
1288 AutocompleteMatch* match, 1292 AutocompleteMatch* match,
1289 GURL* alternate_nav_url) const { 1293 GURL* alternate_nav_url) const {
1290 DCHECK(match); 1294 DCHECK(match);
1291 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, 1295 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text,
1292 false, false, match, alternate_nav_url); 1296 false, false, match, alternate_nav_url);
1293 } 1297 }
1294 1298
1295 void OmniboxEditModel::SetFocusState(OmniboxFocusState state, 1299 void OmniboxEditModel::SetFocusState(OmniboxFocusState state,
1296 OmniboxFocusChangeReason reason) { 1300 OmniboxFocusChangeReason reason) {
1297 if (state == focus_state_) 1301 if (state == focus_state_)
1298 return; 1302 return;
1299 1303
1300 InstantController* instant = GetInstantController(); 1304 InstantController* instant = GetInstantController();
1301 if (instant) 1305 if (instant)
1302 instant->OmniboxFocusChanged(state, reason, NULL); 1306 instant->OmniboxFocusChanged(state, reason, NULL);
1303 1307
1304 // Update state and notify view if the omnibox has focus and the caret 1308 // Update state and notify view if the omnibox has focus and the caret
1305 // visibility changed. 1309 // visibility changed.
1306 const bool was_caret_visible = is_caret_visible(); 1310 const bool was_caret_visible = is_caret_visible();
1307 focus_state_ = state; 1311 focus_state_ = state;
1308 if (focus_state_ != OMNIBOX_FOCUS_NONE && 1312 if (focus_state_ != OMNIBOX_FOCUS_NONE &&
1309 is_caret_visible() != was_caret_visible) 1313 is_caret_visible() != was_caret_visible)
1310 view_->ApplyCaretVisibility(); 1314 view_->ApplyCaretVisibility();
1311 } 1315 }
OLDNEW
« no previous file with comments | « no previous file | chrome/common/metrics/proto/omnibox_event.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698