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

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

Issue 11889003: Fixing ESC in instant-extended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added issue number to TODO. Created 7 years, 10 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
OLDNEW
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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 return false; 502 return false;
503 503
504 if (instant_tab_) 504 if (instant_tab_)
505 instant_tab_->UpOrDownKeyPressed(count); 505 instant_tab_->UpOrDownKeyPressed(count);
506 else 506 else
507 overlay_->UpOrDownKeyPressed(count); 507 overlay_->UpOrDownKeyPressed(count);
508 508
509 return true; 509 return true;
510 } 510 }
511 511
512 void InstantController::OnCancel(const AutocompleteMatch& match,
513 const string16& full_text) {
514 if (!extended_enabled_)
515 return;
516
517 if (!instant_tab_ && !overlay_)
518 return;
519
520 // We manually reset the state here since the JS is not expected to do it.
521 // TODO(sreeram): Handle the case where user_text is now a URL
522 last_match_was_search_ = AutocompleteMatch::IsSearchType(match.type) &&
523 !full_text.empty();
524 last_omnibox_text_ = full_text;
525 last_suggestion_ = InstantSuggestion();
526
527 if (instant_tab_)
528 instant_tab_->CancelSelection(full_text);
529 else
530 overlay_->CancelSelection(full_text);
531 }
532
512 content::WebContents* InstantController::GetPreviewContents() const { 533 content::WebContents* InstantController::GetPreviewContents() const {
513 return overlay_ ? overlay_->contents() : NULL; 534 return overlay_ ? overlay_->contents() : NULL;
514 } 535 }
515 536
516 bool InstantController::IsPreviewingSearchResults() const { 537 bool InstantController::IsPreviewingSearchResults() const {
517 return model_.mode().is_search_suggestions() && IsFullHeight(model_) && 538 return model_.mode().is_search_suggestions() && IsFullHeight(model_) &&
518 (last_match_was_search_ || 539 (last_match_was_search_ ||
519 last_suggestion_.behavior == INSTANT_COMPLETE_NEVER); 540 last_suggestion_.behavior == INSTANT_COMPLETE_NEVER);
520 } 541 }
521 542
522 bool InstantController::CommitIfPossible(InstantCommitType type) { 543 bool InstantController::CommitIfPossible(InstantCommitType type) {
523 if (!extended_enabled_ && !instant_enabled_) 544 if (!extended_enabled_ && !instant_enabled_)
524 return false; 545 return false;
525
sreeram 2013/02/14 17:56:41 Nit: Don't remove this blank line.
526 LOG_INSTANT_DEBUG_EVENT(this, base::StringPrintf( 546 LOG_INSTANT_DEBUG_EVENT(this, base::StringPrintf(
527 "CommitIfPossible: type=%d last_omnibox_text_='%s' " 547 "CommitIfPossible: type=%d last_omnibox_text_='%s' "
528 "last_match_was_search_=%d instant_tab_=%d", type, 548 "last_match_was_search_=%d instant_tab_=%d", type,
529 UTF16ToUTF8(last_omnibox_text_).c_str(), last_match_was_search_, 549 UTF16ToUTF8(last_omnibox_text_).c_str(), last_match_was_search_,
530 instant_tab_ != NULL)); 550 instant_tab_ != NULL));
531 551
532 // If we are on an already committed search results page, send a submit event 552 // If we are on an already committed search results page, send a submit event
533 // to the page, but otherwise, nothing else to do. 553 // to the page, but otherwise, nothing else to do.
534 if (instant_tab_) { 554 if (instant_tab_) {
535 if (type == INSTANT_COMMIT_PRESSED_ENTER && 555 if (type == INSTANT_COMMIT_PRESSED_ENTER &&
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 delete overlay_->ReleaseContents().release(); 1418 delete overlay_->ReleaseContents().release();
1399 MessageLoop::current()->DeleteSoon(FROM_HERE, overlay_.release()); 1419 MessageLoop::current()->DeleteSoon(FROM_HERE, overlay_.release());
1400 EnsureOverlayIsCurrent(false); 1420 EnsureOverlayIsCurrent(false);
1401 } 1421 }
1402 1422
1403 void InstantController::RemoveFromBlacklist(const std::string& url) { 1423 void InstantController::RemoveFromBlacklist(const std::string& url) {
1404 if (blacklisted_urls_.erase(url)) { 1424 if (blacklisted_urls_.erase(url)) {
1405 RecordEventHistogram(INSTANT_CONTROLLER_EVENT_URL_REMOVED_FROM_BLACKLIST); 1425 RecordEventHistogram(INSTANT_CONTROLLER_EVENT_URL_REMOVED_FROM_BLACKLIST);
1406 } 1426 }
1407 } 1427 }
OLDNEW
« no previous file with comments | « chrome/browser/instant/instant_controller.h ('k') | chrome/browser/instant/instant_extended_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698