Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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_PageClassification_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_PageClassification_NEW_TAB_PAGE; |
| 1279 if (url == content::kAboutBlankURL) | 1279 if (url == content::kAboutBlankURL) |
| 1280 return metrics::OmniboxEventProto_PageClassification_BLANK; | 1280 return metrics::OmniboxEventProto_PageClassification_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_PageClassification_HOMEPAGE; |
| 1283 if (view_->toolbar_model()->WouldReplaceSearchURLWithSearchTerms(true)) { | |
| 1284 return metrics:: | |
| 1285 OmniboxEventProto_PageClassification_SEARCH_RESULT_PAGE_DOING_SEARCH_TER M_REPLACEMENT; | |
|
Ilya Sherman
2013/07/19 21:06:34
nit: I think you can refer to this as metrics::Omn
Mark P
2013/07/19 21:40:22
Yup, that works. Done. Also changed (for consist
| |
| 1286 } | |
| 1283 return metrics::OmniboxEventProto_PageClassification_OTHER; | 1287 return metrics::OmniboxEventProto_PageClassification_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 } |
| OLD | NEW |