| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_ntp_prerenderer.h" | 5 #include "chrome/browser/ui/search/instant_ntp_prerenderer.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
| 13 #include "chrome/browser/content_settings/content_settings_provider.h" | 13 #include "chrome/browser/content_settings/content_settings_provider.h" |
| 14 #include "chrome/browser/content_settings/host_content_settings_map.h" | 14 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/search/instant_service.h" | 16 #include "chrome/browser/search/instant_service.h" |
| 17 #include "chrome/browser/search/instant_service_factory.h" | 17 #include "chrome/browser/search/instant_service_factory.h" |
| 18 #include "chrome/browser/search/search.h" | 18 #include "chrome/browser/search/search.h" |
| 19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
| 21 #include "chrome/browser/ui/host_desktop.h" | 21 #include "chrome/browser/ui/host_desktop.h" |
| 22 #include "chrome/browser/ui/search/instant_ntp.h" | 22 #include "chrome/browser/ui/search/instant_ntp.h" |
| 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 24 #include "chrome/common/content_settings.h" | 24 #include "chrome/common/content_settings.h" |
| 25 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 26 #include "chrome/common/search_urls.h" |
| 26 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
| 27 #include "content/public/browser/render_process_host.h" | 28 #include "content/public/browser/render_process_host.h" |
| 28 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
| 29 #include "net/base/network_change_notifier.h" | 30 #include "net/base/network_change_notifier.h" |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 void DeleteNTPSoon(scoped_ptr<InstantNTP> ntp) { | 34 void DeleteNTPSoon(scoped_ptr<InstantNTP> ntp) { |
| 34 if (!ntp) | 35 if (!ntp) |
| 35 return; | 36 return; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 // non-empty URL to use. | 255 // non-empty URL to use. |
| 255 DCHECK(!instant_url.empty()); | 256 DCHECK(!instant_url.empty()); |
| 256 ntp_.reset(new InstantNTP(this, instant_url, profile_)); | 257 ntp_.reset(new InstantNTP(this, instant_url, profile_)); |
| 257 ntp_->InitContents(base::Bind(&InstantNTPPrerenderer::ReloadInstantNTP, | 258 ntp_->InitContents(base::Bind(&InstantNTPPrerenderer::ReloadInstantNTP, |
| 258 base::Unretained(this))); | 259 base::Unretained(this))); |
| 259 } | 260 } |
| 260 | 261 |
| 261 bool InstantNTPPrerenderer::PageIsCurrent() const { | 262 bool InstantNTPPrerenderer::PageIsCurrent() const { |
| 262 const std::string& instant_url = GetInstantURL(); | 263 const std::string& instant_url = GetInstantURL(); |
| 263 if (instant_url.empty() || | 264 if (instant_url.empty() || |
| 264 !chrome::MatchesOriginAndPath(GURL(ntp()->instant_url()), | 265 !search::MatchesOriginAndPath(GURL(ntp()->instant_url()), |
| 265 GURL(instant_url))) | 266 GURL(instant_url))) |
| 266 return false; | 267 return false; |
| 267 | 268 |
| 268 return ntp()->supports_instant(); | 269 return ntp()->supports_instant(); |
| 269 } | 270 } |
| 270 | 271 |
| 271 bool InstantNTPPrerenderer::ShouldSwitchToLocalNTP() const { | 272 bool InstantNTPPrerenderer::ShouldSwitchToLocalNTP() const { |
| 272 if (!ntp()) | 273 if (!ntp()) |
| 273 return true; | 274 return true; |
| 274 | 275 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 290 return !(InStartup() && chrome::ShouldPreferRemoteNTPOnStartup()); | 291 return !(InStartup() && chrome::ShouldPreferRemoteNTPOnStartup()); |
| 291 } | 292 } |
| 292 | 293 |
| 293 void InstantNTPPrerenderer::DefaultSearchProviderChanged() { | 294 void InstantNTPPrerenderer::DefaultSearchProviderChanged() { |
| 294 ReloadInstantNTP(); | 295 ReloadInstantNTP(); |
| 295 } | 296 } |
| 296 | 297 |
| 297 void InstantNTPPrerenderer::GoogleURLUpdated() { | 298 void InstantNTPPrerenderer::GoogleURLUpdated() { |
| 298 ReloadInstantNTP(); | 299 ReloadInstantNTP(); |
| 299 } | 300 } |
| OLD | NEW |