OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "webkit/glue/plugins/webplugin_delegate_impl.h" | 7 #include "webkit/glue/plugins/webplugin_delegate_impl.h" |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 user_gesture_message_posted_(this), | 97 user_gesture_message_posted_(this), |
98 user_gesture_msg_factory_(this), | 98 user_gesture_msg_factory_(this), |
99 null_event_factory_(this), | 99 null_event_factory_(this), |
100 last_mouse_x_(0), | 100 last_mouse_x_(0), |
101 last_mouse_y_(0) { | 101 last_mouse_y_(0) { |
102 memset(&window_, 0, sizeof(window_)); | 102 memset(&window_, 0, sizeof(window_)); |
103 } | 103 } |
104 | 104 |
105 WebPluginDelegateImpl::~WebPluginDelegateImpl() { | 105 WebPluginDelegateImpl::~WebPluginDelegateImpl() { |
106 FakePluginWindowTracker::SharedInstance()->RemoveFakeWindowForDelegate( | 106 FakePluginWindowTracker::SharedInstance()->RemoveFakeWindowForDelegate( |
107 this, cg_context_.window); | 107 this, reinterpret_cast<WindowRef>(cg_context_.window)); |
108 DestroyInstance(); | 108 DestroyInstance(); |
109 } | 109 } |
110 | 110 |
111 void WebPluginDelegateImpl::PluginDestroyed() { | 111 void WebPluginDelegateImpl::PluginDestroyed() { |
112 delete this; | 112 delete this; |
113 } | 113 } |
114 | 114 |
115 bool WebPluginDelegateImpl::Initialize(const GURL& url, | 115 bool WebPluginDelegateImpl::Initialize(const GURL& url, |
116 const std::vector<std::string>& arg_names
, | 116 const std::vector<std::string>& arg_names
, |
117 const std::vector<std::string>& arg_value
s, | 117 const std::vector<std::string>& arg_value
s, |
(...skipping 24 matching lines...) Expand all Loading... |
142 NPAPI::PluginInstance::SetInitializingInstance(old_instance); | 142 NPAPI::PluginInstance::SetInitializingInstance(old_instance); |
143 | 143 |
144 if (!start_result) | 144 if (!start_result) |
145 return false; | 145 return false; |
146 | 146 |
147 FakePluginWindowTracker* window_tracker = | 147 FakePluginWindowTracker* window_tracker = |
148 FakePluginWindowTracker::SharedInstance(); | 148 FakePluginWindowTracker::SharedInstance(); |
149 cg_context_.window = window_tracker->GenerateFakeWindowForDelegate(this); | 149 cg_context_.window = window_tracker->GenerateFakeWindowForDelegate(this); |
150 cg_context_.context = NULL; | 150 cg_context_.context = NULL; |
151 Rect window_bounds = { 0, 0, window_rect_.height(), window_rect_.width() }; | 151 Rect window_bounds = { 0, 0, window_rect_.height(), window_rect_.width() }; |
152 SetWindowBounds(cg_context_.window, kWindowContentRgn, &window_bounds); | 152 SetWindowBounds(reinterpret_cast<WindowRef>(cg_context_.window), |
| 153 kWindowContentRgn, &window_bounds); |
153 window_.window = &cg_context_; | 154 window_.window = &cg_context_; |
154 window_.type = NPWindowTypeWindow; | 155 window_.type = NPWindowTypeWindow; |
155 | 156 |
156 plugin->SetWindow(NULL); | 157 plugin->SetWindow(NULL); |
157 plugin_url_ = url.spec(); | 158 plugin_url_ = url.spec(); |
158 | 159 |
159 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 160 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
160 null_event_factory_.NewRunnableMethod( | 161 null_event_factory_.NewRunnableMethod( |
161 &WebPluginDelegateImpl::OnNullEvent), | 162 &WebPluginDelegateImpl::OnNullEvent), |
162 kPluginIdleThrottleDelayMs); | 163 kPluginIdleThrottleDelayMs); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 352 |
352 window_.clipRect.top = 0; | 353 window_.clipRect.top = 0; |
353 window_.clipRect.left = 0; | 354 window_.clipRect.left = 0; |
354 window_.clipRect.bottom = window_rect_.height(); | 355 window_.clipRect.bottom = window_rect_.height(); |
355 window_.clipRect.right = window_rect_.width(); | 356 window_.clipRect.right = window_rect_.width(); |
356 window_.height = window_rect_.height(); | 357 window_.height = window_rect_.height(); |
357 window_.width = window_rect_.width(); | 358 window_.width = window_rect_.width(); |
358 window_.x = 0; | 359 window_.x = 0; |
359 window_.y = 0; | 360 window_.y = 0; |
360 | 361 |
361 UpdateDummyWindowBoundsWithOffset(cg_context_.window, window_rect_.x(), | 362 UpdateDummyWindowBoundsWithOffset( |
362 window_rect_.y(), window_rect_.width(), | 363 reinterpret_cast<WindowRef>(cg_context_.window), window_rect_.x(), |
363 window_rect_.height()); | 364 window_rect_.y(), window_rect_.width(), window_rect_.height()); |
364 | 365 |
365 NPError err = instance()->NPP_SetWindow(&window_); | 366 NPError err = instance()->NPP_SetWindow(&window_); |
366 DCHECK(err == NPERR_NO_ERROR); | 367 DCHECK(err == NPERR_NO_ERROR); |
367 } | 368 } |
368 | 369 |
369 void WebPluginDelegateImpl::SetFocus() { | 370 void WebPluginDelegateImpl::SetFocus() { |
370 NPEvent focus_event = { 0 }; | 371 NPEvent focus_event = { 0 }; |
371 focus_event.what = NPEventType_GetFocusEvent; | 372 focus_event.what = NPEventType_GetFocusEvent; |
372 focus_event.when = TickCount(); | 373 focus_event.when = TickCount(); |
373 instance()->NPP_HandleEvent(&focus_event); | 374 instance()->NPP_HandleEvent(&focus_event); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 last_mouse_y_ = np_event.where.v; | 523 last_mouse_y_ = np_event.where.v; |
523 return true; // Let the recurring task actually send the event. | 524 return true; // Let the recurring task actually send the event. |
524 } | 525 } |
525 | 526 |
526 // If this is a mouse event, we need to make sure our dummy window has the | 527 // If this is a mouse event, we need to make sure our dummy window has the |
527 // correct location before we send the event to the plugin, so that any | 528 // correct location before we send the event to the plugin, so that any |
528 // coordinate conversion the plugin does will work out. | 529 // coordinate conversion the plugin does will work out. |
529 if (WebInputEventIsWebMouseEvent(event)) { | 530 if (WebInputEventIsWebMouseEvent(event)) { |
530 const WebMouseEvent* mouse_event = | 531 const WebMouseEvent* mouse_event = |
531 static_cast<const WebMouseEvent*>(&event); | 532 static_cast<const WebMouseEvent*>(&event); |
532 UpdateWindowLocation(cg_context_.window, *mouse_event); | 533 UpdateWindowLocation(reinterpret_cast<WindowRef>(cg_context_.window), |
| 534 *mouse_event); |
533 } | 535 } |
534 CGContextSaveGState(cg_context_.context); | 536 CGContextSaveGState(cg_context_.context); |
535 bool ret = instance()->NPP_HandleEvent(&np_event) != 0; | 537 bool ret = instance()->NPP_HandleEvent(&np_event) != 0; |
536 CGContextRestoreGState(cg_context_.context); | 538 CGContextRestoreGState(cg_context_.context); |
537 return ret; | 539 return ret; |
538 } | 540 } |
539 | 541 |
540 WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient( | 542 WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient( |
541 int resource_id, const GURL& url, bool notify_needed, | 543 int resource_id, const GURL& url, bool notify_needed, |
542 intptr_t notify_data, intptr_t existing_stream) { | 544 intptr_t notify_data, intptr_t existing_stream) { |
(...skipping 24 matching lines...) Expand all Loading... |
567 np_event.modifiers |= btnState; | 569 np_event.modifiers |= btnState; |
568 np_event.where.h = last_mouse_x_; | 570 np_event.where.h = last_mouse_x_; |
569 np_event.where.v = last_mouse_y_; | 571 np_event.where.v = last_mouse_y_; |
570 instance()->NPP_HandleEvent(&np_event); | 572 instance()->NPP_HandleEvent(&np_event); |
571 | 573 |
572 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 574 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
573 null_event_factory_.NewRunnableMethod( | 575 null_event_factory_.NewRunnableMethod( |
574 &WebPluginDelegateImpl::OnNullEvent), | 576 &WebPluginDelegateImpl::OnNullEvent), |
575 kPluginIdleThrottleDelayMs); | 577 kPluginIdleThrottleDelayMs); |
576 } | 578 } |
OLD | NEW |