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

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: Addressed comments 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);
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);
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
96 return instant_.SubmitQuery(search_terms); 95 // If we will not be replacing search terms from this URL, don't send to
96 // InstantController.
97 return chrome::IsSuitableURLForInstant(browser_profile, url) ?
Jered 2014/02/11 19:10:10 nit: if (!chrome::IsSuitableURLForInstant(browser_
kmadhusu 2014/02/11 23:24:32 Done.
98 instant_.SubmitQuery(search_terms) : false;
97 } 99 }
98 100
99 Profile* BrowserInstantController::profile() const { 101 Profile* BrowserInstantController::profile() const {
100 return browser_->profile(); 102 return browser_->profile();
101 } 103 }
102 104
103 content::WebContents* BrowserInstantController::GetActiveWebContents() const { 105 content::WebContents* BrowserInstantController::GetActiveWebContents() const {
104 return browser_->tab_strip_model()->GetActiveWebContents(); 106 return browser_->tab_strip_model()->GetActiveWebContents();
105 } 107 }
106 108
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 content::RenderProcessHost* rph = contents->GetRenderProcessHost(); 171 content::RenderProcessHost* rph = contents->GetRenderProcessHost();
170 instant_service->SendSearchURLsToRenderer(rph); 172 instant_service->SendSearchURLsToRenderer(rph);
171 173
172 // Reload the contents to ensure that it gets assigned to a non-priviledged 174 // Reload the contents to ensure that it gets assigned to a non-priviledged
173 // renderer. 175 // renderer.
174 if (!instant_service->IsInstantProcess(rph->GetID())) 176 if (!instant_service->IsInstantProcess(rph->GetID()))
175 continue; 177 continue;
176 contents->GetController().Reload(false); 178 contents->GetController().Reload(false);
177 } 179 }
178 } 180 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698