| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/instant/instant_controller.h" | 5 #include "chrome/browser/instant/instant_controller.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 225 |
| 226 bool InstantController::IsCurrent() { | 226 bool InstantController::IsCurrent() { |
| 227 // TODO(mmenke): See if we can do something more intelligent in the | 227 // TODO(mmenke): See if we can do something more intelligent in the |
| 228 // navigation pending case. | 228 // navigation pending case. |
| 229 return is_displayable_ && !loader_->IsNavigationPending() && | 229 return is_displayable_ && !loader_->IsNavigationPending() && |
| 230 !loader_->needs_reload(); | 230 !loader_->needs_reload(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 bool InstantController::PrepareForCommit() { | 233 bool InstantController::PrepareForCommit() { |
| 234 // If we are not in the HIDDEN field trial, return the status of the preview. | 234 // If we are not in the HIDDEN field trial, return the status of the preview. |
| 235 if (!InstantFieldTrial::IsHiddenExperiment(tab_contents_->profile())) | 235 if (!tab_contents_ || |
| 236 !InstantFieldTrial::IsHiddenExperiment(tab_contents_->profile())) { |
| 236 return IsCurrent(); | 237 return IsCurrent(); |
| 238 } |
| 237 | 239 |
| 238 TemplateURLService* model = TemplateURLServiceFactory::GetForProfile( | 240 TemplateURLService* model = TemplateURLServiceFactory::GetForProfile( |
| 239 tab_contents_->profile()); | 241 tab_contents_->profile()); |
| 240 if (!model) | 242 if (!model) |
| 241 return false; | 243 return false; |
| 242 | 244 |
| 243 const TemplateURL* template_url = model->GetDefaultSearchProvider(); | 245 const TemplateURL* template_url = model->GetDefaultSearchProvider(); |
| 244 if (is_out_of_date_ || | 246 if (is_out_of_date_ || |
| 245 !IsValidInstantTemplateURL(template_url) || | 247 !IsValidInstantTemplateURL(template_url) || |
| 246 !loader_.get() || | 248 !loader_.get() || |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 if (destroy_factory_.empty()) { | 539 if (destroy_factory_.empty()) { |
| 538 MessageLoop::current()->PostTask( | 540 MessageLoop::current()->PostTask( |
| 539 FROM_HERE, destroy_factory_.NewRunnableMethod( | 541 FROM_HERE, destroy_factory_.NewRunnableMethod( |
| 540 &InstantController::DestroyLoaders)); | 542 &InstantController::DestroyLoaders)); |
| 541 } | 543 } |
| 542 } | 544 } |
| 543 | 545 |
| 544 void InstantController::DestroyLoaders() { | 546 void InstantController::DestroyLoaders() { |
| 545 loaders_to_destroy_.reset(); | 547 loaders_to_destroy_.reset(); |
| 546 } | 548 } |
| OLD | NEW |