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

Side by Side Diff: chrome/browser/ui/search/search_tab_helper.cc

Issue 2232863002: Remove search::GetSearchTerms since it always returns empty string (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_query_extract
Patch Set: Mac Created 4 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
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/search/search_tab_helper.h" 5 #include "chrome/browser/ui/search/search_tab_helper.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <set> 8 #include <set>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // We can't use WebContents::GetURL() because that uses the active entry, 67 // We can't use WebContents::GetURL() because that uses the active entry,
68 // whereas we want the visible entry. 68 // whereas we want the visible entry.
69 const content::NavigationEntry* entry = 69 const content::NavigationEntry* entry =
70 contents->GetController().GetVisibleEntry(); 70 contents->GetController().GetVisibleEntry();
71 if (entry && entry->GetVirtualURL() == GURL(chrome::kChromeUINewTabURL)) 71 if (entry && entry->GetVirtualURL() == GURL(chrome::kChromeUINewTabURL))
72 return true; 72 return true;
73 73
74 return search::IsInstantNTP(contents); 74 return search::IsInstantNTP(contents);
75 } 75 }
76 76
77 bool IsSearchResults(const content::WebContents* contents) {
78 return !search::GetSearchTerms(contents).empty();
79 }
80
81 bool IsLocal(const content::WebContents* contents) { 77 bool IsLocal(const content::WebContents* contents) {
82 if (!contents) 78 if (!contents)
83 return false; 79 return false;
84 const content::NavigationEntry* entry = 80 const content::NavigationEntry* entry =
85 contents->GetController().GetVisibleEntry(); 81 contents->GetController().GetVisibleEntry();
86 return entry && entry->GetURL() == GURL(chrome::kChromeSearchLocalNtpUrl); 82 return entry && entry->GetURL() == GURL(chrome::kChromeSearchLocalNtpUrl);
87 } 83 }
88 84
89 // Returns true if |contents| are rendered inside an Instant process. 85 // Returns true if |contents| are rendered inside an Instant process.
90 bool InInstantProcess(Profile* profile, 86 bool InInstantProcess(Profile* profile,
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 delegate_->OnWebContentsInstantSupportDisabled(web_contents_); 465 delegate_->OnWebContentsInstantSupportDisabled(web_contents_);
470 } 466 }
471 } 467 }
472 468
473 void SearchTabHelper::UpdateMode(bool update_origin) { 469 void SearchTabHelper::UpdateMode(bool update_origin) {
474 SearchMode::Type type = SearchMode::MODE_DEFAULT; 470 SearchMode::Type type = SearchMode::MODE_DEFAULT;
475 SearchMode::Origin origin = SearchMode::ORIGIN_DEFAULT; 471 SearchMode::Origin origin = SearchMode::ORIGIN_DEFAULT;
476 if (IsNTP(web_contents_)) { 472 if (IsNTP(web_contents_)) {
477 type = SearchMode::MODE_NTP; 473 type = SearchMode::MODE_NTP;
478 origin = SearchMode::ORIGIN_NTP; 474 origin = SearchMode::ORIGIN_NTP;
479 } else if (IsSearchResults(web_contents_)) {
480 type = SearchMode::MODE_SEARCH_RESULTS;
481 origin = SearchMode::ORIGIN_SEARCH;
Peter Kasting 2016/08/13 05:03:44 This is the only non-unittest location that sets t
Marc Treib 2016/08/16 12:00:17 Yup, on my list :) I've added TODOs to the definit
482 } 475 }
483 if (!update_origin) 476 if (!update_origin)
484 origin = model_.mode().origin; 477 origin = model_.mode().origin;
485 478
486 OmniboxView* omnibox = GetOmniboxView(); 479 OmniboxView* omnibox = GetOmniboxView();
487 if (omnibox && omnibox->model()->user_input_in_progress()) 480 if (omnibox && omnibox->model()->user_input_in_progress())
488 type = SearchMode::MODE_SEARCH_SUGGESTIONS; 481 type = SearchMode::MODE_SEARCH_SUGGESTIONS;
489 482
490 SearchMode old_mode(model_.mode()); 483 SearchMode old_mode(model_.mode());
491 model_.SetMode(SearchMode(type, origin)); 484 model_.SetMode(SearchMode(type, origin));
(...skipping 23 matching lines...) Expand all
515 508
516 bool SearchTabHelper::IsInputInProgress() const { 509 bool SearchTabHelper::IsInputInProgress() const {
517 OmniboxView* omnibox = GetOmniboxView(); 510 OmniboxView* omnibox = GetOmniboxView();
518 return !model_.mode().is_ntp() && omnibox && 511 return !model_.mode().is_ntp() && omnibox &&
519 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; 512 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE;
520 } 513 }
521 514
522 OmniboxView* SearchTabHelper::GetOmniboxView() const { 515 OmniboxView* SearchTabHelper::GetOmniboxView() const {
523 return delegate_ ? delegate_->GetOmniboxView() : NULL; 516 return delegate_ ? delegate_->GetOmniboxView() : NULL;
524 } 517 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698