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

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

Issue 11824050: InstantExtended: Committed NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Undo to fix blacklisting. 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/instant/instant_client.h"
6
7 #include "base/utf_string_conversions.h"
8 #include "chrome/common/render_messages.h"
9 #include "content/public/browser/web_contents.h"
10 #include "ui/base/resource/resource_bundle.h"
11 #include "ui/gfx/font.h"
12
13 InstantClient::Delegate::~Delegate() {
14 }
15
16 InstantClient::InstantClient(Delegate* delegate) : delegate_(delegate) {
17 }
18
19 InstantClient::~InstantClient() {
20 }
21
22 void InstantClient::SetContents(content::WebContents* contents) {
23 Observe(contents);
24 }
25
26 void InstantClient::Update(const string16& text,
27 size_t selection_start,
28 size_t selection_end,
29 bool verbatim) {
30 Send(new ChromeViewMsg_SearchBoxChange(routing_id(), text, verbatim,
31 selection_start, selection_end));
32 }
33
34 void InstantClient::Submit(const string16& text) {
35 Send(new ChromeViewMsg_SearchBoxSubmit(routing_id(), text));
36 }
37
38 void InstantClient::Cancel(const string16& text) {
39 Send(new ChromeViewMsg_SearchBoxCancel(routing_id(), text));
40 }
41
42 void InstantClient::SetPopupBounds(const gfx::Rect& bounds) {
43 Send(new ChromeViewMsg_SearchBoxPopupResize(routing_id(), bounds));
44 }
45
46 void InstantClient::SetMarginSize(const int start, const int end) {
47 Send(new ChromeViewMsg_SearchBoxMarginChange(routing_id(), start, end));
48 }
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
60 void InstantClient::DetermineIfPageSupportsInstant() {
61 Send(new ChromeViewMsg_DetermineIfPageSupportsInstant(routing_id()));
62 }
63
64 void InstantClient::SendAutocompleteResults(
65 const std::vector<InstantAutocompleteResult>& results) {
66 Send(new ChromeViewMsg_SearchBoxAutocompleteResults(routing_id(), results));
67 }
68
69 void InstantClient::UpOrDownKeyPressed(int count) {
70 Send(new ChromeViewMsg_SearchBoxUpOrDownKeyPressed(routing_id(), count));
71 }
72
73 void InstantClient::SearchModeChanged(const chrome::search::Mode& mode) {
74 Send(new ChromeViewMsg_SearchBoxModeChanged(routing_id(), mode));
75 }
76
77 void InstantClient::SendThemeBackgroundInfo(
78 const ThemeBackgroundInfo& theme_info) {
79 Send(new ChromeViewMsg_SearchBoxThemeChanged(routing_id(), theme_info));
80 }
81
82 void InstantClient::SendThemeAreaHeight(int height) {
83 Send(new ChromeViewMsg_SearchBoxThemeAreaHeightChanged(routing_id(), height));
84 }
85
86 void InstantClient::SetDisplayInstantResults(bool display_instant_results) {
87 Send(new ChromeViewMsg_SearchBoxSetDisplayInstantResults(routing_id(),
88 display_instant_results));
89 }
90
91 void InstantClient::KeyCaptureChanged(bool is_key_capture_enabled) {
92 Send(new ChromeViewMsg_SearchBoxKeyCaptureChanged(routing_id(),
93 is_key_capture_enabled));
94 }
95
96 void InstantClient::RenderViewCreated(
97 content::RenderViewHost* render_view_host) {
98 delegate_->RenderViewCreated();
99 }
100
101 void InstantClient::DidFinishLoad(
102 int64 /* frame_id */,
103 const GURL& /* validated_url */,
104 bool is_main_frame,
105 content::RenderViewHost* /* render_view_host */) {
106 if (is_main_frame)
107 DetermineIfPageSupportsInstant();
108 }
109
110 bool InstantClient::OnMessageReceived(const IPC::Message& message) {
111 bool handled = true;
112 IPC_BEGIN_MESSAGE_MAP(InstantClient, message)
113 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, SetSuggestions)
114 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined,
115 InstantSupportDetermined)
116 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantPreview,
117 ShowInstantPreview)
118 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_StartCapturingKeyStrokes,
119 StartCapturingKeyStrokes);
120 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_StopCapturingKeyStrokes,
121 StopCapturingKeyStrokes);
122 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate,
123 SearchBoxNavigate);
124 IPC_MESSAGE_UNHANDLED(handled = false)
125 IPC_END_MESSAGE_MAP()
126 return handled;
127 }
128
129 void InstantClient::RenderViewGone(base::TerminationStatus status) {
130 delegate_->RenderViewGone();
131 }
132
133 void InstantClient::DidCommitProvisionalLoadForFrame(
134 int64 frame_id,
135 bool is_main_frame,
136 const GURL& url,
137 content::PageTransition transition_type,
138 content::RenderViewHost* render_view_host) {
139 if (!is_main_frame)
140 return;
141 delegate_->AboutToNavigateMainFrame(url);
142 }
143
144 void InstantClient::SetSuggestions(
145 int page_id,
146 const std::vector<InstantSuggestion>& suggestions) {
147 if (web_contents()->IsActiveEntry(page_id))
148 delegate_->SetSuggestions(suggestions);
149 }
150
151 void InstantClient::InstantSupportDetermined(int page_id, bool result) {
152 if (web_contents()->IsActiveEntry(page_id))
153 delegate_->InstantSupportDetermined(result);
154 }
155
156 void InstantClient::ShowInstantPreview(int page_id,
157 InstantShownReason reason,
158 int height,
159 InstantSizeUnits units) {
160 if (web_contents()->IsActiveEntry(page_id))
161 delegate_->ShowInstantPreview(reason, height, units);
162 }
163
164 void InstantClient::StartCapturingKeyStrokes(int page_id) {
165 if (web_contents()->IsActiveEntry(page_id))
166 delegate_->StartCapturingKeyStrokes();
167 }
168
169 void InstantClient::StopCapturingKeyStrokes(int page_id) {
170 if (web_contents()->IsActiveEntry(page_id))
171 delegate_->StopCapturingKeyStrokes();
172 }
173
174 void InstantClient::SearchBoxNavigate(int page_id,
175 const GURL& url,
176 content::PageTransition transition) {
177 if (web_contents()->IsActiveEntry(page_id))
178 delegate_->NavigateToURL(url, transition);
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