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

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

Issue 8892011: Clean up TCW, make it solely a hub for 1:1 observer/helper objects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 | « chrome/browser/instant/instant_controller.cc ('k') | chrome/browser/omnibox_search_hint.cc » ('j') | 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_loader.h" 5 #include "chrome/browser/instant/instant_loader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 loader_(loader), 283 loader_(loader),
284 registered_render_widget_host_(NULL), 284 registered_render_widget_host_(NULL),
285 waiting_for_new_page_(true), 285 waiting_for_new_page_(true),
286 is_mouse_down_from_activate_(false), 286 is_mouse_down_from_activate_(false),
287 user_typed_before_load_(false) { 287 user_typed_before_load_(false) {
288 DCHECK(loader->preview_contents()); 288 DCHECK(loader->preview_contents());
289 registrar_.Add(this, content::NOTIFICATION_INTERSTITIAL_ATTACHED, 289 registrar_.Add(this, content::NOTIFICATION_INTERSTITIAL_ATTACHED,
290 content::Source<TabContents>(loader->preview_contents()->tab_contents())); 290 content::Source<TabContents>(loader->preview_contents()->tab_contents()));
291 registrar_.Add(this, content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR, 291 registrar_.Add(this, content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR,
292 content::Source<NavigationController>( 292 content::Source<NavigationController>(
293 &loader->preview_contents()->controller())); 293 &loader->preview_contents()->tab_contents()->controller()));
294 } 294 }
295 295
296 void InstantLoader::TabContentsDelegateImpl::PrepareForNewLoad() { 296 void InstantLoader::TabContentsDelegateImpl::PrepareForNewLoad() {
297 user_typed_before_load_ = false; 297 user_typed_before_load_ = false;
298 waiting_for_new_page_ = true; 298 waiting_for_new_page_ = true;
299 add_page_vector_.clear(); 299 add_page_vector_.clear();
300 UnregisterForPaintNotifications(); 300 UnregisterForPaintNotifications();
301 } 301 }
302 302
303 void InstantLoader::TabContentsDelegateImpl::PreviewPainted() { 303 void InstantLoader::TabContentsDelegateImpl::PreviewPainted() {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 IPC_MESSAGE_UNHANDLED(handled = false) 540 IPC_MESSAGE_UNHANDLED(handled = false)
541 IPC_END_MESSAGE_MAP() 541 IPC_END_MESSAGE_MAP()
542 return handled; 542 return handled;
543 } 543 }
544 544
545 void InstantLoader::TabContentsDelegateImpl::OnSetSuggestions( 545 void InstantLoader::TabContentsDelegateImpl::OnSetSuggestions(
546 int32 page_id, 546 int32 page_id,
547 const std::vector<std::string>& suggestions, 547 const std::vector<std::string>& suggestions,
548 InstantCompleteBehavior behavior) { 548 InstantCompleteBehavior behavior) {
549 TabContentsWrapper* source = loader_->preview_contents(); 549 TabContentsWrapper* source = loader_->preview_contents();
550 if (!source->controller().GetActiveEntry() || 550 if (!source->tab_contents()->controller().GetActiveEntry() ||
551 page_id != source->controller().GetActiveEntry()->page_id()) 551 page_id !=
552 source->tab_contents()->controller().GetActiveEntry()->page_id()) {
552 return; 553 return;
554 }
553 555
554 if (suggestions.empty()) 556 if (suggestions.empty())
555 loader_->SetCompleteSuggestedText(string16(), behavior); 557 loader_->SetCompleteSuggestedText(string16(), behavior);
556 else 558 else
557 loader_->SetCompleteSuggestedText(UTF8ToUTF16(suggestions[0]), behavior); 559 loader_->SetCompleteSuggestedText(UTF8ToUTF16(suggestions[0]), behavior);
558 } 560 }
559 561
560 void InstantLoader::TabContentsDelegateImpl::OnInstantSupportDetermined( 562 void InstantLoader::TabContentsDelegateImpl::OnInstantSupportDetermined(
561 int32 page_id, 563 int32 page_id,
562 bool result) { 564 bool result) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 if (!created_preview_contents) { 663 if (!created_preview_contents) {
662 if (is_determining_if_page_supports_instant()) { 664 if (is_determining_if_page_supports_instant()) {
663 // The page hasn't loaded yet. We'll send the script down when it does. 665 // The page hasn't loaded yet. We'll send the script down when it does.
664 frame_load_observer_->set_text(user_text_); 666 frame_load_observer_->set_text(user_text_);
665 frame_load_observer_->set_verbatim(verbatim); 667 frame_load_observer_->set_verbatim(verbatim);
666 preview_tab_contents_delegate_->set_user_typed_before_load(); 668 preview_tab_contents_delegate_->set_user_typed_before_load();
667 return true; 669 return true;
668 } 670 }
669 // TODO: support real cursor position. 671 // TODO: support real cursor position.
670 int text_length = static_cast<int>(user_text_.size()); 672 int text_length = static_cast<int>(user_text_.size());
671 RenderViewHost* host = preview_contents_->render_view_host(); 673 RenderViewHost* host =
674 preview_contents_->tab_contents()->render_view_host();
672 host->Send(new ChromeViewMsg_SearchBoxChange( 675 host->Send(new ChromeViewMsg_SearchBoxChange(
673 host->routing_id(), user_text_, verbatim, text_length, text_length)); 676 host->routing_id(), user_text_, verbatim, text_length, text_length));
674 677
675 string16 complete_suggested_text_lower = base::i18n::ToLower( 678 string16 complete_suggested_text_lower = base::i18n::ToLower(
676 complete_suggested_text_); 679 complete_suggested_text_);
677 string16 user_text_lower = base::i18n::ToLower(user_text_); 680 string16 user_text_lower = base::i18n::ToLower(user_text_);
678 if (!verbatim && 681 if (!verbatim &&
679 complete_suggested_text_lower.size() > user_text_lower.size() && 682 complete_suggested_text_lower.size() > user_text_lower.size() &&
680 !complete_suggested_text_lower.compare(0, user_text_lower.size(), 683 !complete_suggested_text_lower.compare(0, user_text_lower.size(),
681 user_text_lower)) { 684 user_text_lower)) {
682 *suggested_text = last_suggestion_ = 685 *suggested_text = last_suggestion_ =
683 complete_suggested_text_.substr(user_text_.size()); 686 complete_suggested_text_.substr(user_text_.size());
684 } 687 }
685 } else { 688 } else {
686 LoadInstantURL(tab_contents, template_url, transition_type, user_text_, 689 LoadInstantURL(tab_contents, template_url, transition_type, user_text_,
687 verbatim); 690 verbatim);
688 } 691 }
689 } else { 692 } else {
690 DCHECK(template_url_id_ == 0); 693 DCHECK(template_url_id_ == 0);
691 preview_tab_contents_delegate_->PrepareForNewLoad(); 694 preview_tab_contents_delegate_->PrepareForNewLoad();
692 frame_load_observer_.reset(NULL); 695 frame_load_observer_.reset(NULL);
693 preview_contents_->controller().LoadURL(url_, content::Referrer(), 696 preview_contents_->tab_contents()->controller().LoadURL(
694 transition_type, std::string()); 697 url_, content::Referrer(), transition_type, std::string());
695 } 698 }
696 return true; 699 return true;
697 } 700 }
698 701
699 void InstantLoader::SetOmniboxBounds(const gfx::Rect& bounds) { 702 void InstantLoader::SetOmniboxBounds(const gfx::Rect& bounds) {
700 if (omnibox_bounds_ == bounds) 703 if (omnibox_bounds_ == bounds)
701 return; 704 return;
702 705
703 // Don't update the page while the mouse is down. http://crbug.com/71952 706 // Don't update the page while the mouse is down. http://crbug.com/71952
704 if (IsMouseDownFromActivate()) 707 if (IsMouseDownFromActivate())
(...skipping 25 matching lines...) Expand all
730 TabContentsWrapper* InstantLoader::ReleasePreviewContents( 733 TabContentsWrapper* InstantLoader::ReleasePreviewContents(
731 InstantCommitType type) { 734 InstantCommitType type) {
732 if (!preview_contents_.get()) 735 if (!preview_contents_.get())
733 return NULL; 736 return NULL;
734 737
735 // FrameLoadObserver is only used for instant results, and instant results are 738 // FrameLoadObserver is only used for instant results, and instant results are
736 // only committed if active (when the FrameLoadObserver isn't installed). 739 // only committed if active (when the FrameLoadObserver isn't installed).
737 DCHECK(type == INSTANT_COMMIT_DESTROY || !frame_load_observer_.get()); 740 DCHECK(type == INSTANT_COMMIT_DESTROY || !frame_load_observer_.get());
738 741
739 if (type != INSTANT_COMMIT_DESTROY && is_showing_instant()) { 742 if (type != INSTANT_COMMIT_DESTROY && is_showing_instant()) {
740 RenderViewHost* host = preview_contents_->render_view_host(); 743 RenderViewHost* host =
744 preview_contents_->tab_contents()->render_view_host();
741 if (type == INSTANT_COMMIT_FOCUS_LOST) { 745 if (type == INSTANT_COMMIT_FOCUS_LOST) {
742 host->Send(new ChromeViewMsg_SearchBoxCancel(host->routing_id())); 746 host->Send(new ChromeViewMsg_SearchBoxCancel(host->routing_id()));
743 } else { 747 } else {
744 host->Send(new ChromeViewMsg_SearchBoxSubmit( 748 host->Send(new ChromeViewMsg_SearchBoxSubmit(
745 host->routing_id(), user_text_, 749 host->routing_id(), user_text_,
746 type == INSTANT_COMMIT_PRESSED_ENTER)); 750 type == INSTANT_COMMIT_PRESSED_ENTER));
747 } 751 }
748 } 752 }
749 omnibox_bounds_ = gfx::Rect(); 753 omnibox_bounds_ = gfx::Rect();
750 last_omnibox_bounds_ = gfx::Rect(); 754 last_omnibox_bounds_ = gfx::Rect();
(...skipping 12 matching lines...) Expand all
763 preview_tab_contents_delegate_->CommitHistory(template_url_id_ != 0); 767 preview_tab_contents_delegate_->CommitHistory(template_url_id_ != 0);
764 } 768 }
765 if (preview_contents_->tab_contents()->GetRenderWidgetHostView()) { 769 if (preview_contents_->tab_contents()->GetRenderWidgetHostView()) {
766 #if defined(OS_MACOSX) 770 #if defined(OS_MACOSX)
767 preview_contents_->tab_contents()->GetRenderWidgetHostView()-> 771 preview_contents_->tab_contents()->GetRenderWidgetHostView()->
768 SetTakesFocusOnlyOnMouseDown(false); 772 SetTakesFocusOnlyOnMouseDown(false);
769 registrar_.Remove( 773 registrar_.Remove(
770 this, 774 this,
771 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 775 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
772 content::Source<NavigationController>( 776 content::Source<NavigationController>(
773 &preview_contents_->controller())); 777 &preview_contents_->tab_contents()->controller()));
774 #endif 778 #endif
775 } 779 }
776 preview_contents_->tab_contents()->set_delegate(NULL); 780 preview_contents_->tab_contents()->set_delegate(NULL);
777 ready_ = false; 781 ready_ = false;
778 } 782 }
779 update_bounds_timer_.Stop(); 783 update_bounds_timer_.Stop();
780 AddPreviewUsageForHistogram(template_url_id_, 784 AddPreviewUsageForHistogram(template_url_id_,
781 type == INSTANT_COMMIT_DESTROY ? PREVIEW_DELETED : PREVIEW_COMMITTED); 785 type == INSTANT_COMMIT_DESTROY ? PREVIEW_DELETED : PREVIEW_COMMITTED);
782 return preview_contents_.release(); 786 return preview_contents_.release();
783 } 787 }
(...skipping 16 matching lines...) Expand all
800 if (preview_contents_.get()) 804 if (preview_contents_.get())
801 return; 805 return;
802 806
803 CreatePreviewContents(tab_contents); 807 CreatePreviewContents(tab_contents);
804 LoadInstantURL(tab_contents, template_url, content::PAGE_TRANSITION_GENERATED, 808 LoadInstantURL(tab_contents, template_url, content::PAGE_TRANSITION_GENERATED,
805 string16(), true); 809 string16(), true);
806 } 810 }
807 811
808 bool InstantLoader::IsNavigationPending() const { 812 bool InstantLoader::IsNavigationPending() const {
809 return preview_contents_.get() && 813 return preview_contents_.get() &&
810 preview_contents_->controller().pending_entry(); 814 preview_contents_->tab_contents()->controller().pending_entry();
811 } 815 }
812 816
813 void InstantLoader::Observe(int type, 817 void InstantLoader::Observe(int type,
814 const content::NotificationSource& source, 818 const content::NotificationSource& source,
815 const content::NotificationDetails& details) { 819 const content::NotificationDetails& details) {
816 #if defined(OS_MACOSX) 820 #if defined(OS_MACOSX)
817 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) { 821 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) {
818 if (preview_contents_->tab_contents()->GetRenderWidgetHostView()) { 822 if (preview_contents_->tab_contents()->GetRenderWidgetHostView()) {
819 preview_contents_->tab_contents()->GetRenderWidgetHostView()-> 823 preview_contents_->tab_contents()->GetRenderWidgetHostView()->
820 SetTakesFocusOnlyOnMouseDown(true); 824 SetTakesFocusOnlyOnMouseDown(true);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 SendBoundsToPage(false); 959 SendBoundsToPage(false);
956 } 960 }
957 961
958 void InstantLoader::SendBoundsToPage(bool force_if_waiting) { 962 void InstantLoader::SendBoundsToPage(bool force_if_waiting) {
959 if (last_omnibox_bounds_ == omnibox_bounds_) 963 if (last_omnibox_bounds_ == omnibox_bounds_)
960 return; 964 return;
961 965
962 if (preview_contents_.get() && is_showing_instant() && 966 if (preview_contents_.get() && is_showing_instant() &&
963 (force_if_waiting || !is_determining_if_page_supports_instant())) { 967 (force_if_waiting || !is_determining_if_page_supports_instant())) {
964 last_omnibox_bounds_ = omnibox_bounds_; 968 last_omnibox_bounds_ = omnibox_bounds_;
965 RenderViewHost* host = preview_contents_->render_view_host(); 969 RenderViewHost* host =
970 preview_contents_->tab_contents()->render_view_host();
966 host->Send(new ChromeViewMsg_SearchBoxResize( 971 host->Send(new ChromeViewMsg_SearchBoxResize(
967 host->routing_id(), GetOmniboxBoundsInTermsOfPreview())); 972 host->routing_id(), GetOmniboxBoundsInTermsOfPreview()));
968 } 973 }
969 } 974 }
970 975
971 void InstantLoader::ReplacePreviewContents(TabContentsWrapper* old_tc, 976 void InstantLoader::ReplacePreviewContents(TabContentsWrapper* old_tc,
972 TabContentsWrapper* new_tc) { 977 TabContentsWrapper* new_tc) {
973 DCHECK(old_tc == preview_contents_); 978 DCHECK(old_tc == preview_contents_);
974 // We release here without deleting so that the caller still has reponsibility 979 // We release here without deleting so that the caller still has reponsibility
975 // for deleting the TabContentsWrapper. 980 // for deleting the TabContentsWrapper.
976 ignore_result(preview_contents_.release()); 981 ignore_result(preview_contents_.release());
977 preview_contents_.reset(new_tc); 982 preview_contents_.reset(new_tc);
978 983
979 // Make sure the new preview contents acts like the old one. 984 // Make sure the new preview contents acts like the old one.
980 SetupPreviewContents(old_tc); 985 SetupPreviewContents(old_tc);
981 986
982 // Cleanup the old preview contents. 987 // Cleanup the old preview contents.
983 old_tc->constrained_window_tab_helper()->set_delegate(NULL); 988 old_tc->constrained_window_tab_helper()->set_delegate(NULL);
984 old_tc->core_tab_helper()->set_delegate(NULL); 989 old_tc->core_tab_helper()->set_delegate(NULL);
985 old_tc->tab_contents()->set_delegate(NULL); 990 old_tc->tab_contents()->set_delegate(NULL);
986 991
987 #if defined(OS_MACOSX) 992 #if defined(OS_MACOSX)
988 registrar_.Remove( 993 registrar_.Remove(
989 this, 994 this,
990 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 995 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
991 content::Source<NavigationController>(&old_tc->controller())); 996 content::Source<NavigationController>(
997 &old_tc->tab_contents()->controller()));
992 #endif 998 #endif
993 registrar_.Remove(this, 999 registrar_.Remove(
994 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 1000 this,
995 content::Source<NavigationController>(&old_tc->controller())); 1001 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
1002 content::Source<NavigationController>(
1003 &old_tc->tab_contents()->controller()));
996 1004
997 // We prerendered so we should be ready to show. If we're ready, swap in 1005 // We prerendered so we should be ready to show. If we're ready, swap in
998 // immediately, otherwise show the preview as normal. 1006 // immediately, otherwise show the preview as normal.
999 if (ready_) 1007 if (ready_)
1000 delegate_->SwappedTabContents(this); 1008 delegate_->SwappedTabContents(this);
1001 else 1009 else
1002 ShowPreview(); 1010 ShowPreview();
1003 } 1011 }
1004 1012
1005 void InstantLoader::SetupPreviewContents(TabContentsWrapper* tab_contents) { 1013 void InstantLoader::SetupPreviewContents(TabContentsWrapper* tab_contents) {
1006 preview_contents_->tab_contents()->set_delegate( 1014 preview_contents_->tab_contents()->set_delegate(
1007 preview_tab_contents_delegate_.get()); 1015 preview_tab_contents_delegate_.get());
1008 preview_contents_->blocked_content_tab_helper()->SetAllContentsBlocked(true); 1016 preview_contents_->blocked_content_tab_helper()->SetAllContentsBlocked(true);
1009 preview_contents_->constrained_window_tab_helper()->set_delegate( 1017 preview_contents_->constrained_window_tab_helper()->set_delegate(
1010 preview_tab_contents_delegate_.get()); 1018 preview_tab_contents_delegate_.get());
1011 preview_contents_->core_tab_helper()->set_delegate( 1019 preview_contents_->core_tab_helper()->set_delegate(
1012 preview_tab_contents_delegate_.get()); 1020 preview_tab_contents_delegate_.get());
1013 1021
1014 // Propagate the max page id. That way if we end up merging the two 1022 // Propagate the max page id. That way if we end up merging the two
1015 // NavigationControllers (which happens if we commit) none of the page ids 1023 // NavigationControllers (which happens if we commit) none of the page ids
1016 // will overlap. 1024 // will overlap.
1017 int32 max_page_id = tab_contents->tab_contents()->GetMaxPageID(); 1025 int32 max_page_id = tab_contents->tab_contents()->GetMaxPageID();
1018 if (max_page_id != -1) 1026 if (max_page_id != -1) {
1019 preview_contents_->controller().set_max_restored_page_id(max_page_id + 1); 1027 preview_contents_->tab_contents()->controller().set_max_restored_page_id(
1028 max_page_id + 1);
1029 }
1020 1030
1021 #if defined(OS_MACOSX) 1031 #if defined(OS_MACOSX)
1022 // If |preview_contents_| does not currently have a RWHV, we will call 1032 // If |preview_contents_| does not currently have a RWHV, we will call
1023 // SetTakesFocusOnlyOnMouseDown() as a result of the 1033 // SetTakesFocusOnlyOnMouseDown() as a result of the
1024 // RENDER_VIEW_HOST_CHANGED notification. 1034 // RENDER_VIEW_HOST_CHANGED notification.
1025 if (preview_contents_->tab_contents()->GetRenderWidgetHostView()) { 1035 if (preview_contents_->tab_contents()->GetRenderWidgetHostView()) {
1026 preview_contents_->tab_contents()->GetRenderWidgetHostView()-> 1036 preview_contents_->tab_contents()->GetRenderWidgetHostView()->
1027 SetTakesFocusOnlyOnMouseDown(true); 1037 SetTakesFocusOnlyOnMouseDown(true);
1028 } 1038 }
1029 registrar_.Add( 1039 registrar_.Add(
1030 this, 1040 this,
1031 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 1041 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
1032 content::Source<NavigationController>(&preview_contents_->controller())); 1042 content::Source<NavigationController>(
1043 &preview_contents_->tab_contents()->controller()));
1033 #endif 1044 #endif
1034 1045
1035 registrar_.Add( 1046 registrar_.Add(
1036 this, 1047 this,
1037 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 1048 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
1038 content::Source<NavigationController>(&preview_contents_->controller())); 1049 content::Source<NavigationController>(
1050 &preview_contents_->tab_contents()->controller()));
1039 1051
1040 gfx::Rect tab_bounds; 1052 gfx::Rect tab_bounds;
1041 tab_contents->view()->GetContainerBounds(&tab_bounds); 1053 tab_contents->tab_contents()->view()->GetContainerBounds(&tab_bounds);
1042 preview_contents_->view()->SizeContents(tab_bounds.size()); 1054 preview_contents_->tab_contents()->view()->SizeContents(tab_bounds.size());
1043 } 1055 }
1044 1056
1045 void InstantLoader::CreatePreviewContents(TabContentsWrapper* tab_contents) { 1057 void InstantLoader::CreatePreviewContents(TabContentsWrapper* tab_contents) {
1046 TabContents* new_contents = 1058 TabContents* new_contents =
1047 new TabContents( 1059 new TabContents(
1048 tab_contents->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); 1060 tab_contents->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL);
1049 preview_contents_.reset(new TabContentsWrapper(new_contents)); 1061 preview_contents_.reset(new TabContentsWrapper(new_contents));
1050 AddPreviewUsageForHistogram(template_url_id_, PREVIEW_CREATED); 1062 AddPreviewUsageForHistogram(template_url_id_, PREVIEW_CREATED);
1051 preview_tab_contents_delegate_.reset(new TabContentsDelegateImpl(this)); 1063 preview_tab_contents_delegate_.reset(new TabContentsDelegateImpl(this));
1052 SetupPreviewContents(tab_contents); 1064 SetupPreviewContents(tab_contents);
(...skipping 14 matching lines...) Expand all
1067 // This uses an empty string for the replacement text as the url doesn't 1079 // This uses an empty string for the replacement text as the url doesn't
1068 // really have the search params, but we need to use the replace 1080 // really have the search params, but we need to use the replace
1069 // functionality so that embeded tags (like {google:baseURL}) are escaped 1081 // functionality so that embeded tags (like {google:baseURL}) are escaped
1070 // correctly. 1082 // correctly.
1071 // TODO(sky): having to use a replaceable url is a bit of a hack here. 1083 // TODO(sky): having to use a replaceable url is a bit of a hack here.
1072 GURL instant_url(template_url->instant_url()->ReplaceSearchTermsUsingProfile( 1084 GURL instant_url(template_url->instant_url()->ReplaceSearchTermsUsingProfile(
1073 tab_contents->profile(), *template_url, string16(), -1, string16())); 1085 tab_contents->profile(), *template_url, string16(), -1, string16()));
1074 CommandLine* cl = CommandLine::ForCurrentProcess(); 1086 CommandLine* cl = CommandLine::ForCurrentProcess();
1075 if (cl->HasSwitch(switches::kInstantURL)) 1087 if (cl->HasSwitch(switches::kInstantURL))
1076 instant_url = GURL(cl->GetSwitchValueASCII(switches::kInstantURL)); 1088 instant_url = GURL(cl->GetSwitchValueASCII(switches::kInstantURL));
1077 preview_contents_->controller().LoadURL(instant_url, content::Referrer(), 1089 preview_contents_->tab_contents()->controller().LoadURL(
1078 transition_type, std::string()); 1090 instant_url, content::Referrer(), transition_type, std::string());
1079 RenderViewHost* host = preview_contents_->render_view_host(); 1091 RenderViewHost* host = preview_contents_->tab_contents()->render_view_host();
1080 preview_contents_->tab_contents()->HideContents(); 1092 preview_contents_->tab_contents()->HideContents();
1081 1093
1082 // If user_text is empty, this must be a preload of the search homepage. In 1094 // If user_text is empty, this must be a preload of the search homepage. In
1083 // that case, send down a SearchBoxResize message, which will switch the page 1095 // that case, send down a SearchBoxResize message, which will switch the page
1084 // to "search results" UI. This avoids flicker when the page is shown with 1096 // to "search results" UI. This avoids flicker when the page is shown with
1085 // results. In addition, we don't want the page accidentally causing the 1097 // results. In addition, we don't want the page accidentally causing the
1086 // preloaded page to be displayed yet (by calling setSuggestions), so don't 1098 // preloaded page to be displayed yet (by calling setSuggestions), so don't
1087 // send a SearchBoxChange message. 1099 // send a SearchBoxChange message.
1088 if (user_text.empty()) { 1100 if (user_text.empty()) {
1089 host->Send(new ChromeViewMsg_SearchBoxResize( 1101 host->Send(new ChromeViewMsg_SearchBoxResize(
1090 host->routing_id(), GetOmniboxBoundsInTermsOfPreview())); 1102 host->routing_id(), GetOmniboxBoundsInTermsOfPreview()));
1091 } else { 1103 } else {
1092 host->Send(new ChromeViewMsg_SearchBoxChange( 1104 host->Send(new ChromeViewMsg_SearchBoxChange(
1093 host->routing_id(), user_text, verbatim, 0, 0)); 1105 host->routing_id(), user_text, verbatim, 0, 0));
1094 } 1106 }
1095 1107
1096 frame_load_observer_.reset(new FrameLoadObserver( 1108 frame_load_observer_.reset(new FrameLoadObserver(
1097 this, preview_contents()->tab_contents(), user_text, verbatim)); 1109 this, preview_contents()->tab_contents(), user_text, verbatim));
1098 } 1110 }
OLDNEW
« no previous file with comments | « chrome/browser/instant/instant_controller.cc ('k') | chrome/browser/omnibox_search_hint.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698