OLD | NEW |
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 #if defined(ENABLE_PEPPER) | |
6 #define PEPPER_APIS_ENABLED | |
7 #endif | |
8 | |
9 #include "chrome/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
10 | 6 |
11 #include <algorithm> | 7 #include <algorithm> |
12 #include <string> | 8 #include <string> |
13 #include <vector> | 9 #include <vector> |
14 | 10 |
15 #include "app/gfx/color_utils.h" | 11 #include "app/gfx/color_utils.h" |
16 #include "app/gfx/favicon_size.h" | 12 #include "app/gfx/favicon_size.h" |
17 #include "app/gfx/native_widget_types.h" | 13 #include "app/gfx/native_widget_types.h" |
18 #include "app/l10n_util.h" | 14 #include "app/l10n_util.h" |
(...skipping 2615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2634 url, policy_url, mime_type, &path, actual_mime_type)); | 2630 url, policy_url, mime_type, &path, actual_mime_type)); |
2635 if (path.value().empty()) | 2631 if (path.value().empty()) |
2636 return NULL; | 2632 return NULL; |
2637 | 2633 |
2638 const std::string* mime_type_to_use; | 2634 const std::string* mime_type_to_use; |
2639 if (!actual_mime_type->empty()) | 2635 if (!actual_mime_type->empty()) |
2640 mime_type_to_use = actual_mime_type; | 2636 mime_type_to_use = actual_mime_type; |
2641 else | 2637 else |
2642 mime_type_to_use = &mime_type; | 2638 mime_type_to_use = &mime_type; |
2643 | 2639 |
2644 #if defined(PEPPER_APIS_ENABLED) | 2640 bool use_pepper_host = false; |
| 2641 bool in_process_plugin = RenderProcess::current()->in_process_plugins(); |
| 2642 // Check for trusted Pepper plugins. |
2645 const char kPepperPrefix[] = "pepper-"; | 2643 const char kPepperPrefix[] = "pepper-"; |
2646 if (StartsWithASCII(*mime_type_to_use, kPepperPrefix, true)) { | 2644 if (StartsWithASCII(*mime_type_to_use, kPepperPrefix, true)) { |
2647 return WebPluginDelegatePepper::Create( | 2645 if (CommandLine::ForCurrentProcess()-> |
2648 path, *mime_type_to_use, gfx::NativeViewFromId(host_window_)); | 2646 HasSwitch(switches::kInternalPepper)) { |
| 2647 in_process_plugin = true; |
| 2648 use_pepper_host = true; |
| 2649 } else { |
| 2650 // In process Pepper plugins must be explicitly enabled. |
| 2651 return NULL; |
| 2652 } |
2649 } | 2653 } |
2650 #endif | 2654 // Check for Native Client modules. |
2651 | |
2652 bool in_process_plugin = RenderProcess::current()->in_process_plugins(); | |
2653 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInternalNaCl)) { | 2655 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInternalNaCl)) { |
2654 if (mime_type == "application/x-nacl-srpc") { | 2656 if (mime_type == "application/x-nacl-srpc") { |
2655 in_process_plugin = true; | 2657 in_process_plugin = true; |
| 2658 use_pepper_host = true; |
2656 } | 2659 } |
2657 } | 2660 } |
2658 if (in_process_plugin) { | 2661 if (in_process_plugin) { |
2659 #if defined(OS_WIN) // In-proc plugins aren't supported on Linux or Mac. | 2662 #if defined(OS_WIN) // In-proc plugins aren't supported on Linux or Mac. |
2660 return WebPluginDelegateImpl::Create( | 2663 if (use_pepper_host) { |
2661 path, *mime_type_to_use, gfx::NativeViewFromId(host_window_)); | 2664 return WebPluginDelegatePepper::Create( |
| 2665 path, *mime_type_to_use, gfx::NativeViewFromId(host_window_)); |
| 2666 } else { |
| 2667 return WebPluginDelegateImpl::Create( |
| 2668 path, *mime_type_to_use, gfx::NativeViewFromId(host_window_)); |
| 2669 } |
2662 #else | 2670 #else |
2663 NOTIMPLEMENTED(); | 2671 NOTIMPLEMENTED(); |
2664 return NULL; | 2672 return NULL; |
2665 #endif | 2673 #endif |
2666 } | 2674 } |
2667 | 2675 |
2668 return new WebPluginDelegateProxy(*mime_type_to_use, AsWeakPtr()); | 2676 return new WebPluginDelegateProxy(*mime_type_to_use, AsWeakPtr()); |
2669 } | 2677 } |
2670 | 2678 |
2671 void RenderView::CreatedPluginWindow(gfx::PluginWindowHandle window) { | 2679 void RenderView::CreatedPluginWindow(gfx::PluginWindowHandle window) { |
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3884 new PluginMsg_SignalModalDialogEvent(host_window_)); | 3892 new PluginMsg_SignalModalDialogEvent(host_window_)); |
3885 | 3893 |
3886 message->EnableMessagePumping(); // Runs a nested message loop. | 3894 message->EnableMessagePumping(); // Runs a nested message loop. |
3887 bool rv = Send(message); | 3895 bool rv = Send(message); |
3888 | 3896 |
3889 PluginChannelHost::Broadcast( | 3897 PluginChannelHost::Broadcast( |
3890 new PluginMsg_ResetModalDialogEvent(host_window_)); | 3898 new PluginMsg_ResetModalDialogEvent(host_window_)); |
3891 | 3899 |
3892 return rv; | 3900 return rv; |
3893 } | 3901 } |
OLD | NEW |