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

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

Issue 9473001: Extract minimal RenderViewHost interface for embedders, leaving (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to LKGR. Created 8 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 web_contents_->GetController().GetActiveEntry(); 159 web_contents_->GetController().GetActiveEntry();
160 if (!active_entry || active_entry->GetPageID() != page_id || 160 if (!active_entry || active_entry->GetPageID() != page_id ||
161 active_entry->GetUniqueID() != unique_id_) { 161 active_entry->GetUniqueID() != unique_id_) {
162 return; 162 return;
163 } 163 }
164 loader_->SendBoundsToPage(true); 164 loader_->SendBoundsToPage(true);
165 // TODO: support real cursor position. 165 // TODO: support real cursor position.
166 int text_length = static_cast<int>(text_.size()); 166 int text_length = static_cast<int>(text_.size());
167 RenderViewHost* host = web_contents_->GetRenderViewHost(); 167 RenderViewHost* host = web_contents_->GetRenderViewHost();
168 host->Send(new ChromeViewMsg_DetermineIfPageSupportsInstant( 168 host->Send(new ChromeViewMsg_DetermineIfPageSupportsInstant(
169 host->routing_id(), text_, verbatim_, text_length, text_length)); 169 host->GetRoutingID(), text_, verbatim_, text_length, text_length));
170 break; 170 break;
171 } 171 }
172 default: 172 default:
173 NOTREACHED(); 173 NOTREACHED();
174 break; 174 break;
175 } 175 }
176 } 176 }
177 177
178 // TabContentsDelegateImpl ----------------------------------------------------- 178 // TabContentsDelegateImpl -----------------------------------------------------
179 179
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 frame_load_observer_->set_text(user_text_); 682 frame_load_observer_->set_text(user_text_);
683 frame_load_observer_->set_verbatim(verbatim); 683 frame_load_observer_->set_verbatim(verbatim);
684 preview_tab_contents_delegate_->set_user_typed_before_load(); 684 preview_tab_contents_delegate_->set_user_typed_before_load();
685 return true; 685 return true;
686 } 686 }
687 // TODO: support real cursor position. 687 // TODO: support real cursor position.
688 int text_length = static_cast<int>(user_text_.size()); 688 int text_length = static_cast<int>(user_text_.size());
689 RenderViewHost* host = 689 RenderViewHost* host =
690 preview_contents_->web_contents()->GetRenderViewHost(); 690 preview_contents_->web_contents()->GetRenderViewHost();
691 host->Send(new ChromeViewMsg_SearchBoxChange( 691 host->Send(new ChromeViewMsg_SearchBoxChange(
692 host->routing_id(), user_text_, verbatim, text_length, text_length)); 692 host->GetRoutingID(),
693 user_text_,
694 verbatim,
695 text_length,
696 text_length));
693 697
694 string16 complete_suggested_text_lower = base::i18n::ToLower( 698 string16 complete_suggested_text_lower = base::i18n::ToLower(
695 complete_suggested_text_); 699 complete_suggested_text_);
696 string16 user_text_lower = base::i18n::ToLower(user_text_); 700 string16 user_text_lower = base::i18n::ToLower(user_text_);
697 if (!verbatim && 701 if (!verbatim &&
698 complete_suggested_text_lower.size() > user_text_lower.size() && 702 complete_suggested_text_lower.size() > user_text_lower.size() &&
699 !complete_suggested_text_lower.compare(0, user_text_lower.size(), 703 !complete_suggested_text_lower.compare(0, user_text_lower.size(),
700 user_text_lower)) { 704 user_text_lower)) {
701 *suggested_text = last_suggestion_ = 705 *suggested_text = last_suggestion_ =
702 complete_suggested_text_.substr(user_text_.size()); 706 complete_suggested_text_.substr(user_text_.size());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 return NULL; 757 return NULL;
754 758
755 // FrameLoadObserver is only used for instant results, and instant results are 759 // FrameLoadObserver is only used for instant results, and instant results are
756 // only committed if active (when the FrameLoadObserver isn't installed). 760 // only committed if active (when the FrameLoadObserver isn't installed).
757 DCHECK(type == INSTANT_COMMIT_DESTROY || !frame_load_observer_.get()); 761 DCHECK(type == INSTANT_COMMIT_DESTROY || !frame_load_observer_.get());
758 762
759 if (type != INSTANT_COMMIT_DESTROY && is_showing_instant()) { 763 if (type != INSTANT_COMMIT_DESTROY && is_showing_instant()) {
760 RenderViewHost* host = 764 RenderViewHost* host =
761 preview_contents_->web_contents()->GetRenderViewHost(); 765 preview_contents_->web_contents()->GetRenderViewHost();
762 if (type == INSTANT_COMMIT_FOCUS_LOST) { 766 if (type == INSTANT_COMMIT_FOCUS_LOST) {
763 host->Send(new ChromeViewMsg_SearchBoxCancel(host->routing_id())); 767 host->Send(new ChromeViewMsg_SearchBoxCancel(host->GetRoutingID()));
764 } else { 768 } else {
765 host->Send(new ChromeViewMsg_SearchBoxSubmit( 769 host->Send(new ChromeViewMsg_SearchBoxSubmit(
766 host->routing_id(), user_text_, 770 host->GetRoutingID(), user_text_,
767 type == INSTANT_COMMIT_PRESSED_ENTER)); 771 type == INSTANT_COMMIT_PRESSED_ENTER));
768 } 772 }
769 } 773 }
770 omnibox_bounds_ = gfx::Rect(); 774 omnibox_bounds_ = gfx::Rect();
771 last_omnibox_bounds_ = gfx::Rect(); 775 last_omnibox_bounds_ = gfx::Rect();
772 GURL url; 776 GURL url;
773 url.Swap(&url_); 777 url.Swap(&url_);
774 user_text_.clear(); 778 user_text_.clear();
775 complete_suggested_text_.clear(); 779 complete_suggested_text_.clear();
776 if (preview_contents_.get()) { 780 if (preview_contents_.get()) {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 void InstantLoader::SendBoundsToPage(bool force_if_waiting) { 995 void InstantLoader::SendBoundsToPage(bool force_if_waiting) {
992 if (last_omnibox_bounds_ == omnibox_bounds_) 996 if (last_omnibox_bounds_ == omnibox_bounds_)
993 return; 997 return;
994 998
995 if (preview_contents_.get() && is_showing_instant() && 999 if (preview_contents_.get() && is_showing_instant() &&
996 (force_if_waiting || !is_determining_if_page_supports_instant())) { 1000 (force_if_waiting || !is_determining_if_page_supports_instant())) {
997 last_omnibox_bounds_ = omnibox_bounds_; 1001 last_omnibox_bounds_ = omnibox_bounds_;
998 RenderViewHost* host = 1002 RenderViewHost* host =
999 preview_contents_->web_contents()->GetRenderViewHost(); 1003 preview_contents_->web_contents()->GetRenderViewHost();
1000 host->Send(new ChromeViewMsg_SearchBoxResize( 1004 host->Send(new ChromeViewMsg_SearchBoxResize(
1001 host->routing_id(), GetOmniboxBoundsInTermsOfPreview())); 1005 host->GetRoutingID(), GetOmniboxBoundsInTermsOfPreview()));
1002 } 1006 }
1003 } 1007 }
1004 1008
1005 void InstantLoader::ReplacePreviewContents(TabContentsWrapper* old_tc, 1009 void InstantLoader::ReplacePreviewContents(TabContentsWrapper* old_tc,
1006 TabContentsWrapper* new_tc) { 1010 TabContentsWrapper* new_tc) {
1007 DCHECK(old_tc == preview_contents_); 1011 DCHECK(old_tc == preview_contents_);
1008 // We release here without deleting so that the caller still has reponsibility 1012 // We release here without deleting so that the caller still has reponsibility
1009 // for deleting the TabContentsWrapper. 1013 // for deleting the TabContentsWrapper.
1010 ignore_result(preview_contents_.release()); 1014 ignore_result(preview_contents_.release());
1011 preview_contents_.reset(new_tc); 1015 preview_contents_.reset(new_tc);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 preview_contents_->web_contents()->HideContents(); 1117 preview_contents_->web_contents()->HideContents();
1114 1118
1115 // If user_text is empty, this must be a preload of the search homepage. In 1119 // If user_text is empty, this must be a preload of the search homepage. In
1116 // that case, send down a SearchBoxResize message, which will switch the page 1120 // that case, send down a SearchBoxResize message, which will switch the page
1117 // to "search results" UI. This avoids flicker when the page is shown with 1121 // to "search results" UI. This avoids flicker when the page is shown with
1118 // results. In addition, we don't want the page accidentally causing the 1122 // results. In addition, we don't want the page accidentally causing the
1119 // preloaded page to be displayed yet (by calling setSuggestions), so don't 1123 // preloaded page to be displayed yet (by calling setSuggestions), so don't
1120 // send a SearchBoxChange message. 1124 // send a SearchBoxChange message.
1121 if (user_text.empty()) { 1125 if (user_text.empty()) {
1122 host->Send(new ChromeViewMsg_SearchBoxResize( 1126 host->Send(new ChromeViewMsg_SearchBoxResize(
1123 host->routing_id(), GetOmniboxBoundsInTermsOfPreview())); 1127 host->GetRoutingID(), GetOmniboxBoundsInTermsOfPreview()));
1124 } else { 1128 } else {
1125 host->Send(new ChromeViewMsg_SearchBoxChange( 1129 host->Send(new ChromeViewMsg_SearchBoxChange(
1126 host->routing_id(), user_text, verbatim, 0, 0)); 1130 host->GetRoutingID(), user_text, verbatim, 0, 0));
1127 } 1131 }
1128 1132
1129 frame_load_observer_.reset(new FrameLoadObserver( 1133 frame_load_observer_.reset(new FrameLoadObserver(
1130 this, preview_contents()->web_contents(), user_text, verbatim)); 1134 this, preview_contents()->web_contents(), user_text, verbatim));
1131 } 1135 }
OLDNEW
« no previous file with comments | « chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc ('k') | chrome/browser/memory_details.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698