| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 return false; | 500 return false; |
| 501 | 501 |
| 502 if (instant_tab_) | 502 if (instant_tab_) |
| 503 instant_tab_->UpOrDownKeyPressed(count); | 503 instant_tab_->UpOrDownKeyPressed(count); |
| 504 else | 504 else |
| 505 overlay_->UpOrDownKeyPressed(count); | 505 overlay_->UpOrDownKeyPressed(count); |
| 506 | 506 |
| 507 return true; | 507 return true; |
| 508 } | 508 } |
| 509 | 509 |
| 510 void InstantController::OnCancel(const AutocompleteMatch& match, |
| 511 const string16& full_text) { |
| 512 if (!extended_enabled_) |
| 513 return; |
| 514 |
| 515 if (!instant_tab_ && !overlay_) |
| 516 return; |
| 517 |
| 518 // We manually reset the state here since the JS is not expected to do it. |
| 519 // TODO(sreeram): Handle the case where user_text is now a URL |
| 520 last_match_was_search_ = AutocompleteMatch::IsSearchType(match.type) && |
| 521 !full_text.empty(); |
| 522 last_omnibox_text_ = full_text; |
| 523 last_suggestion_ = InstantSuggestion(); |
| 524 |
| 525 if (instant_tab_) |
| 526 instant_tab_->CancelSelection(full_text); |
| 527 else |
| 528 overlay_->CancelSelection(full_text); |
| 529 } |
| 530 |
| 510 content::WebContents* InstantController::GetPreviewContents() const { | 531 content::WebContents* InstantController::GetPreviewContents() const { |
| 511 return overlay_ ? overlay_->contents() : NULL; | 532 return overlay_ ? overlay_->contents() : NULL; |
| 512 } | 533 } |
| 513 | 534 |
| 514 bool InstantController::IsPreviewingSearchResults() const { | 535 bool InstantController::IsPreviewingSearchResults() const { |
| 515 return model_.mode().is_search_suggestions() && IsFullHeight(model_) && | 536 return model_.mode().is_search_suggestions() && IsFullHeight(model_) && |
| 516 (last_match_was_search_ || | 537 (last_match_was_search_ || |
| 517 last_suggestion_.behavior == INSTANT_COMPLETE_NEVER); | 538 last_suggestion_.behavior == INSTANT_COMPLETE_NEVER); |
| 518 } | 539 } |
| 519 | 540 |
| (...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1392 delete overlay_->ReleaseContents().release(); | 1413 delete overlay_->ReleaseContents().release(); |
| 1393 MessageLoop::current()->DeleteSoon(FROM_HERE, overlay_.release()); | 1414 MessageLoop::current()->DeleteSoon(FROM_HERE, overlay_.release()); |
| 1394 EnsureOverlayIsCurrent(false); | 1415 EnsureOverlayIsCurrent(false); |
| 1395 } | 1416 } |
| 1396 | 1417 |
| 1397 void InstantController::RemoveFromBlacklist(const std::string& url) { | 1418 void InstantController::RemoveFromBlacklist(const std::string& url) { |
| 1398 if (blacklisted_urls_.erase(url)) { | 1419 if (blacklisted_urls_.erase(url)) { |
| 1399 RecordEventHistogram(INSTANT_CONTROLLER_EVENT_URL_REMOVED_FROM_BLACKLIST); | 1420 RecordEventHistogram(INSTANT_CONTROLLER_EVENT_URL_REMOVED_FROM_BLACKLIST); |
| 1400 } | 1421 } |
| 1401 } | 1422 } |
| OLD | NEW |