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

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

Issue 11833043: Instant Extended: Fallback to local preview if the remote instant page is not ready on user input. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor
Patch Set: Removing LOG messages. Created 7 years, 11 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
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_client.h" 5 #include "chrome/browser/instant/instant_client.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/common/render_messages.h" 8 #include "chrome/common/render_messages.h"
9 #include "content/public/browser/web_contents.h" 9 #include "content/public/browser/web_contents.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 29 matching lines...) Expand all
40 } 40 }
41 41
42 void InstantClient::SetPopupBounds(const gfx::Rect& bounds) { 42 void InstantClient::SetPopupBounds(const gfx::Rect& bounds) {
43 Send(new ChromeViewMsg_SearchBoxPopupResize(routing_id(), bounds)); 43 Send(new ChromeViewMsg_SearchBoxPopupResize(routing_id(), bounds));
44 } 44 }
45 45
46 void InstantClient::SetMarginSize(const int start, const int end) { 46 void InstantClient::SetMarginSize(const int start, const int end) {
47 Send(new ChromeViewMsg_SearchBoxMarginChange(routing_id(), start, end)); 47 Send(new ChromeViewMsg_SearchBoxMarginChange(routing_id(), start, end));
48 } 48 }
49 49
50 void InstantClient::InitializeFonts() {
51 const gfx::Font& omnibox_font =
52 ui::ResourceBundle::GetSharedInstance().GetFont(
53 ui::ResourceBundle::MediumFont);
54 string16 omnibox_font_name = UTF8ToUTF16(omnibox_font.GetFontName());
55 size_t omnibox_font_size = omnibox_font.GetFontSize();
56 Send(new ChromeViewMsg_SearchBoxFontInformation(
57 routing_id(), omnibox_font_name, omnibox_font_size));
58 }
59
50 void InstantClient::DetermineIfPageSupportsInstant() { 60 void InstantClient::DetermineIfPageSupportsInstant() {
51 Send(new ChromeViewMsg_DetermineIfPageSupportsInstant(routing_id())); 61 Send(new ChromeViewMsg_DetermineIfPageSupportsInstant(routing_id()));
52 } 62 }
53 63
54 void InstantClient::SendAutocompleteResults( 64 void InstantClient::SendAutocompleteResults(
55 const std::vector<InstantAutocompleteResult>& results) { 65 const std::vector<InstantAutocompleteResult>& results) {
56 Send(new ChromeViewMsg_SearchBoxAutocompleteResults(routing_id(), results)); 66 Send(new ChromeViewMsg_SearchBoxAutocompleteResults(routing_id(), results));
57 } 67 }
58 68
59 void InstantClient::UpOrDownKeyPressed(int count) { 69 void InstantClient::UpOrDownKeyPressed(int count) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 137 }
128 138
129 void InstantClient::SetSuggestions( 139 void InstantClient::SetSuggestions(
130 int page_id, 140 int page_id,
131 const std::vector<InstantSuggestion>& suggestions) { 141 const std::vector<InstantSuggestion>& suggestions) {
132 if (web_contents()->IsActiveEntry(page_id)) 142 if (web_contents()->IsActiveEntry(page_id))
133 delegate_->SetSuggestions(suggestions); 143 delegate_->SetSuggestions(suggestions);
134 } 144 }
135 145
136 void InstantClient::InstantSupportDetermined(int page_id, bool result) { 146 void InstantClient::InstantSupportDetermined(int page_id, bool result) {
137 if (result) {
138 // Inform the renderer process of the Omnibox's font information.
139 const gfx::Font& omnibox_font =
140 ui::ResourceBundle::GetSharedInstance().GetFont(
141 ui::ResourceBundle::MediumFont);
142 string16 omnibox_font_name = UTF8ToUTF16(omnibox_font.GetFontName());
143 size_t omnibox_font_size = omnibox_font.GetFontSize();
144
145 Send(new ChromeViewMsg_SearchBoxFontInformation(
146 routing_id(), omnibox_font_name, omnibox_font_size));
147 }
148 if (web_contents()->IsActiveEntry(page_id)) 147 if (web_contents()->IsActiveEntry(page_id))
149 delegate_->InstantSupportDetermined(result); 148 delegate_->InstantSupportDetermined(result);
150 } 149 }
151 150
152 void InstantClient::ShowInstantPreview(int page_id, 151 void InstantClient::ShowInstantPreview(int page_id,
153 InstantShownReason reason, 152 InstantShownReason reason,
154 int height, 153 int height,
155 InstantSizeUnits units) { 154 InstantSizeUnits units) {
156 if (web_contents()->IsActiveEntry(page_id)) 155 if (web_contents()->IsActiveEntry(page_id))
157 delegate_->ShowInstantPreview(reason, height, units); 156 delegate_->ShowInstantPreview(reason, height, units);
158 } 157 }
159 158
160 void InstantClient::StartCapturingKeyStrokes(int page_id) { 159 void InstantClient::StartCapturingKeyStrokes(int page_id) {
161 if (web_contents()->IsActiveEntry(page_id)) 160 if (web_contents()->IsActiveEntry(page_id))
162 delegate_->StartCapturingKeyStrokes(); 161 delegate_->StartCapturingKeyStrokes();
163 } 162 }
164 163
165 void InstantClient::StopCapturingKeyStrokes(int page_id) { 164 void InstantClient::StopCapturingKeyStrokes(int page_id) {
166 if (web_contents()->IsActiveEntry(page_id)) 165 if (web_contents()->IsActiveEntry(page_id))
167 delegate_->StopCapturingKeyStrokes(); 166 delegate_->StopCapturingKeyStrokes();
168 } 167 }
169 168
170 void InstantClient::SearchBoxNavigate(int page_id, 169 void InstantClient::SearchBoxNavigate(int page_id,
171 const GURL& url, 170 const GURL& url,
172 content::PageTransition transition) { 171 content::PageTransition transition) {
173 if (web_contents()->IsActiveEntry(page_id)) 172 if (web_contents()->IsActiveEntry(page_id))
174 delegate_->NavigateToURL(url, transition); 173 delegate_->NavigateToURL(url, transition);
175 } 174 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698