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

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

Issue 340050: Add the plumbing and test code for plugins opening files from the sandbox. Th... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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
« no previous file with comments | « chrome/renderer/webplugin_delegate_pepper.h ('k') | webkit/glue/pepper/pepper.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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #define PEPPER_APIS_ENABLED 1 5 #define PEPPER_APIS_ENABLED 1
6 6
7 #include "chrome/renderer/webplugin_delegate_pepper.h" 7 #include "chrome/renderer/webplugin_delegate_pepper.h"
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "app/gfx/blit.h" 12 #include "app/gfx/blit.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/process_util.h" 15 #include "base/process_util.h"
16 #include "base/scoped_ptr.h" 16 #include "base/scoped_ptr.h"
17 #include "base/stats_counters.h" 17 #include "base/stats_counters.h"
18 #include "base/string_util.h" 18 #include "base/string_util.h"
19 #include "chrome/common/render_messages.h"
20 #include "chrome/renderer/render_thread.h"
19 #include "webkit/api/public/WebInputEvent.h" 21 #include "webkit/api/public/WebInputEvent.h"
20 #include "webkit/glue/glue_util.h" 22 #include "webkit/glue/glue_util.h"
21 #include "webkit/glue/pepper/pepper.h" 23 #include "webkit/glue/pepper/pepper.h"
22 #include "webkit/glue/plugins/plugin_constants_win.h" 24 #include "webkit/glue/plugins/plugin_constants_win.h"
23 #include "webkit/glue/plugins/plugin_instance.h" 25 #include "webkit/glue/plugins/plugin_instance.h"
24 #include "webkit/glue/plugins/plugin_lib.h" 26 #include "webkit/glue/plugins/plugin_lib.h"
25 #include "webkit/glue/plugins/plugin_list.h" 27 #include "webkit/glue/plugins/plugin_list.h"
26 #include "webkit/glue/plugins/plugin_stream_url.h" 28 #include "webkit/glue/plugins/plugin_stream_url.h"
27 #include "webkit/glue/webkit_glue.h" 29 #include "webkit/glue/webkit_glue.h"
28 30
29 using webkit_glue::WebPlugin; 31 using webkit_glue::WebPlugin;
30 using webkit_glue::WebPluginDelegate; 32 using webkit_glue::WebPluginDelegate;
31 using webkit_glue::WebPluginResourceClient; 33 using webkit_glue::WebPluginResourceClient;
32 using WebKit::WebCursorInfo; 34 using WebKit::WebCursorInfo;
33 using WebKit::WebKeyboardEvent; 35 using WebKit::WebKeyboardEvent;
34 using WebKit::WebInputEvent; 36 using WebKit::WebInputEvent;
35 using WebKit::WebMouseEvent; 37 using WebKit::WebMouseEvent;
36 using WebKit::WebMouseWheelEvent; 38 using WebKit::WebMouseWheelEvent;
37 39
38 namespace { 40 namespace {
39 const uint32 kBytesPerPixel = 4; // Only 8888 RGBA for now. 41
42 const uint32 kBytesPerPixel = 4; // Only 8888 RGBA for now.
43
40 } // namespace 44 } // namespace
41 45
42 uint32 WebPluginDelegatePepper::next_buffer_id = 0; 46 uint32 WebPluginDelegatePepper::next_buffer_id = 0;
43 47
44 WebPluginDelegatePepper* WebPluginDelegatePepper::Create( 48 WebPluginDelegatePepper* WebPluginDelegatePepper::Create(
45 const FilePath& filename, 49 const FilePath& filename,
46 const std::string& mime_type, 50 const std::string& mime_type,
47 gfx::PluginWindowHandle containing_view) { 51 gfx::PluginWindowHandle containing_view) {
48 scoped_refptr<NPAPI::PluginLib> plugin_lib = 52 scoped_refptr<NPAPI::PluginLib> plugin_lib =
49 NPAPI::PluginLib::CreatePluginLib(filename); 53 NPAPI::PluginLib::CreatePluginLib(filename);
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 NPError WebPluginDelegatePepper::FlushRenderContext(NPRenderContext* context) { 441 NPError WebPluginDelegatePepper::FlushRenderContext(NPRenderContext* context) {
438 // TODO(brettw): we should have some kind of swapping of the canvases so we 442 // TODO(brettw): we should have some kind of swapping of the canvases so we
439 // can double buffer while avoiding this deep copy. 443 // can double buffer while avoiding this deep copy.
440 if (!plugin_canvas_->getTopPlatformDevice().accessBitmap(false).copyTo( 444 if (!plugin_canvas_->getTopPlatformDevice().accessBitmap(false).copyTo(
441 &committed_bitmap_, SkBitmap::kARGB_8888_Config)) 445 &committed_bitmap_, SkBitmap::kARGB_8888_Config))
442 return NPERR_OUT_OF_MEMORY_ERROR; 446 return NPERR_OUT_OF_MEMORY_ERROR;
443 447
444 committed_bitmap_.setIsOpaque(false); 448 committed_bitmap_.setIsOpaque(false);
445 return NPERR_NO_ERROR; 449 return NPERR_NO_ERROR;
446 } 450 }
451
452 NPError WebPluginDelegatePepper::OpenFileInSandbox(const char* file_name,
453 void** handle) {
454 *handle = NULL;
455
456 #if defined(OS_WIN)
457 FilePath file_path(UTF8ToUTF16(file_name));
458 #elif defined(OS_POSIX)
459 FilePath file_path(file_name);
460 #endif
461
462 ViewMsg_OpenFileForPluginResponse_Params result;
463 RenderThread::current()->Send(new ViewMsg_OpenFileForPlugin(
464 file_path, &result));
465
466 #if defined(OS_WIN)
467 if (!result.file_handle)
468 return NPERR_INVALID_PARAM;
469 *handle = result.file_handle;
470 #elif defined(OS_POSIX)
471 if (!result.file_handle.fd)
472 return NPERR_INVALID_PARAM;
473 *static_cast<int*>(handle) = result.file_handle.fd;
474 #endif
475
476 return NPERR_NO_ERROR;
477 }
OLDNEW
« no previous file with comments | « chrome/renderer/webplugin_delegate_pepper.h ('k') | webkit/glue/pepper/pepper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698