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/tab_contents/match_preview.h" | 5 #include "chrome/browser/tab_contents/match_preview.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 enabled = CommandLine::ForCurrentProcess()->HasSwitch( | 447 enabled = CommandLine::ForCurrentProcess()->HasSwitch( |
448 switches::kEnableMatchPreview); | 448 switches::kEnableMatchPreview); |
449 } | 449 } |
450 return enabled; | 450 return enabled; |
451 } | 451 } |
452 | 452 |
453 MatchPreview::MatchPreview(MatchPreviewDelegate* delegate) | 453 MatchPreview::MatchPreview(MatchPreviewDelegate* delegate) |
454 : delegate_(delegate), | 454 : delegate_(delegate), |
455 tab_contents_(NULL), | 455 tab_contents_(NULL), |
456 is_active_(false), | 456 is_active_(false), |
457 template_url_id_(0) { | 457 template_url_id_(0), |
| 458 last_transition_type_(PageTransition::LINK) { |
458 preview_tab_contents_delegate_.reset(new TabContentsDelegateImpl(this)); | 459 preview_tab_contents_delegate_.reset(new TabContentsDelegateImpl(this)); |
459 } | 460 } |
460 | 461 |
461 MatchPreview::~MatchPreview() { | 462 MatchPreview::~MatchPreview() { |
462 // Delete the TabContents before the delegate as the TabContents holds a | 463 // Delete the TabContents before the delegate as the TabContents holds a |
463 // reference to the delegate. | 464 // reference to the delegate. |
464 preview_contents_.reset(NULL); | 465 preview_contents_.reset(NULL); |
465 } | 466 } |
466 | 467 |
467 void MatchPreview::Update(TabContents* tab_contents, | 468 void MatchPreview::Update(TabContents* tab_contents, |
468 const AutocompleteMatch& match, | 469 const AutocompleteMatch& match, |
469 const string16& user_text, | 470 const string16& user_text, |
470 string16* suggested_text) { | 471 string16* suggested_text) { |
471 if (tab_contents != tab_contents_) | 472 if (tab_contents != tab_contents_) |
472 DestroyPreviewContents(); | 473 DestroyPreviewContents(); |
473 | 474 |
474 tab_contents_ = tab_contents; | 475 tab_contents_ = tab_contents; |
| 476 last_transition_type_ = match.transition; |
475 | 477 |
476 if (url_ == match.destination_url) | 478 if (url_ == match.destination_url) |
477 return; | 479 return; |
478 | 480 |
479 url_ = match.destination_url; | 481 url_ = match.destination_url; |
480 | 482 |
481 if (url_.is_empty() || !url_.is_valid()) { | 483 if (url_.is_empty() || !url_.is_valid()) { |
482 DestroyPreviewContents(); | 484 DestroyPreviewContents(); |
483 return; | 485 return; |
484 } | 486 } |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 gfx::Rect MatchPreview::GetOmniboxBoundsInTermsOfPreview() { | 642 gfx::Rect MatchPreview::GetOmniboxBoundsInTermsOfPreview() { |
641 if (omnibox_bounds_.IsEmpty()) | 643 if (omnibox_bounds_.IsEmpty()) |
642 return omnibox_bounds_; | 644 return omnibox_bounds_; |
643 | 645 |
644 gfx::Rect preview_bounds(delegate_->GetMatchPreviewBounds()); | 646 gfx::Rect preview_bounds(delegate_->GetMatchPreviewBounds()); |
645 return gfx::Rect(omnibox_bounds_.x() - preview_bounds.x(), | 647 return gfx::Rect(omnibox_bounds_.x() - preview_bounds.x(), |
646 omnibox_bounds_.y() - preview_bounds.y(), | 648 omnibox_bounds_.y() - preview_bounds.y(), |
647 omnibox_bounds_.width(), | 649 omnibox_bounds_.width(), |
648 omnibox_bounds_.height()); | 650 omnibox_bounds_.height()); |
649 } | 651 } |
OLD | NEW |