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

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

Issue 141893009: Create a new helper function to extract search terms from the URL irrespective of the availablility (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 10 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/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/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_web_ui.h" 9 #include "chrome/browser/extensions/extension_web_ui.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // Unsupported dispositions. 66 // Unsupported dispositions.
67 if (disposition == NEW_BACKGROUND_TAB || disposition == NEW_WINDOW || 67 if (disposition == NEW_BACKGROUND_TAB || disposition == NEW_WINDOW ||
68 disposition == NEW_FOREGROUND_TAB) 68 disposition == NEW_FOREGROUND_TAB)
69 return false; 69 return false;
70 70
71 // The omnibox currently doesn't use other dispositions, so we don't attempt 71 // The omnibox currently doesn't use other dispositions, so we don't attempt
72 // to handle them. If you hit this DCHECK file a bug and I'll (sky) add 72 // to handle them. If you hit this DCHECK file a bug and I'll (sky) add
73 // support for the new disposition. 73 // support for the new disposition.
74 DCHECK(disposition == CURRENT_TAB) << disposition; 74 DCHECK(disposition == CURRENT_TAB) << disposition;
75 75
76 // If we will not be replacing search terms from this URL, don't send to 76 Profile* browser_profile = profile();
77 // InstantController.
78 const base::string16& search_terms = 77 const base::string16& search_terms =
79 chrome::GetSearchTermsFromURL(browser_->profile(), url); 78 chrome::ExtractSearchTermsFromURL(browser_profile, url);
samarth 2014/02/12 18:02:39 nit: just use profile() here?
kmadhusu 2014/02/12 19:58:09 Done.
80 if (search_terms.empty()) 79 if (search_terms.empty())
81 return false; 80 return false;
82 81
83 InstantSearchPrerenderer* prerenderer = 82 InstantSearchPrerenderer* prerenderer =
84 GetInstantSearchPrerenderer(profile()); 83 GetInstantSearchPrerenderer(browser_profile);
samarth 2014/02/12 18:02:39 Likewise here and below
kmadhusu 2014/02/12 19:58:09 Done.
85 if (prerenderer) { 84 if (prerenderer) {
86 if (prerenderer->CanCommitQuery(GetActiveWebContents(), search_terms)) { 85 if (prerenderer->CanCommitQuery(GetActiveWebContents(), search_terms)) {
87 // Submit query to render the prefetched results. Browser will swap the 86 // Submit query to render the prefetched results. Browser will swap the
88 // prerendered contents with the active tab contents. 87 // prerendered contents with the active tab contents.
89 prerenderer->Commit(search_terms); 88 prerenderer->Commit(search_terms);
90 return false; 89 return false;
91 } else { 90 } else {
92 prerenderer->Cancel(); 91 prerenderer->Cancel();
93 } 92 }
94 } 93 }
95 94
95 // If we will not be replacing search terms from this URL, don't send to
96 // InstantController.
97 if (!chrome::IsQueryExtractionAllowedForURL(browser_profile, url))
98 return false;
99
96 return instant_.SubmitQuery(search_terms); 100 return instant_.SubmitQuery(search_terms);
97 } 101 }
98 102
99 Profile* BrowserInstantController::profile() const { 103 Profile* BrowserInstantController::profile() const {
100 return browser_->profile(); 104 return browser_->profile();
101 } 105 }
102 106
103 content::WebContents* BrowserInstantController::GetActiveWebContents() const { 107 content::WebContents* BrowserInstantController::GetActiveWebContents() const {
104 return browser_->tab_strip_model()->GetActiveWebContents(); 108 return browser_->tab_strip_model()->GetActiveWebContents();
105 } 109 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 content::RenderProcessHost* rph = contents->GetRenderProcessHost(); 173 content::RenderProcessHost* rph = contents->GetRenderProcessHost();
170 instant_service->SendSearchURLsToRenderer(rph); 174 instant_service->SendSearchURLsToRenderer(rph);
171 175
172 // Reload the contents to ensure that it gets assigned to a non-priviledged 176 // Reload the contents to ensure that it gets assigned to a non-priviledged
173 // renderer. 177 // renderer.
174 if (!instant_service->IsInstantProcess(rph->GetID())) 178 if (!instant_service->IsInstantProcess(rph->GetID()))
175 continue; 179 continue;
176 contents->GetController().Reload(false); 180 contents->GetController().Reload(false);
177 } 181 }
178 } 182 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698