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

Side by Side Diff: chrome/browser/ui/browser_instant_controller.cc

Issue 609493002: Propagate the search request params from the browser to the Instant search base page to fix the embe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: '' Created 6 years, 1 month 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/browser_instant_controller.h" 5 #include "chrome/browser/ui/browser_instant_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/infobars/infobar_service.h" 8 #include "chrome/browser/infobars/infobar_service.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/search/instant_service.h" 10 #include "chrome/browser/search/instant_service.h"
11 #include "chrome/browser/search/instant_service_factory.h" 11 #include "chrome/browser/search/instant_service_factory.h"
12 #include "chrome/browser/search/search.h" 12 #include "chrome/browser/search/search.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_window.h" 14 #include "chrome/browser/ui/browser_window.h"
15 #include "chrome/browser/ui/location_bar/location_bar.h" 15 #include "chrome/browser/ui/location_bar/location_bar.h"
16 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" 16 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
17 #include "chrome/browser/ui/omnibox/omnibox_view.h" 17 #include "chrome/browser/ui/omnibox/omnibox_view.h"
18 #include "chrome/browser/ui/search/instant_search_prerenderer.h" 18 #include "chrome/browser/ui/search/instant_search_prerenderer.h"
19 #include "chrome/browser/ui/search/search_model.h" 19 #include "chrome/browser/ui/search/search_model.h"
20 #include "chrome/browser/ui/search/search_tab_helper.h" 20 #include "chrome/browser/ui/search/search_tab_helper.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" 21 #include "chrome/browser/ui/tabs/tab_strip_model.h"
22 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
23 #include "content/public/browser/render_process_host.h" 23 #include "content/public/browser/render_process_host.h"
24 #include "content/public/browser/user_metrics.h" 24 #include "content/public/browser/user_metrics.h"
25 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
26 26
Mark P 2014/11/17 19:15:58 please include instant_types directly.
kmadhusu 2014/11/17 22:52:05 Done.
27 27
28 // Helpers -------------------------------------------------------------------- 28 // Helpers --------------------------------------------------------------------
29 29
30 namespace { 30 namespace {
31 31
32 InstantSearchPrerenderer* GetInstantSearchPrerenderer(Profile* profile) { 32 InstantSearchPrerenderer* GetInstantSearchPrerenderer(Profile* profile) {
33 DCHECK(profile); 33 DCHECK(profile);
34 InstantService* instant_service = 34 InstantService* instant_service =
35 InstantServiceFactory::GetForProfile(profile); 35 InstantServiceFactory::GetForProfile(profile);
36 return instant_service ? instant_service->instant_search_prerenderer() : NULL; 36 return instant_service ? instant_service->instant_search_prerenderer() : NULL;
(...skipping 29 matching lines...) Expand all
66 disposition == NEW_FOREGROUND_TAB) 66 disposition == NEW_FOREGROUND_TAB)
67 return false; 67 return false;
68 68
69 // The omnibox currently doesn't use other dispositions, so we don't attempt 69 // The omnibox currently doesn't use other dispositions, so we don't attempt
70 // to handle them. If you hit this DCHECK file a bug and I'll (sky) add 70 // to handle them. If you hit this DCHECK file a bug and I'll (sky) add
71 // support for the new disposition. 71 // support for the new disposition.
72 DCHECK(disposition == CURRENT_TAB) << disposition; 72 DCHECK(disposition == CURRENT_TAB) << disposition;
73 73
74 const base::string16& search_terms = 74 const base::string16& search_terms =
75 chrome::ExtractSearchTermsFromURL(profile(), url); 75 chrome::ExtractSearchTermsFromURL(profile(), url);
76 EmbeddedSearchRequestParams request_params(url);
76 if (search_terms.empty()) 77 if (search_terms.empty())
77 return false; 78 return false;
78 79
79 InstantSearchPrerenderer* prerenderer = 80 InstantSearchPrerenderer* prerenderer =
80 GetInstantSearchPrerenderer(profile()); 81 GetInstantSearchPrerenderer(profile());
81 if (prerenderer) { 82 if (prerenderer) {
82 if (prerenderer->CanCommitQuery(GetActiveWebContents(), search_terms)) { 83 if (prerenderer->CanCommitQuery(GetActiveWebContents(), search_terms)) {
83 // Submit query to render the prefetched results. Browser will swap the 84 // Submit query to render the prefetched results. Browser will swap the
84 // prerendered contents with the active tab contents. 85 // prerendered contents with the active tab contents.
85 prerenderer->Commit(search_terms); 86 prerenderer->Commit(search_terms, request_params);
86 return false; 87 return false;
87 } else { 88 } else {
88 prerenderer->Cancel(); 89 prerenderer->Cancel();
89 } 90 }
90 } 91 }
91 92
92 // If we will not be replacing search terms from this URL, don't send to 93 // If we will not be replacing search terms from this URL, don't send to
93 // InstantController. 94 // InstantController.
94 if (!chrome::IsQueryExtractionAllowedForURL(profile(), url)) 95 if (!chrome::IsQueryExtractionAllowedForURL(profile(), url))
95 return false; 96 return false;
96 97 return instant_.SubmitQuery(search_terms, request_params);
97 return instant_.SubmitQuery(search_terms);
98 } 98 }
99 99
100 Profile* BrowserInstantController::profile() const { 100 Profile* BrowserInstantController::profile() const {
101 return browser_->profile(); 101 return browser_->profile();
102 } 102 }
103 103
104 content::WebContents* BrowserInstantController::GetActiveWebContents() const { 104 content::WebContents* BrowserInstantController::GetActiveWebContents() const {
105 return browser_->tab_strip_model()->GetActiveWebContents(); 105 return browser_->tab_strip_model()->GetActiveWebContents();
106 } 106 }
107 107
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 163
164 contents->GetController().Reload(false); 164 contents->GetController().Reload(false);
165 165
166 // As the reload was not triggered by the user we don't want to close any 166 // As the reload was not triggered by the user we don't want to close any
167 // infobars. We have to tell the InfoBarService after the reload, otherwise 167 // infobars. We have to tell the InfoBarService after the reload, otherwise
168 // it would ignore this call when 168 // it would ignore this call when
169 // WebContentsObserver::DidStartNavigationToPendingEntry is invoked. 169 // WebContentsObserver::DidStartNavigationToPendingEntry is invoked.
170 InfoBarService::FromWebContents(contents)->set_ignore_next_reload(); 170 InfoBarService::FromWebContents(contents)->set_ignore_next_reload();
171 } 171 }
172 } 172 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698