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

Side by Side Diff: webkit/glue/plugins/pepper_plugin_instance.cc

Issue 2896009: add find hookup (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: update DEPS Created 10 years, 5 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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "webkit/glue/plugins/pepper_plugin_instance.h" 5 #include "webkit/glue/plugins/pepper_plugin_instance.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "gfx/rect.h" 10 #include "gfx/rect.h"
11 #include "third_party/ppapi/c/pp_instance.h" 11 #include "third_party/ppapi/c/pp_instance.h"
12 #include "third_party/ppapi/c/pp_event.h" 12 #include "third_party/ppapi/c/pp_event.h"
13 #include "third_party/ppapi/c/pp_rect.h" 13 #include "third_party/ppapi/c/pp_rect.h"
14 #include "third_party/ppapi/c/pp_resource.h" 14 #include "third_party/ppapi/c/pp_resource.h"
15 #include "third_party/ppapi/c/pp_var.h" 15 #include "third_party/ppapi/c/pp_var.h"
16 #include "third_party/ppapi/c/ppb_find.h"
16 #include "third_party/ppapi/c/ppb_instance.h" 17 #include "third_party/ppapi/c/ppb_instance.h"
18 #include "third_party/ppapi/c/ppp_find.h"
17 #include "third_party/ppapi/c/ppp_instance.h" 19 #include "third_party/ppapi/c/ppp_instance.h"
18 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" 20 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h"
19 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" 21 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h"
20 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" 22 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h"
21 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" 23 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
22 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" 24 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h"
23 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" 25 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h"
24 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" 26 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h"
25 #include "webkit/glue/plugins/pepper_device_context_2d.h" 27 #include "webkit/glue/plugins/pepper_device_context_2d.h"
26 #include "webkit/glue/plugins/pepper_event_conversion.h" 28 #include "webkit/glue/plugins/pepper_event_conversion.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 154 }
153 155
154 const PPB_Instance ppb_instance = { 156 const PPB_Instance ppb_instance = {
155 &GetWindowObject, 157 &GetWindowObject,
156 &GetOwnerElementObject, 158 &GetOwnerElementObject,
157 &BindGraphicsDeviceContext, 159 &BindGraphicsDeviceContext,
158 &IsFullFrame, 160 &IsFullFrame,
159 &SetCursor, 161 &SetCursor,
160 }; 162 };
161 163
164 void NumberOfFindResultsChanged(PP_Instance instance_id,
165 int32_t total,
166 bool final_result) {
167 PluginInstance* instance = PluginInstance::FromPPInstance(instance_id);
168 if (!instance)
169 return;
170
171 DCHECK_NE(instance->find_identifier(), -1);
172 instance->delegate()->DidChangeNumberOfFindResults(
173 instance->find_identifier(), total, final_result);
174 }
175
176 void SelectedFindResultChanged(PP_Instance instance_id,
177 int32_t index) {
178 PluginInstance* instance = PluginInstance::FromPPInstance(instance_id);
179 if (!instance)
180 return;
181
182 DCHECK_NE(instance->find_identifier(), -1);
183 instance->delegate()->DidChangeSelectedFindResult(
184 instance->find_identifier(), index);
185 }
186
187 const PPB_Find ppb_find = {
188 &NumberOfFindResultsChanged,
189 &SelectedFindResultChanged,
190 };
191
162 } // namespace 192 } // namespace
163 193
164 PluginInstance::PluginInstance(PluginDelegate* delegate, 194 PluginInstance::PluginInstance(PluginDelegate* delegate,
165 PluginModule* module, 195 PluginModule* module,
166 const PPP_Instance* instance_interface) 196 const PPP_Instance* instance_interface)
167 : delegate_(delegate), 197 : delegate_(delegate),
168 module_(module), 198 module_(module),
169 instance_interface_(instance_interface), 199 instance_interface_(instance_interface),
170 container_(NULL), 200 container_(NULL),
171 full_frame_(false), 201 full_frame_(false),
(...skipping 11 matching lines...) Expand all
183 // static 213 // static
184 const PPB_Instance* PluginInstance::GetInterface() { 214 const PPB_Instance* PluginInstance::GetInterface() {
185 return &ppb_instance; 215 return &ppb_instance;
186 } 216 }
187 217
188 // static 218 // static
189 PluginInstance* PluginInstance::FromPPInstance(PP_Instance instance) { 219 PluginInstance* PluginInstance::FromPPInstance(PP_Instance instance) {
190 return reinterpret_cast<PluginInstance*>(instance); 220 return reinterpret_cast<PluginInstance*>(instance);
191 } 221 }
192 222
223 // static
224 const PPB_Find* PluginInstance::GetFindInterface() {
225 return &ppb_find;
226 }
227
193 PP_Instance PluginInstance::GetPPInstance() { 228 PP_Instance PluginInstance::GetPPInstance() {
194 return reinterpret_cast<intptr_t>(this); 229 return reinterpret_cast<intptr_t>(this);
195 } 230 }
196 231
197 void PluginInstance::Paint(WebCanvas* canvas, 232 void PluginInstance::Paint(WebCanvas* canvas,
198 const gfx::Rect& plugin_rect, 233 const gfx::Rect& plugin_rect,
199 const gfx::Rect& paint_rect) { 234 const gfx::Rect& paint_rect) {
200 if (device_context_2d_) 235 if (device_context_2d_)
201 device_context_2d_->Paint(canvas, plugin_rect, paint_rect); 236 device_context_2d_->Paint(canvas, plugin_rect, paint_rect);
202 } 237 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 return UTF8ToUTF16(string->value()); 379 return UTF8ToUTF16(string->value());
345 } 380 }
346 381
347 void PluginInstance::Zoom(float factor, bool text_only) { 382 void PluginInstance::Zoom(float factor, bool text_only) {
348 // TODO: implement me 383 // TODO: implement me
349 } 384 }
350 385
351 bool PluginInstance::StartFind(const string16& search_text, 386 bool PluginInstance::StartFind(const string16& search_text,
352 bool case_sensitive, 387 bool case_sensitive,
353 int identifier) { 388 int identifier) {
389 if (!plugin_find_interface_) {
390 plugin_find_interface_ =
391 reinterpret_cast<const PPP_Find*>(module_->GetPluginInterface(
392 PPP_FIND_INTERFACE));
393 }
394
395 if (plugin_find_interface_)
396 return false;
397
354 find_identifier_ = identifier; 398 find_identifier_ = identifier;
355 return false; 399 return plugin_find_interface_->StartFind(
356 // TODO: implement me 400 GetPPInstance(),
401 reinterpret_cast<const char*>(search_text.c_str()),
402 case_sensitive);
357 } 403 }
358 404
359 void PluginInstance::SelectFindResult(bool forward) { 405 void PluginInstance::SelectFindResult(bool forward) {
360 // TODO: implement me 406 DCHECK(plugin_find_interface_);
407
408 plugin_find_interface_->SelectFindResult(GetPPInstance(), forward);
361 } 409 }
362 410
363 void PluginInstance::StopFind() { 411 void PluginInstance::StopFind() {
412 DCHECK(plugin_find_interface_);
413
364 find_identifier_ = -1; 414 find_identifier_ = -1;
365 // TODO: implement me 415 plugin_find_interface_->StopFind(GetPPInstance());
366 } 416 }
367 417
368 } // namespace pepper 418 } // namespace pepper
OLDNEW
« no previous file with comments | « webkit/glue/plugins/pepper_plugin_instance.h ('k') | webkit/glue/plugins/pepper_plugin_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698