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

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

Issue 11421079: Persist the Instant API to committed search result pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More fixes Created 8 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
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 "chrome/common/render_messages.h"
8 #include "content/public/browser/web_contents.h"
9
10 InstantClient::Delegate::~Delegate() {
11 }
12
13 InstantClient::InstantClient(Delegate* delegate) : delegate_(delegate) {
14 }
15
16 InstantClient::~InstantClient() {
17 }
18
19 void InstantClient::SetContents(content::WebContents* contents) {
20 Observe(contents);
21 }
22
23 void InstantClient::Update(const string16& text,
24 size_t selection_start,
25 size_t selection_end,
26 bool verbatim) {
27 Send(new ChromeViewMsg_SearchBoxChange(routing_id(), text, verbatim,
28 selection_start, selection_end));
29 }
30
31 void InstantClient::Submit(const string16& text) {
32 Send(new ChromeViewMsg_SearchBoxSubmit(routing_id(), text));
33 }
34
35 void InstantClient::Cancel(const string16& text) {
36 Send(new ChromeViewMsg_SearchBoxCancel(routing_id(), text));
37 }
38
39 void InstantClient::SetOmniboxBounds(const gfx::Rect& bounds) {
40 Send(new ChromeViewMsg_SearchBoxResize(routing_id(), bounds));
41 }
42
43 void InstantClient::DetermineIfPageSupportsInstant() {
44 Send(new ChromeViewMsg_DetermineIfPageSupportsInstant(routing_id()));
45 }
46
47 void InstantClient::SendAutocompleteResults(
48 const std::vector<InstantAutocompleteResult>& results) {
49 Send(new ChromeViewMsg_SearchBoxAutocompleteResults(routing_id(), results));
50 }
51
52 void InstantClient::UpOrDownKeyPressed(int count) {
53 Send(new ChromeViewMsg_SearchBoxUpOrDownKeyPressed(routing_id(), count));
54 }
55
56 void InstantClient::SearchModeChanged(const chrome::search::Mode& mode) {
57 Send(new ChromeViewMsg_SearchBoxModeChanged(routing_id(), mode));
58 }
59
60 void InstantClient::SendThemeBackgroundInfo(
61 const ThemeBackgroundInfo& theme_info) {
62 Send(new ChromeViewMsg_SearchBoxThemeChanged(routing_id(), theme_info));
63 }
64
65 void InstantClient::SendThemeAreaHeight(int height) {
66 Send(new ChromeViewMsg_SearchBoxThemeAreaHeightChanged(routing_id(), height));
67 }
68
69 void InstantClient::SetDisplayInstantResults(bool display_instant_results) {
70 Send(new ChromeViewMsg_SearchBoxSetDisplayInstantResults(routing_id(),
71 display_instant_results));
72 }
73
74 void InstantClient::DidFinishLoad(
75 int64 /* frame_id */,
76 const GURL& /* validated_url */,
77 bool is_main_frame,
78 content::RenderViewHost* /* render_view_host */) {
79 if (is_main_frame)
80 DetermineIfPageSupportsInstant();
81 }
82
83 bool InstantClient::OnMessageReceived(const IPC::Message& message) {
84 bool handled = true;
85 IPC_BEGIN_MESSAGE_MAP(InstantClient, message)
86 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, SetSuggestions)
87 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined,
88 InstantSupportDetermined)
89 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantPreview,
90 ShowInstantPreview)
91 IPC_MESSAGE_UNHANDLED(handled = false)
92 IPC_END_MESSAGE_MAP()
93 return handled;
94 }
95
96 void InstantClient::SetSuggestions(
97 int page_id,
98 const std::vector<InstantSuggestion>& suggestions) {
99 if (web_contents()->IsActiveEntry(page_id))
100 delegate_->SetSuggestions(suggestions);
101 }
102
103 void InstantClient::InstantSupportDetermined(int page_id, bool result) {
104 if (web_contents()->IsActiveEntry(page_id))
105 delegate_->InstantSupportDetermined(result);
106 }
107
108 void InstantClient::ShowInstantPreview(int page_id,
109 InstantShownReason reason,
110 int height,
111 InstantSizeUnits units) {
112 if (web_contents()->IsActiveEntry(page_id))
113 delegate_->ShowInstantPreview(reason, height, units);
114 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698