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

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: Rebase 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
« no previous file with comments | « chrome/browser/android/tab_android.cc ('k') | chrome/browser/ui/search/instant_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/instant_types.h"
22 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
23 #include "content/public/browser/render_process_host.h" 24 #include "content/public/browser/render_process_host.h"
24 #include "content/public/browser/user_metrics.h" 25 #include "content/public/browser/user_metrics.h"
25 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
26 27
27 28
28 // Helpers -------------------------------------------------------------------- 29 // Helpers --------------------------------------------------------------------
29 30
30 namespace { 31 namespace {
31 32
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 disposition == NEW_FOREGROUND_TAB) 67 disposition == NEW_FOREGROUND_TAB)
67 return false; 68 return false;
68 69
69 // The omnibox currently doesn't use other dispositions, so we don't attempt 70 // 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 71 // to handle them. If you hit this DCHECK file a bug and I'll (sky) add
71 // support for the new disposition. 72 // support for the new disposition.
72 DCHECK(disposition == CURRENT_TAB) << disposition; 73 DCHECK(disposition == CURRENT_TAB) << disposition;
73 74
74 const base::string16& search_terms = 75 const base::string16& search_terms =
75 chrome::ExtractSearchTermsFromURL(profile(), url); 76 chrome::ExtractSearchTermsFromURL(profile(), url);
77 EmbeddedSearchRequestParams request_params(url);
76 if (search_terms.empty()) 78 if (search_terms.empty())
77 return false; 79 return false;
78 80
79 InstantSearchPrerenderer* prerenderer = 81 InstantSearchPrerenderer* prerenderer =
80 GetInstantSearchPrerenderer(profile()); 82 GetInstantSearchPrerenderer(profile());
81 if (prerenderer) { 83 if (prerenderer) {
82 if (prerenderer->CanCommitQuery(GetActiveWebContents(), search_terms)) { 84 if (prerenderer->CanCommitQuery(GetActiveWebContents(), search_terms)) {
83 // Submit query to render the prefetched results. Browser will swap the 85 // Submit query to render the prefetched results. Browser will swap the
84 // prerendered contents with the active tab contents. 86 // prerendered contents with the active tab contents.
85 prerenderer->Commit(search_terms); 87 prerenderer->Commit(search_terms, request_params);
86 return false; 88 return false;
87 } else { 89 } else {
88 prerenderer->Cancel(); 90 prerenderer->Cancel();
89 } 91 }
90 } 92 }
91 93
92 // If we will not be replacing search terms from this URL, don't send to 94 // If we will not be replacing search terms from this URL, don't send to
93 // InstantController. 95 // InstantController.
94 if (!chrome::IsQueryExtractionAllowedForURL(profile(), url)) 96 if (!chrome::IsQueryExtractionAllowedForURL(profile(), url))
95 return false; 97 return false;
96 98 return instant_.SubmitQuery(search_terms, request_params);
97 return instant_.SubmitQuery(search_terms);
98 } 99 }
99 100
100 Profile* BrowserInstantController::profile() const { 101 Profile* BrowserInstantController::profile() const {
101 return browser_->profile(); 102 return browser_->profile();
102 } 103 }
103 104
104 content::WebContents* BrowserInstantController::GetActiveWebContents() const { 105 content::WebContents* BrowserInstantController::GetActiveWebContents() const {
105 return browser_->tab_strip_model()->GetActiveWebContents(); 106 return browser_->tab_strip_model()->GetActiveWebContents();
106 } 107 }
107 108
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 164
164 contents->GetController().Reload(false); 165 contents->GetController().Reload(false);
165 166
166 // As the reload was not triggered by the user we don't want to close any 167 // 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 168 // infobars. We have to tell the InfoBarService after the reload, otherwise
168 // it would ignore this call when 169 // it would ignore this call when
169 // WebContentsObserver::DidStartNavigationToPendingEntry is invoked. 170 // WebContentsObserver::DidStartNavigationToPendingEntry is invoked.
170 InfoBarService::FromWebContents(contents)->set_ignore_next_reload(); 171 InfoBarService::FromWebContents(contents)->set_ignore_next_reload();
171 } 172 }
172 } 173 }
OLDNEW
« no previous file with comments | « chrome/browser/android/tab_android.cc ('k') | chrome/browser/ui/search/instant_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698