Chromium Code Reviews| 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" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 | 67 |
| 68 InstantNTPPrerenderer::~InstantNTPPrerenderer() { | 68 InstantNTPPrerenderer::~InstantNTPPrerenderer() { |
| 69 InstantService* instant_service = | 69 InstantService* instant_service = |
| 70 InstantServiceFactory::GetForProfile(profile_); | 70 InstantServiceFactory::GetForProfile(profile_); |
| 71 if (instant_service) | 71 if (instant_service) |
| 72 instant_service->RemoveObserver(this); | 72 instant_service->RemoveObserver(this); |
| 73 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); | 73 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void InstantNTPPrerenderer::ReloadInstantNTP() { | 76 void InstantNTPPrerenderer::ReloadInstantNTP() { |
| 77 // Stub for unit tests. | |
|
Jered
2013/10/01 20:57:34
This method isn't tested?
samarth
2013/10/02 00:18:00
No, this is necessary because of a random extensio
| |
| 78 if (base::MessageLoop::current()->type() != base::MessageLoop::TYPE_UI) | |
| 79 return; | |
| 80 | |
| 77 ResetNTP(GetInstantURL()); | 81 ResetNTP(GetInstantURL()); |
| 78 } | 82 } |
| 79 | 83 |
| 80 scoped_ptr<content::WebContents> InstantNTPPrerenderer::ReleaseNTPContents() { | 84 scoped_ptr<content::WebContents> InstantNTPPrerenderer::ReleaseNTPContents() { |
| 81 if (!profile_ || profile_->IsOffTheRecord() || | 85 if (!profile_ || profile_->IsOffTheRecord() || |
| 82 !chrome::ShouldShowInstantNTP()) | 86 !chrome::ShouldShowInstantNTP()) |
| 83 return scoped_ptr<content::WebContents>(); | 87 return scoped_ptr<content::WebContents>(); |
| 84 | 88 |
| 85 if (ShouldSwitchToLocalNTP()) | 89 if (ShouldSwitchToLocalNTP()) |
| 86 ResetNTP(GetLocalInstantURL()); | 90 ResetNTP(GetLocalInstantURL()); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 return !(InStartup() && chrome::ShouldPreferRemoteNTPOnStartup()); | 294 return !(InStartup() && chrome::ShouldPreferRemoteNTPOnStartup()); |
| 291 } | 295 } |
| 292 | 296 |
| 293 void InstantNTPPrerenderer::DefaultSearchProviderChanged() { | 297 void InstantNTPPrerenderer::DefaultSearchProviderChanged() { |
| 294 ReloadInstantNTP(); | 298 ReloadInstantNTP(); |
| 295 } | 299 } |
| 296 | 300 |
| 297 void InstantNTPPrerenderer::GoogleURLUpdated() { | 301 void InstantNTPPrerenderer::GoogleURLUpdated() { |
| 298 ReloadInstantNTP(); | 302 ReloadInstantNTP(); |
| 299 } | 303 } |
| OLD | NEW |