OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "webkit/glue/plugins/pepper_webplugin_delegate_impl.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/ref_counted.h" |
| 9 #include "webkit/glue/plugins/pepper_device_context_2d.h" |
| 10 #include "webkit/glue/plugins/pepper_plugin_instance.h" |
| 11 #include "webkit/glue/plugins/pepper_plugin_module.h" |
| 12 #include "webkit/glue/plugins/webplugin.h" |
| 13 |
| 14 namespace pepper { |
| 15 |
| 16 WebPluginDelegateImpl::WebPluginDelegateImpl(PluginInstance* instance) |
| 17 : instance_(instance), |
| 18 web_plugin_(NULL) { |
| 19 } |
| 20 |
| 21 WebPluginDelegateImpl::~WebPluginDelegateImpl() { |
| 22 } |
| 23 |
| 24 // static |
| 25 WebPluginDelegateImpl* WebPluginDelegateImpl::Create(PluginDelegate* delegate, |
| 26 const FilePath& filename) { |
| 27 scoped_refptr<PluginModule> module = PluginModule::CreateModule(filename); |
| 28 if (!module.get()) |
| 29 return NULL; |
| 30 |
| 31 scoped_refptr<PluginInstance> instance = module->CreateInstance(delegate); |
| 32 return new WebPluginDelegateImpl(instance.get()); |
| 33 } |
| 34 |
| 35 bool WebPluginDelegateImpl::Initialize( |
| 36 const GURL& url, |
| 37 const std::vector<std::string>& arg_names, |
| 38 const std::vector<std::string>& arg_values, |
| 39 webkit_glue::WebPlugin* plugin, |
| 40 bool load_manually) { |
| 41 web_plugin_ = plugin; |
| 42 |
| 43 if (!instance_->Initialize(arg_names, arg_values)) { |
| 44 LOG(WARNING) << "Plugin instance initialization failed."; |
| 45 return false; |
| 46 } |
| 47 |
| 48 // Declare we're in Windowless mode to WebKit. |
| 49 web_plugin_->SetWindow(0); |
| 50 return true; |
| 51 } |
| 52 |
| 53 void WebPluginDelegateImpl::PluginDestroyed() { |
| 54 // TODO(brettw) we may need something like in the NPAPI version that checks |
| 55 // for reentrancy and doesn't delete until later. |
| 56 instance_->Delete(); |
| 57 delete this; |
| 58 } |
| 59 |
| 60 void WebPluginDelegateImpl::UpdateGeometry(const gfx::Rect& window_rect, |
| 61 const gfx::Rect& clip_rect) { |
| 62 window_rect_ = window_rect; |
| 63 instance_->ViewChanged(window_rect, clip_rect); |
| 64 } |
| 65 |
| 66 void WebPluginDelegateImpl::Paint(WebKit::WebCanvas* canvas, |
| 67 const gfx::Rect& rect) { |
| 68 instance_->Paint(canvas, window_rect_, rect); |
| 69 } |
| 70 |
| 71 void WebPluginDelegateImpl::Print(gfx::NativeDrawingContext hdc) { |
| 72 } |
| 73 |
| 74 void WebPluginDelegateImpl::SetFocus(bool focused) { |
| 75 } |
| 76 |
| 77 bool WebPluginDelegateImpl::HandleInputEvent(const WebKit::WebInputEvent& event, |
| 78 WebKit::WebCursorInfo* cursor) { |
| 79 return instance_->HandleInputEvent(event, cursor); |
| 80 } |
| 81 |
| 82 NPObject* WebPluginDelegateImpl::GetPluginScriptableObject() { |
| 83 return NULL; |
| 84 } |
| 85 |
| 86 void WebPluginDelegateImpl::DidFinishLoadWithReason(const GURL& url, |
| 87 NPReason reason, |
| 88 int notify_id) { |
| 89 } |
| 90 |
| 91 int WebPluginDelegateImpl::GetProcessId() { |
| 92 return -1; // TODO(brettw) work out what this should do. |
| 93 } |
| 94 |
| 95 void WebPluginDelegateImpl::SendJavaScriptStream(const GURL& url, |
| 96 const std::string& result, |
| 97 bool success, |
| 98 int notify_id) { |
| 99 } |
| 100 |
| 101 void WebPluginDelegateImpl::DidReceiveManualResponse( |
| 102 const GURL& url, |
| 103 const std::string& mime_type, |
| 104 const std::string& headers, |
| 105 uint32 expected_length, |
| 106 uint32 last_modified) { |
| 107 } |
| 108 |
| 109 void WebPluginDelegateImpl::DidReceiveManualData(const char* buffer, |
| 110 int length) { |
| 111 } |
| 112 |
| 113 void WebPluginDelegateImpl::DidFinishManualLoading() { |
| 114 } |
| 115 |
| 116 void WebPluginDelegateImpl::DidManualLoadFail() { |
| 117 } |
| 118 |
| 119 void WebPluginDelegateImpl::InstallMissingPlugin() { |
| 120 } |
| 121 |
| 122 webkit_glue::WebPluginResourceClient* |
| 123 WebPluginDelegateImpl::CreateResourceClient(unsigned long resource_id, |
| 124 const GURL& url, |
| 125 int notify_id) { |
| 126 return NULL; |
| 127 } |
| 128 |
| 129 webkit_glue::WebPluginResourceClient* |
| 130 WebPluginDelegateImpl::CreateSeekableResourceClient(unsigned long resource_id, |
| 131 int range_request_id) { |
| 132 return NULL; |
| 133 } |
| 134 |
| 135 bool WebPluginDelegateImpl::SupportsFind() { |
| 136 return false; |
| 137 } |
| 138 |
| 139 void WebPluginDelegateImpl::StartFind(const std::string& search_text, |
| 140 bool case_sensitive, |
| 141 int identifier) { |
| 142 } |
| 143 |
| 144 void WebPluginDelegateImpl::SelectFindResult(bool forward) { |
| 145 } |
| 146 |
| 147 void WebPluginDelegateImpl::StopFind() { |
| 148 } |
| 149 |
| 150 void WebPluginDelegateImpl::NumberOfFindResultsChanged(int total, |
| 151 bool final_result) { |
| 152 } |
| 153 |
| 154 void WebPluginDelegateImpl::SelectedFindResultChanged(int index) { |
| 155 } |
| 156 |
| 157 void WebPluginDelegateImpl::Zoom(int factor) { |
| 158 } |
| 159 |
| 160 } // namespace pepper |
OLD | NEW |