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

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

Issue 343523003: Remove AutocompleteInput Type and PageClassification. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "chrome/browser/ui/omnibox/omnibox_navigation_observer.h" 49 #include "chrome/browser/ui/omnibox/omnibox_navigation_observer.h"
50 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" 50 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
51 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" 51 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h"
52 #include "chrome/browser/ui/omnibox/omnibox_view.h" 52 #include "chrome/browser/ui/omnibox/omnibox_view.h"
53 #include "chrome/browser/ui/search/instant_search_prerenderer.h" 53 #include "chrome/browser/ui/search/instant_search_prerenderer.h"
54 #include "chrome/browser/ui/search/search_tab_helper.h" 54 #include "chrome/browser/ui/search/search_tab_helper.h"
55 #include "chrome/browser/ui/toolbar/toolbar_model.h" 55 #include "chrome/browser/ui/toolbar/toolbar_model.h"
56 #include "chrome/common/chrome_switches.h" 56 #include "chrome/common/chrome_switches.h"
57 #include "chrome/common/pref_names.h" 57 #include "chrome/common/pref_names.h"
58 #include "chrome/common/url_constants.h" 58 #include "chrome/common/url_constants.h"
59 #include "components/metrics/proto/omnibox_event.pb.h"
59 #include "components/google/core/browser/google_url_tracker.h" 60 #include "components/google/core/browser/google_url_tracker.h"
60 #include "components/url_fixer/url_fixer.h" 61 #include "components/url_fixer/url_fixer.h"
61 #include "content/public/browser/navigation_controller.h" 62 #include "content/public/browser/navigation_controller.h"
62 #include "content/public/browser/navigation_entry.h" 63 #include "content/public/browser/navigation_entry.h"
63 #include "content/public/browser/notification_service.h" 64 #include "content/public/browser/notification_service.h"
64 #include "content/public/browser/render_view_host.h" 65 #include "content/public/browser/render_view_host.h"
65 #include "content/public/browser/user_metrics.h" 66 #include "content/public/browser/user_metrics.h"
66 #include "extensions/common/constants.h" 67 #include "extensions/common/constants.h"
67 #include "ui/gfx/image/image.h" 68 #include "ui/gfx/image/image.h"
68 #include "url/url_util.h" 69 #include "url/url_util.h"
69 70
71 using metrics::OmniboxEventProto;
70 using predictors::AutocompleteActionPredictor; 72 using predictors::AutocompleteActionPredictor;
71 73
72 74
73 // Helpers -------------------------------------------------------------------- 75 // Helpers --------------------------------------------------------------------
74 76
75 namespace { 77 namespace {
76 78
77 // Histogram name which counts the number of times that the user text is 79 // Histogram name which counts the number of times that the user text is
78 // cleared. IME users are sometimes in the situation that IME was 80 // cleared. IME users are sometimes in the situation that IME was
79 // unintentionally turned on and failed to input latin alphabets (ASCII 81 // unintentionally turned on and failed to input latin alphabets (ASCII
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 bool OmniboxEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { 1421 bool OmniboxEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) {
1420 switch (c) { 1422 switch (c) {
1421 case 0x0020: // Space 1423 case 0x0020: // Space
1422 case 0x3000: // Ideographic Space 1424 case 0x3000: // Ideographic Space
1423 return true; 1425 return true;
1424 default: 1426 default:
1425 return false; 1427 return false;
1426 } 1428 }
1427 } 1429 }
1428 1430
1429 AutocompleteInput::PageClassification OmniboxEditModel::ClassifyPage() const { 1431 OmniboxEventProto::PageClassification OmniboxEditModel::ClassifyPage() const {
1430 if (!delegate_->CurrentPageExists()) 1432 if (!delegate_->CurrentPageExists())
1431 return AutocompleteInput::OTHER; 1433 return OmniboxEventProto::OTHER;
1432 if (delegate_->IsInstantNTP()) { 1434 if (delegate_->IsInstantNTP()) {
1433 // Note that we treat OMNIBOX as the source if focus_source_ is INVALID, 1435 // Note that we treat OMNIBOX as the source if focus_source_ is INVALID,
1434 // i.e., if input isn't actually in progress. 1436 // i.e., if input isn't actually in progress.
1435 return (focus_source_ == FAKEBOX) ? 1437 return (focus_source_ == FAKEBOX) ?
1436 AutocompleteInput::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS : 1438 OmniboxEventProto::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS :
1437 AutocompleteInput::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS; 1439 OmniboxEventProto::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS;
1438 } 1440 }
1439 const GURL& gurl = delegate_->GetURL(); 1441 const GURL& gurl = delegate_->GetURL();
1440 if (!gurl.is_valid()) 1442 if (!gurl.is_valid())
1441 return AutocompleteInput::INVALID_SPEC; 1443 return OmniboxEventProto::INVALID_SPEC;
1442 const std::string& url = gurl.spec(); 1444 const std::string& url = gurl.spec();
1443 if (url == chrome::kChromeUINewTabURL) 1445 if (url == chrome::kChromeUINewTabURL)
1444 return AutocompleteInput::NTP; 1446 return OmniboxEventProto::NTP;
1445 if (url == url::kAboutBlankURL) 1447 if (url == url::kAboutBlankURL)
1446 return AutocompleteInput::BLANK; 1448 return OmniboxEventProto::BLANK;
1447 if (url == profile()->GetPrefs()->GetString(prefs::kHomePage)) 1449 if (url == profile()->GetPrefs()->GetString(prefs::kHomePage))
1448 return AutocompleteInput::HOME_PAGE; 1450 return OmniboxEventProto::HOME_PAGE;
1449 if (controller_->GetToolbarModel()->WouldPerformSearchTermReplacement(true)) 1451 if (controller_->GetToolbarModel()->WouldPerformSearchTermReplacement(true))
1450 return AutocompleteInput::SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT; 1452 return OmniboxEventProto::SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT;
1451 if (delegate_->IsSearchResultsPage()) 1453 if (delegate_->IsSearchResultsPage())
1452 return AutocompleteInput::SEARCH_RESULT_PAGE_NO_SEARCH_TERM_REPLACEMENT; 1454 return OmniboxEventProto::SEARCH_RESULT_PAGE_NO_SEARCH_TERM_REPLACEMENT;
1453 return AutocompleteInput::OTHER; 1455 return OmniboxEventProto::OTHER;
1454 } 1456 }
1455 1457
1456 void OmniboxEditModel::ClassifyStringForPasteAndGo( 1458 void OmniboxEditModel::ClassifyStringForPasteAndGo(
1457 const base::string16& text, 1459 const base::string16& text,
1458 AutocompleteMatch* match, 1460 AutocompleteMatch* match,
1459 GURL* alternate_nav_url) const { 1461 GURL* alternate_nav_url) const {
1460 DCHECK(match); 1462 DCHECK(match);
1461 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify( 1463 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(
1462 text, false, false, ClassifyPage(), match, alternate_nav_url); 1464 text, false, false, ClassifyPage(), match, alternate_nav_url);
1463 } 1465 }
1464 1466
1465 void OmniboxEditModel::SetFocusState(OmniboxFocusState state, 1467 void OmniboxEditModel::SetFocusState(OmniboxFocusState state,
1466 OmniboxFocusChangeReason reason) { 1468 OmniboxFocusChangeReason reason) {
1467 if (state == focus_state_) 1469 if (state == focus_state_)
1468 return; 1470 return;
1469 1471
1470 // Update state and notify view if the omnibox has focus and the caret 1472 // Update state and notify view if the omnibox has focus and the caret
1471 // visibility changed. 1473 // visibility changed.
1472 const bool was_caret_visible = is_caret_visible(); 1474 const bool was_caret_visible = is_caret_visible();
1473 focus_state_ = state; 1475 focus_state_ = state;
1474 if (focus_state_ != OMNIBOX_FOCUS_NONE && 1476 if (focus_state_ != OMNIBOX_FOCUS_NONE &&
1475 is_caret_visible() != was_caret_visible) 1477 is_caret_visible() != was_caret_visible)
1476 view_->ApplyCaretVisibility(); 1478 view_->ApplyCaretVisibility();
1477 1479
1478 delegate_->OnFocusChanged(focus_state_, reason); 1480 delegate_->OnFocusChanged(focus_state_, reason);
1479 } 1481 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_edit_model.h ('k') | chrome/browser/ui/views/frame/browser_root_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698