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

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
77 // InstantController.
78 const base::string16& search_terms = 76 const base::string16& search_terms =
79 chrome::GetSearchTermsFromURL(browser_->profile(), url); 77 chrome::ExtractSearchTermsFromURL(profile(), url);
80 if (search_terms.empty()) 78 if (search_terms.empty())
81 return false; 79 return false;
82 80
83 InstantSearchPrerenderer* prerenderer = 81 InstantSearchPrerenderer* prerenderer =
84 GetInstantSearchPrerenderer(profile()); 82 GetInstantSearchPrerenderer(profile());
85 if (prerenderer) { 83 if (prerenderer) {
86 if (prerenderer->CanCommitQuery(GetActiveWebContents(), search_terms)) { 84 if (prerenderer->CanCommitQuery(GetActiveWebContents(), search_terms)) {
87 // Submit query to render the prefetched results. Browser will swap the 85 // Submit query to render the prefetched results. Browser will swap the
88 // prerendered contents with the active tab contents. 86 // prerendered contents with the active tab contents.
89 prerenderer->Commit(search_terms); 87 prerenderer->Commit(search_terms);
90 return false; 88 return false;
91 } else { 89 } else {
92 prerenderer->Cancel(); 90 prerenderer->Cancel();
93 } 91 }
94 } 92 }
95 93
94 // If we will not be replacing search terms from this URL, don't send to
95 // InstantController.
96 if (!chrome::IsQueryExtractionAllowedForURL(profile(), url))
97 return false;
98
96 return instant_.SubmitQuery(search_terms); 99 return instant_.SubmitQuery(search_terms);
97 } 100 }
98 101
99 Profile* BrowserInstantController::profile() const { 102 Profile* BrowserInstantController::profile() const {
100 return browser_->profile(); 103 return browser_->profile();
101 } 104 }
102 105
103 content::WebContents* BrowserInstantController::GetActiveWebContents() const { 106 content::WebContents* BrowserInstantController::GetActiveWebContents() const {
104 return browser_->tab_strip_model()->GetActiveWebContents(); 107 return browser_->tab_strip_model()->GetActiveWebContents();
105 } 108 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 content::RenderProcessHost* rph = contents->GetRenderProcessHost(); 172 content::RenderProcessHost* rph = contents->GetRenderProcessHost();
170 instant_service->SendSearchURLsToRenderer(rph); 173 instant_service->SendSearchURLsToRenderer(rph);
171 174
172 // Reload the contents to ensure that it gets assigned to a non-priviledged 175 // Reload the contents to ensure that it gets assigned to a non-priviledged
173 // renderer. 176 // renderer.
174 if (!instant_service->IsInstantProcess(rph->GetID())) 177 if (!instant_service->IsInstantProcess(rph->GetID()))
175 continue; 178 continue;
176 contents->GetController().Reload(false); 179 contents->GetController().Reload(false);
177 } 180 }
178 } 181 }
OLDNEW
« no previous file with comments | « chrome/browser/search/search_unittest.cc ('k') | chrome/browser/ui/search/instant_search_prerenderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698