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

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: Addressing sreeram's comments. 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
« no previous file with comments | « chrome/browser/instant/instant_client.h ('k') | chrome/browser/instant/instant_controller.h » ('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 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 16 matching lines...) Expand all
76 void InstantClient::SetDisplayInstantResults(bool display_instant_results) { 86 void InstantClient::SetDisplayInstantResults(bool display_instant_results) {
77 Send(new ChromeViewMsg_SearchBoxSetDisplayInstantResults(routing_id(), 87 Send(new ChromeViewMsg_SearchBoxSetDisplayInstantResults(routing_id(),
78 display_instant_results)); 88 display_instant_results));
79 } 89 }
80 90
81 void InstantClient::KeyCaptureChanged(bool is_key_capture_enabled) { 91 void InstantClient::KeyCaptureChanged(bool is_key_capture_enabled) {
82 Send(new ChromeViewMsg_SearchBoxKeyCaptureChanged(routing_id(), 92 Send(new ChromeViewMsg_SearchBoxKeyCaptureChanged(routing_id(),
83 is_key_capture_enabled)); 93 is_key_capture_enabled));
84 } 94 }
85 95
96 void InstantClient::RenderViewCreated(
97 content::RenderViewHost* render_view_host) {
98 delegate_->RenderViewCreated();
99 }
100
86 void InstantClient::DidFinishLoad( 101 void InstantClient::DidFinishLoad(
87 int64 /* frame_id */, 102 int64 /* frame_id */,
88 const GURL& /* validated_url */, 103 const GURL& /* validated_url */,
89 bool is_main_frame, 104 bool is_main_frame,
90 content::RenderViewHost* /* render_view_host */) { 105 content::RenderViewHost* /* render_view_host */) {
91 if (is_main_frame) 106 if (is_main_frame)
92 DetermineIfPageSupportsInstant(); 107 DetermineIfPageSupportsInstant();
93 } 108 }
94 109
95 bool InstantClient::OnMessageReceived(const IPC::Message& message) { 110 bool InstantClient::OnMessageReceived(const IPC::Message& message) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 142 }
128 143
129 void InstantClient::SetSuggestions( 144 void InstantClient::SetSuggestions(
130 int page_id, 145 int page_id,
131 const std::vector<InstantSuggestion>& suggestions) { 146 const std::vector<InstantSuggestion>& suggestions) {
132 if (web_contents()->IsActiveEntry(page_id)) 147 if (web_contents()->IsActiveEntry(page_id))
133 delegate_->SetSuggestions(suggestions); 148 delegate_->SetSuggestions(suggestions);
134 } 149 }
135 150
136 void InstantClient::InstantSupportDetermined(int page_id, bool result) { 151 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)) 152 if (web_contents()->IsActiveEntry(page_id))
149 delegate_->InstantSupportDetermined(result); 153 delegate_->InstantSupportDetermined(result);
150 } 154 }
151 155
152 void InstantClient::ShowInstantPreview(int page_id, 156 void InstantClient::ShowInstantPreview(int page_id,
153 InstantShownReason reason, 157 InstantShownReason reason,
154 int height, 158 int height,
155 InstantSizeUnits units) { 159 InstantSizeUnits units) {
156 if (web_contents()->IsActiveEntry(page_id)) 160 if (web_contents()->IsActiveEntry(page_id))
157 delegate_->ShowInstantPreview(reason, height, units); 161 delegate_->ShowInstantPreview(reason, height, units);
158 } 162 }
159 163
160 void InstantClient::StartCapturingKeyStrokes(int page_id) { 164 void InstantClient::StartCapturingKeyStrokes(int page_id) {
161 if (web_contents()->IsActiveEntry(page_id)) 165 if (web_contents()->IsActiveEntry(page_id))
162 delegate_->StartCapturingKeyStrokes(); 166 delegate_->StartCapturingKeyStrokes();
163 } 167 }
164 168
165 void InstantClient::StopCapturingKeyStrokes(int page_id) { 169 void InstantClient::StopCapturingKeyStrokes(int page_id) {
166 if (web_contents()->IsActiveEntry(page_id)) 170 if (web_contents()->IsActiveEntry(page_id))
167 delegate_->StopCapturingKeyStrokes(); 171 delegate_->StopCapturingKeyStrokes();
168 } 172 }
169 173
170 void InstantClient::SearchBoxNavigate(int page_id, 174 void InstantClient::SearchBoxNavigate(int page_id,
171 const GURL& url, 175 const GURL& url,
172 content::PageTransition transition) { 176 content::PageTransition transition) {
173 if (web_contents()->IsActiveEntry(page_id)) 177 if (web_contents()->IsActiveEntry(page_id))
174 delegate_->NavigateToURL(url, transition); 178 delegate_->NavigateToURL(url, transition);
175 } 179 }
OLDNEW
« no previous file with comments | « chrome/browser/instant/instant_client.h ('k') | chrome/browser/instant/instant_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698