OLD | NEW |
---|---|
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 Loading... | |
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 = | |
79 chrome::GetSearchTermsFromURL(browser_->profile(), url); | |
80 if (search_terms.empty()) | |
81 return false; | |
82 | |
83 InstantSearchPrerenderer* prerenderer = | 76 InstantSearchPrerenderer* prerenderer = |
84 GetInstantSearchPrerenderer(profile()); | 77 GetInstantSearchPrerenderer(profile()); |
85 if (prerenderer) { | 78 if (prerenderer) { |
79 const base::string16& search_terms = | |
80 prerenderer->GetSearchTermsFromURL(url); | |
86 if (prerenderer->CanCommitQuery(GetActiveWebContents(), search_terms)) { | 81 if (prerenderer->CanCommitQuery(GetActiveWebContents(), search_terms)) { |
87 // Submit query to render the prefetched results. Browser will swap the | 82 // Submit query to render the prefetched results. Browser will swap the |
88 // prerendered contents with the active tab contents. | 83 // prerendered contents with the active tab contents. |
89 prerenderer->Commit(search_terms); | 84 prerenderer->Commit(search_terms); |
90 return false; | 85 return false; |
91 } else { | 86 } else { |
92 prerenderer->Cancel(); | 87 prerenderer->Cancel(); |
93 } | 88 } |
94 } | 89 } |
95 | 90 |
91 // If we will not be replacing search terms from this URL, don't send to | |
92 // InstantController. | |
93 const base::string16& search_terms = | |
Jered
2014/02/07 03:02:26
Can we find a way to do this where we don't try to
kmadhusu
2014/02/11 01:40:02
Done.
| |
94 chrome::GetSearchTermsFromURL(browser_->profile(), url); | |
95 if (search_terms.empty()) | |
96 return false; | |
96 return instant_.SubmitQuery(search_terms); | 97 return instant_.SubmitQuery(search_terms); |
97 } | 98 } |
98 | 99 |
99 Profile* BrowserInstantController::profile() const { | 100 Profile* BrowserInstantController::profile() const { |
100 return browser_->profile(); | 101 return browser_->profile(); |
101 } | 102 } |
102 | 103 |
103 content::WebContents* BrowserInstantController::GetActiveWebContents() const { | 104 content::WebContents* BrowserInstantController::GetActiveWebContents() const { |
104 return browser_->tab_strip_model()->GetActiveWebContents(); | 105 return browser_->tab_strip_model()->GetActiveWebContents(); |
105 } | 106 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 content::RenderProcessHost* rph = contents->GetRenderProcessHost(); | 174 content::RenderProcessHost* rph = contents->GetRenderProcessHost(); |
174 instant_service->SendSearchURLsToRenderer(rph); | 175 instant_service->SendSearchURLsToRenderer(rph); |
175 | 176 |
176 // Reload the contents to ensure that it gets assigned to a non-priviledged | 177 // Reload the contents to ensure that it gets assigned to a non-priviledged |
177 // renderer. | 178 // renderer. |
178 if (!instant_service->IsInstantProcess(rph->GetID())) | 179 if (!instant_service->IsInstantProcess(rph->GetID())) |
179 continue; | 180 continue; |
180 contents->GetController().Reload(false); | 181 contents->GetController().Reload(false); |
181 } | 182 } |
182 } | 183 } |
OLD | NEW |