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

Side by Side Diff: chrome/browser/ui/search/instant_controller.cc

Issue 23455047: InstantExtended: Send search URLs to renderers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More browsertest fixes Created 7 years, 2 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/search/instant_controller.h" 5 #include "chrome/browser/ui/search/instant_controller.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/content_settings/content_settings_provider.h" 11 #include "chrome/browser/content_settings/content_settings_provider.h"
12 #include "chrome/browser/content_settings/host_content_settings_map.h" 12 #include "chrome/browser/content_settings/host_content_settings_map.h"
13 #include "chrome/browser/platform_util.h" 13 #include "chrome/browser/platform_util.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/search/instant_service.h" 15 #include "chrome/browser/search/instant_service.h"
16 #include "chrome/browser/search/instant_service_factory.h" 16 #include "chrome/browser/search/instant_service_factory.h"
17 #include "chrome/browser/search/search.h" 17 #include "chrome/browser/search/search.h"
18 #include "chrome/browser/search_engines/search_terms_data.h" 18 #include "chrome/browser/search_engines/search_terms_data.h"
19 #include "chrome/browser/search_engines/template_url_service.h" 19 #include "chrome/browser/search_engines/template_url_service.h"
20 #include "chrome/browser/search_engines/template_url_service_factory.h" 20 #include "chrome/browser/search_engines/template_url_service_factory.h"
21 #include "chrome/browser/ui/browser_instant_controller.h" 21 #include "chrome/browser/ui/browser_instant_controller.h"
22 #include "chrome/browser/ui/search/instant_tab.h" 22 #include "chrome/browser/ui/search/instant_tab.h"
23 #include "chrome/browser/ui/search/search_tab_helper.h" 23 #include "chrome/browser/ui/search/search_tab_helper.h"
24 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/content_settings_types.h" 25 #include "chrome/common/content_settings_types.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "chrome/common/search_urls.h"
27 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
28 #include "components/sessions/serialized_navigation_entry.h" 29 #include "components/sessions/serialized_navigation_entry.h"
29 #include "content/public/browser/navigation_entry.h" 30 #include "content/public/browser/navigation_entry.h"
30 #include "content/public/browser/notification_service.h" 31 #include "content/public/browser/notification_service.h"
31 #include "content/public/browser/render_process_host.h" 32 #include "content/public/browser/render_process_host.h"
32 #include "content/public/browser/render_widget_host_view.h" 33 #include "content/public/browser/render_widget_host_view.h"
33 #include "content/public/browser/user_metrics.h" 34 #include "content/public/browser/user_metrics.h"
34 #include "content/public/browser/web_contents.h" 35 #include "content/public/browser/web_contents.h"
35 #include "content/public/browser/web_contents_view.h" 36 #include "content/public/browser/web_contents_view.h"
36 #include "net/base/escape.h" 37 #include "net/base/escape.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // in by template values). This check is necessary to make sure we don't 150 // in by template values). This check is necessary to make sure we don't
150 // inadvertently redirect to the local NTP if someone, say, reloads a SRP 151 // inadvertently redirect to the local NTP if someone, say, reloads a SRP
151 // while offline, as a committed results page still counts as an instant 152 // while offline, as a committed results page still counts as an instant
152 // url. We also check to make sure there's no forward history, as if 153 // url. We also check to make sure there's no forward history, as if
153 // someone hits the back button a lot when offline and returns to a NTP 154 // someone hits the back button a lot when offline and returns to a NTP
154 // we don't want to redirect and nuke their forward history stack. 155 // we don't want to redirect and nuke their forward history stack.
155 const GURL& current_url = contents->GetURL(); 156 const GURL& current_url = contents->GetURL();
156 GURL instant_url = chrome::GetInstantURL(profile(), 157 GURL instant_url = chrome::GetInstantURL(profile(),
157 chrome::kDisableStartMargin); 158 chrome::kDisableStartMargin);
158 if (instant_tab_->IsLocal() || 159 if (instant_tab_->IsLocal() ||
159 !chrome::MatchesOriginAndPath(instant_url, current_url) || 160 !search::MatchesOriginAndPath(instant_url, current_url) ||
160 !current_url.ref().empty() || 161 !current_url.ref().empty() ||
161 contents->GetController().CanGoForward()) 162 contents->GetController().CanGoForward())
162 return; 163 return;
163 LOG_INSTANT_DEBUG_EVENT(this, "InstantPageLoadFailed: instant_tab"); 164 LOG_INSTANT_DEBUG_EVENT(this, "InstantPageLoadFailed: instant_tab");
164 RedirectToLocalNTP(contents); 165 RedirectToLocalNTP(contents);
165 } 166 }
166 167
167 bool InstantController::SubmitQuery(const string16& search_terms) { 168 bool InstantController::SubmitQuery(const string16& search_terms) {
168 if (instant_tab_ && instant_tab_->supports_instant() && 169 if (instant_tab_ && instant_tab_->supports_instant() &&
169 search_mode_.is_origin_search()) { 170 search_mode_.is_origin_search()) {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 content::PAGE_TRANSITION_SERVER_REDIRECT, 396 content::PAGE_TRANSITION_SERVER_REDIRECT,
396 std::string()); // No extra headers. 397 std::string()); // No extra headers.
397 // TODO(dcblack): Remove extraneous history entry caused by 404s. 398 // TODO(dcblack): Remove extraneous history entry caused by 404s.
398 // Note that the base case of a 204 being returned doesn't push a history 399 // Note that the base case of a 204 being returned doesn't push a history
399 // entry. 400 // entry.
400 } 401 }
401 402
402 InstantService* InstantController::GetInstantService() const { 403 InstantService* InstantController::GetInstantService() const {
403 return InstantServiceFactory::GetForProfile(profile()); 404 return InstantServiceFactory::GetForProfile(profile());
404 } 405 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_instant_controller.cc ('k') | chrome/browser/ui/search/instant_ntp_prerenderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698