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

Side by Side Diff: chrome/renderer/searchbox/searchbox.cc

Issue 11413018: alternate ntp: implement searchbox api for instant overlay to adopt themes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed scott's comments Created 8 years, 1 month 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/renderer/searchbox/searchbox.h" 5 #include "chrome/renderer/searchbox/searchbox.h"
6 6
7 #include "chrome/common/render_messages.h" 7 #include "chrome/common/render_messages.h"
8 #include "chrome/renderer/searchbox/searchbox_extension.h" 8 #include "chrome/renderer/searchbox/searchbox_extension.h"
9 #include "content/public/renderer/render_view.h" 9 #include "content/public/renderer/render_view.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 const InstantAutocompleteResult* SearchBox::GetAutocompleteResultWithId( 73 const InstantAutocompleteResult* SearchBox::GetAutocompleteResultWithId(
74 size_t restricted_id) const { 74 size_t restricted_id) const {
75 if (restricted_id < last_results_base_ || 75 if (restricted_id < last_results_base_ ||
76 restricted_id >= last_results_base_ + last_autocomplete_results_.size()) 76 restricted_id >= last_results_base_ + last_autocomplete_results_.size())
77 return NULL; 77 return NULL;
78 return &last_autocomplete_results_[restricted_id - last_results_base_]; 78 return &last_autocomplete_results_[restricted_id - last_results_base_];
79 } 79 }
80 80
81 const ThemeBackgroundInfo& SearchBox::GetThemeBackgroundInfo() {
82 return theme_info_;
palmer 2012/11/19 18:26:51 Validate the theme_info_ struct's members here. Th
kuan 2012/11/19 22:06:07 i validate everything in SearchBoxExtensions.
83 }
84
85 int SearchBox::GetThemeAreaHeight() {
86 return theme_area_height_;
87 }
88
81 bool SearchBox::OnMessageReceived(const IPC::Message& message) { 89 bool SearchBox::OnMessageReceived(const IPC::Message& message) {
82 bool handled = true; 90 bool handled = true;
83 IPC_BEGIN_MESSAGE_MAP(SearchBox, message) 91 IPC_BEGIN_MESSAGE_MAP(SearchBox, message)
84 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxChange, OnChange) 92 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxChange, OnChange)
85 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSubmit, OnSubmit) 93 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSubmit, OnSubmit)
86 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxCancel, OnCancel) 94 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxCancel, OnCancel)
87 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxResize, OnResize) 95 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxResize, OnResize)
88 IPC_MESSAGE_HANDLER(ChromeViewMsg_DetermineIfPageSupportsInstant, 96 IPC_MESSAGE_HANDLER(ChromeViewMsg_DetermineIfPageSupportsInstant,
89 OnDetermineIfPageSupportsInstant) 97 OnDetermineIfPageSupportsInstant)
90 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxAutocompleteResults, 98 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxAutocompleteResults,
91 OnAutocompleteResults) 99 OnAutocompleteResults)
92 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxUpOrDownKeyPressed, 100 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxUpOrDownKeyPressed,
93 OnUpOrDownKeyPressed) 101 OnUpOrDownKeyPressed)
94 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxActiveTabModeChanged, 102 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxActiveTabModeChanged,
95 OnActiveTabModeChanged) 103 OnActiveTabModeChanged)
104 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxThemeChanged,
105 OnThemeChanged)
106 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxThemeAreaHeightChanged,
107 OnThemeAreaHeightChanged)
96 IPC_MESSAGE_UNHANDLED(handled = false) 108 IPC_MESSAGE_UNHANDLED(handled = false)
97 IPC_END_MESSAGE_MAP() 109 IPC_END_MESSAGE_MAP()
98 return handled; 110 return handled;
99 } 111 }
100 112
101 void SearchBox::OnChange(const string16& query, 113 void SearchBox::OnChange(const string16& query,
102 bool verbatim, 114 bool verbatim,
103 size_t selection_start, 115 size_t selection_start,
104 size_t selection_end) { 116 size_t selection_end) {
105 query_ = query; 117 query_ = query;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } 181 }
170 182
171 void SearchBox::OnActiveTabModeChanged(bool active_tab_is_ntp) { 183 void SearchBox::OnActiveTabModeChanged(bool active_tab_is_ntp) {
172 active_tab_is_ntp_ = active_tab_is_ntp; 184 active_tab_is_ntp_ = active_tab_is_ntp;
173 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { 185 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
174 extensions_v8::SearchBoxExtension::DispatchContextChange( 186 extensions_v8::SearchBoxExtension::DispatchContextChange(
175 render_view()->GetWebView()->mainFrame()); 187 render_view()->GetWebView()->mainFrame());
176 } 188 }
177 } 189 }
178 190
191 void SearchBox::OnThemeChanged(const ThemeBackgroundInfo& theme_info) {
192 theme_info_ = theme_info;
193 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
194 extensions_v8::SearchBoxExtension::DispatchThemeChange(
195 render_view()->GetWebView()->mainFrame());
196 }
197 }
198
199 void SearchBox::OnThemeAreaHeightChanged(int height) {
200 theme_area_height_ = height;
201 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
202 extensions_v8::SearchBoxExtension::DispatchThemeAreaHeightChange(
203 render_view()->GetWebView()->mainFrame());
204 }
205 }
206
179 void SearchBox::Reset() { 207 void SearchBox::Reset() {
180 query_.clear(); 208 query_.clear();
181 verbatim_ = false; 209 verbatim_ = false;
182 selection_start_ = 0; 210 selection_start_ = 0;
183 selection_end_ = 0; 211 selection_end_ = 0;
184 results_base_ = 0; 212 results_base_ = 0;
185 rect_ = gfx::Rect(); 213 rect_ = gfx::Rect();
186 autocomplete_results_.clear(); 214 autocomplete_results_.clear();
187 active_tab_is_ntp_ = false; 215 active_tab_is_ntp_ = false;
sreeram 2012/11/19 18:12:02 Clear the newly added variables here?
kuan 2012/11/19 22:06:07 Done. also added to initializer list.
188 } 216 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698