OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/webplugin_delegate_proxy.h" | 5 #include "chrome/renderer/webplugin_delegate_proxy.h" |
6 | 6 |
7 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/ref_counted.h" | 17 #include "base/ref_counted.h" |
| 18 #include "base/scoped_ptr.h" |
18 #include "base/string_split.h" | 19 #include "base/string_split.h" |
19 #include "base/string_util.h" | 20 #include "base/string_util.h" |
20 #include "base/sys_info.h" | 21 #include "base/sys_info.h" |
21 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
22 #include "chrome/common/child_process_logging.h" | 23 #include "chrome/common/child_process_logging.h" |
23 #include "chrome/common/plugin_messages.h" | 24 #include "chrome/common/plugin_messages.h" |
24 #include "chrome/common/render_messages.h" | 25 #include "chrome/common/render_messages.h" |
25 #include "chrome/plugin/npobject_proxy.h" | 26 #include "chrome/plugin/npobject_proxy.h" |
26 #include "chrome/plugin/npobject_stub.h" | 27 #include "chrome/plugin/npobject_stub.h" |
27 #include "chrome/plugin/npobject_util.h" | 28 #include "chrome/plugin/npobject_util.h" |
28 #include "chrome/renderer/command_buffer_proxy.h" | 29 #include "chrome/renderer/command_buffer_proxy.h" |
29 #include "chrome/renderer/plugin_channel_host.h" | 30 #include "chrome/renderer/plugin_channel_host.h" |
30 #include "chrome/renderer/render_thread.h" | 31 #include "chrome/renderer/render_thread.h" |
31 #include "chrome/renderer/render_view.h" | 32 #include "chrome/renderer/render_view.h" |
32 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
33 #include "grit/renderer_resources.h" | 34 #include "grit/renderer_resources.h" |
34 #include "ipc/ipc_channel_handle.h" | 35 #include "ipc/ipc_channel_handle.h" |
35 #include "net/base/mime_util.h" | 36 #include "net/base/mime_util.h" |
36 #include "printing/native_metafile.h" | |
37 #include "skia/ext/platform_canvas.h" | 37 #include "skia/ext/platform_canvas.h" |
38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragData.h" | 40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragData.h" |
41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" | 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" |
44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
45 #include "ui/base/resource/resource_bundle.h" | 45 #include "ui/base/resource/resource_bundle.h" |
46 #include "ui/gfx/blit.h" | 46 #include "ui/gfx/blit.h" |
47 #include "ui/gfx/canvas_skia.h" | 47 #include "ui/gfx/canvas_skia.h" |
48 #include "ui/gfx/native_widget_types.h" | 48 #include "ui/gfx/native_widget_types.h" |
49 #include "ui/gfx/size.h" | 49 #include "ui/gfx/size.h" |
50 #include "webkit/plugins/npapi/webplugin.h" | 50 #include "webkit/plugins/npapi/webplugin.h" |
51 #include "webkit/glue/webkit_glue.h" | 51 #include "webkit/glue/webkit_glue.h" |
52 | 52 |
53 #if defined(OS_POSIX) | 53 #if defined(OS_POSIX) |
54 #include "ipc/ipc_channel_posix.h" | 54 #include "ipc/ipc_channel_posix.h" |
55 #endif | 55 #endif |
56 | 56 |
| 57 #if defined(OS_WIN) |
| 58 #include "printing/native_metafile_factory.h" |
| 59 #include "printing/native_metafile.h" |
| 60 #endif |
| 61 |
57 using WebKit::WebBindings; | 62 using WebKit::WebBindings; |
58 using WebKit::WebCursorInfo; | 63 using WebKit::WebCursorInfo; |
59 using WebKit::WebDragData; | 64 using WebKit::WebDragData; |
60 using WebKit::WebInputEvent; | 65 using WebKit::WebInputEvent; |
61 using WebKit::WebString; | 66 using WebKit::WebString; |
62 using WebKit::WebVector; | 67 using WebKit::WebVector; |
63 using WebKit::WebView; | 68 using WebKit::WebView; |
64 | 69 |
65 // Proxy for WebPluginResourceClient. The object owns itself after creation, | 70 // Proxy for WebPluginResourceClient. The object owns itself after creation, |
66 // deleting itself after its callback has been called. | 71 // deleting itself after its callback has been called. |
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 if (!Send(new PluginMsg_Print(instance_id_, &shared_memory, &size))) | 924 if (!Send(new PluginMsg_Print(instance_id_, &shared_memory, &size))) |
920 return; | 925 return; |
921 | 926 |
922 base::SharedMemory memory(shared_memory, true); | 927 base::SharedMemory memory(shared_memory, true); |
923 if (!memory.Map(size)) { | 928 if (!memory.Map(size)) { |
924 NOTREACHED(); | 929 NOTREACHED(); |
925 return; | 930 return; |
926 } | 931 } |
927 | 932 |
928 #if defined(OS_WIN) | 933 #if defined(OS_WIN) |
929 printing::NativeMetafile metafile; | 934 scoped_ptr<printing::NativeMetafile> metafile( |
930 if (!metafile.Init(memory.memory(), size)) { | 935 printing::NativeMetafileFactory::CreateMetafile()); |
| 936 if (!metafile->Init(memory.memory(), size)) { |
931 NOTREACHED(); | 937 NOTREACHED(); |
932 return; | 938 return; |
933 } | 939 } |
934 // Playback the buffer. | 940 // Playback the buffer. |
935 metafile.Playback(context, NULL); | 941 metafile->Playback(context, NULL); |
936 #else | 942 #else |
937 // TODO(port): plugin printing. | 943 // TODO(port): plugin printing. |
938 NOTIMPLEMENTED(); | 944 NOTIMPLEMENTED(); |
939 #endif | 945 #endif |
940 } | 946 } |
941 | 947 |
942 NPObject* WebPluginDelegateProxy::GetPluginScriptableObject() { | 948 NPObject* WebPluginDelegateProxy::GetPluginScriptableObject() { |
943 if (npobject_) | 949 if (npobject_) |
944 return WebBindings::retainObject(npobject_); | 950 return WebBindings::retainObject(npobject_); |
945 | 951 |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1579 } | 1585 } |
1580 #endif | 1586 #endif |
1581 | 1587 |
1582 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, | 1588 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, |
1583 int resource_id) { | 1589 int resource_id) { |
1584 if (!plugin_) | 1590 if (!plugin_) |
1585 return; | 1591 return; |
1586 | 1592 |
1587 plugin_->URLRedirectResponse(allow, resource_id); | 1593 plugin_->URLRedirectResponse(allow, resource_id); |
1588 } | 1594 } |
OLD | NEW |