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

Side by Side Diff: chrome/browser/instant/instant_controller.cc

Issue 8329020: Crash fix. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } 224 }
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 // Basic checks to prevent accessing a dangling |tab_contents_| pointer.
235 // http://crbug.com/100521.
236 if (is_out_of_date_ || !loader_.get())
237 return false;
238
234 // If we are not in the HIDDEN field trial, return the status of the preview. 239 // If we are not in the HIDDEN field trial, return the status of the preview.
235 if (!tab_contents_ || 240 if (!InstantFieldTrial::IsHiddenExperiment(tab_contents_->profile()))
236 !InstantFieldTrial::IsHiddenExperiment(tab_contents_->profile())) {
237 return IsCurrent(); 241 return IsCurrent();
238 }
239 242
240 TemplateURLService* model = TemplateURLServiceFactory::GetForProfile( 243 TemplateURLService* model = TemplateURLServiceFactory::GetForProfile(
241 tab_contents_->profile()); 244 tab_contents_->profile());
242 if (!model) 245 if (!model)
243 return false; 246 return false;
244 247
245 const TemplateURL* template_url = model->GetDefaultSearchProvider(); 248 const TemplateURL* template_url = model->GetDefaultSearchProvider();
246 if (is_out_of_date_ || 249 if (!IsValidInstantTemplateURL(template_url) ||
247 !IsValidInstantTemplateURL(template_url) ||
248 !loader_.get() ||
249 loader_->template_url_id() != template_url->id() || 250 loader_->template_url_id() != template_url->id() ||
250 loader_->IsNavigationPending() || 251 loader_->IsNavigationPending() ||
251 loader_->is_determining_if_page_supports_instant()) { 252 loader_->is_determining_if_page_supports_instant()) {
252 return false; 253 return false;
253 } 254 }
254 255
255 // Ignore the suggested text, as we are about to commit the verbatim query. 256 // Ignore the suggested text, as we are about to commit the verbatim query.
256 string16 suggested_text; 257 string16 suggested_text;
257 UpdateLoader(template_url, last_url_, last_transition_type_, last_user_text_, 258 UpdateLoader(template_url, last_url_, last_transition_type_, last_user_text_,
258 true, &suggested_text); 259 true, &suggested_text);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 loader_->MaybeLoadInstantURL(tab_contents, template_url); 387 loader_->MaybeLoadInstantURL(tab_contents, template_url);
387 } 388 }
388 389
389 TabContentsWrapper* InstantController::ReleasePreviewContents( 390 TabContentsWrapper* InstantController::ReleasePreviewContents(
390 InstantCommitType type) { 391 InstantCommitType type) {
391 if (!loader_.get()) 392 if (!loader_.get())
392 return NULL; 393 return NULL;
393 394
394 TabContentsWrapper* tab = loader_->ReleasePreviewContents(type); 395 TabContentsWrapper* tab = loader_->ReleasePreviewContents(type);
395 ClearBlacklist(); 396 ClearBlacklist();
397 is_out_of_date_ = true;
396 is_displayable_ = false; 398 is_displayable_ = false;
397 commit_on_mouse_up_ = false; 399 commit_on_mouse_up_ = false;
398 omnibox_bounds_ = gfx::Rect(); 400 omnibox_bounds_ = gfx::Rect();
399 loader_.reset(); 401 loader_.reset();
400 return tab; 402 return tab;
401 } 403 }
402 404
403 void InstantController::CompleteRelease(TabContentsWrapper* tab) { 405 void InstantController::CompleteRelease(TabContentsWrapper* tab) {
404 tab->blocked_content_tab_helper()->SetAllContentsBlocked(false); 406 tab->blocked_content_tab_helper()->SetAllContentsBlocked(false);
405 } 407 }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 if (destroy_factory_.empty()) { 537 if (destroy_factory_.empty()) {
536 MessageLoop::current()->PostTask( 538 MessageLoop::current()->PostTask(
537 FROM_HERE, destroy_factory_.NewRunnableMethod( 539 FROM_HERE, destroy_factory_.NewRunnableMethod(
538 &InstantController::DestroyLoaders)); 540 &InstantController::DestroyLoaders));
539 } 541 }
540 } 542 }
541 543
542 void InstantController::DestroyLoaders() { 544 void InstantController::DestroyLoaders() {
543 loaders_to_destroy_.reset(); 545 loaders_to_destroy_.reset();
544 } 546 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698