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

Unified Diff: chrome/browser/search_versus_navigate_classifier.cc

Issue 328031: Refactor paste and go out of AutocompleteEdit. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: style fixes Created 11 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/search_versus_navigate_classifier.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search_versus_navigate_classifier.cc
===================================================================
--- chrome/browser/search_versus_navigate_classifier.cc (revision 0)
+++ chrome/browser/search_versus_navigate_classifier.cc (revision 0)
@@ -0,0 +1,56 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/search_versus_navigate_classifier.h"
+
+#include "chrome/browser/autocomplete/autocomplete.h"
+#include "googleurl/src/gurl.h"
+
+SearchVersusNavigateClassifier::SearchVersusNavigateClassifier(Profile* profile)
+ : controller_(new AutocompleteController(profile)) {
+}
+
+SearchVersusNavigateClassifier::~SearchVersusNavigateClassifier() {
+}
+
+void SearchVersusNavigateClassifier::Classify(const std::wstring& text,
+ const std::wstring& desired_tld,
+ bool* is_search,
+ GURL* destination_url,
+ PageTransition::Type* transition,
+ bool* is_history_what_you_typed_match,
+ GURL* alternate_nav_url) {
+ controller_->Start(text, desired_tld, true, false, true);
+ DCHECK(controller_->done());
+ const AutocompleteResult& result = controller_->result();
+ if (result.empty()) {
+ if (is_search)
+ *is_search = false;
+ if (destination_url)
+ *destination_url = GURL();
+ if (transition)
+ *transition = PageTransition::TYPED;
+ if (is_history_what_you_typed_match)
+ *is_history_what_you_typed_match = false;
+ if (alternate_nav_url)
+ *alternate_nav_url = GURL();
+ return;
+ }
+
+ const AutocompleteResult::const_iterator match(result.default_match());
+ DCHECK(match != result.end());
+
+ // If this is a search, the page transition will be GENERATED rather than
+ // TYPED.
+ if (is_search)
+ *is_search = (match->transition != PageTransition::TYPED);
+ if (destination_url)
+ *destination_url = match->destination_url;
+ if (transition)
+ *transition = match->transition;
+ if (is_history_what_you_typed_match)
+ *is_history_what_you_typed_match = match->is_history_what_you_typed_match;
+ if (alternate_nav_url)
+ *alternate_nav_url = result.alternate_nav_url();
+}
« no previous file with comments | « chrome/browser/search_versus_navigate_classifier.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698