OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 CommitCurrentPreview(INSTANT_COMMIT_FOCUS_LOST); | 364 CommitCurrentPreview(INSTANT_COMMIT_FOCUS_LOST); |
365 } else { | 365 } else { |
366 // This can happen if the mouse was down, we swapped out the preview and | 366 // This can happen if the mouse was down, we swapped out the preview and |
367 // the mouse was released. Generally this shouldn't happen, but if it does | 367 // the mouse was released. Generally this shouldn't happen, but if it does |
368 // revert. | 368 // revert. |
369 DestroyPreviewContents(); | 369 DestroyPreviewContents(); |
370 } | 370 } |
371 } | 371 } |
372 | 372 |
373 void InstantController::InstantLoaderDoesntSupportInstant( | 373 void InstantController::InstantLoaderDoesntSupportInstant( |
374 InstantLoader* loader, | 374 InstantLoader* loader) { |
375 bool needs_reload, | |
376 const GURL& url_to_load) { | |
377 DCHECK(!loader->ready()); // We better not be showing this loader. | 375 DCHECK(!loader->ready()); // We better not be showing this loader. |
378 DCHECK(loader->template_url_id()); | 376 DCHECK(loader->template_url_id()); |
379 | 377 |
| 378 VLOG(1) << " provider does not support instant"; |
| 379 |
| 380 // Don't attempt to use instant for this search engine again. |
380 BlacklistFromInstant(loader->template_url_id()); | 381 BlacklistFromInstant(loader->template_url_id()); |
381 | 382 |
382 if (loader_manager_->active_loader() == loader) { | 383 if (loader_manager_->active_loader() == loader) { |
383 // The loader is active. Continue to use it, but make sure it isn't tied to | 384 // The loader is active, shut down instant. |
384 // to the search engine anymore. ClearTemplateURLID ends up showing the | 385 DestroyPreviewContents(); |
385 // loader. | 386 } else { |
386 loader_manager_->RemoveLoaderFromInstant(loader); | 387 if (loader_manager_->current_loader() == loader && is_active_) { |
387 loader->ClearTemplateURLID(); | 388 // There is a pending loader and we're active. Hide the preview. When then |
388 | 389 // pending loader finishes loading we'll notify the delegate to show. |
389 if (needs_reload) { | 390 DCHECK(loader_manager_->pending_loader()); |
390 string16 suggested_text; | 391 is_active_ = false; |
391 loader->Update(tab_contents_, 0, url_to_load, last_transition_type_, | 392 delegate_->HideInstant(); |
392 loader->user_text(), false, &suggested_text); | |
393 } | 393 } |
394 } else { | |
395 loader_manager_->DestroyLoader(loader); | 394 loader_manager_->DestroyLoader(loader); |
396 loader = NULL; | |
397 } | 395 } |
398 } | 396 } |
399 | 397 |
400 void InstantController::AddToBlacklist(InstantLoader* loader, const GURL& url) { | 398 void InstantController::AddToBlacklist(InstantLoader* loader, const GURL& url) { |
401 std::string host = url.host(); | 399 std::string host = url.host(); |
402 if (host.empty()) | 400 if (host.empty()) |
403 return; | 401 return; |
404 | 402 |
405 if (!host_blacklist_) | 403 if (!host_blacklist_) |
406 host_blacklist_ = new HostBlacklist; | 404 host_blacklist_ = new HostBlacklist; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 return "Predictive"; | 602 return "Predictive"; |
605 case VERBATIM_TYPE: | 603 case VERBATIM_TYPE: |
606 return "Verbatim"; | 604 return "Verbatim"; |
607 case PREDICTIVE_NO_AUTO_COMPLETE_TYPE: | 605 case PREDICTIVE_NO_AUTO_COMPLETE_TYPE: |
608 return "PredictiveNoAutoComplete"; | 606 return "PredictiveNoAutoComplete"; |
609 default: | 607 default: |
610 NOTREACHED(); | 608 NOTREACHED(); |
611 return std::string(); | 609 return std::string(); |
612 } | 610 } |
613 } | 611 } |
OLD | NEW |