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

Unified Diff: content/child/npapi/webplugin_delegate_impl_win.cc

Issue 19761007: Move NPAPI implementation out of webkit/plugins/npapi and into content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 7 years, 5 months 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 side-by-side diff with in-line comments
Download patch
Index: content/child/npapi/webplugin_delegate_impl_win.cc
===================================================================
--- content/child/npapi/webplugin_delegate_impl_win.cc (revision 0)
+++ content/child/npapi/webplugin_delegate_impl_win.cc (working copy)
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "webkit/plugins/npapi/webplugin_delegate_impl.h"
+#include "content/child/npapi/webplugin_delegate_impl.h"
#include <map>
#include <set>
@@ -22,33 +22,30 @@
#include "base/win/iat_patch_function.h"
#include "base/win/registry.h"
#include "base/win/windows_version.h"
+#include "content/child/npapi/plugin_instance.h"
+#include "content/child/npapi/plugin_lib.h"
+#include "content/child/npapi/plugin_stream_url.h"
+#include "content/child/npapi/webplugin.h"
+#include "content/child/npapi/webplugin_ime_win.h"
+#include "content/common/plugin_constants_win.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "ui/base/win/dpi.h"
#include "ui/base/win/hwnd_util.h"
#include "webkit/common/cursors/webcursor.h"
-#include "webkit/plugins/npapi/plugin_constants_win.h"
-#include "webkit/plugins/npapi/plugin_instance.h"
-#include "webkit/plugins/npapi/plugin_lib.h"
-#include "webkit/plugins/npapi/plugin_stream_url.h"
#include "webkit/plugins/npapi/plugin_utils.h"
-#include "webkit/plugins/npapi/webplugin.h"
-#include "webkit/plugins/npapi/webplugin_ime_win.h"
#include "webkit/plugins/plugin_constants.h"
using WebKit::WebKeyboardEvent;
using WebKit::WebInputEvent;
using WebKit::WebMouseEvent;
+using webkit::WebPluginInfo;
-namespace webkit {
-namespace npapi {
+namespace content {
namespace {
const wchar_t kWebPluginDelegateProperty[] = L"WebPluginDelegateProperty";
-const wchar_t kPluginNameAtomProperty[] = L"PluginNameAtom";
-const wchar_t kPluginVersionAtomProperty[] = L"PluginVersionAtom";
-const wchar_t kDummyActivationWindowName[] = L"DummyWindowForActivation";
const wchar_t kPluginFlashThrottle[] = L"FlashThrottle";
// The fastest we are willing to process WM_USER+1 events for Flash.
@@ -201,59 +198,8 @@
return major_version;
}
-bool GetPluginPropertyFromWindow(
- HWND window, const wchar_t* plugin_atom_property,
- base::string16* plugin_property) {
- ATOM plugin_atom = reinterpret_cast<ATOM>(
- GetPropW(window, plugin_atom_property));
- if (plugin_atom != 0) {
- WCHAR plugin_property_local[MAX_PATH] = {0};
- GlobalGetAtomNameW(plugin_atom,
- plugin_property_local,
- ARRAYSIZE(plugin_property_local));
- *plugin_property = plugin_property_local;
- return true;
- }
- return false;
-}
-
} // namespace
-bool WebPluginDelegateImpl::IsPluginDelegateWindow(HWND window) {
- return ui::GetClassName(window) == base::string16(kNativeWindowClassName);
-}
-
-// static
-bool WebPluginDelegateImpl::GetPluginNameFromWindow(
- HWND window, base::string16* plugin_name) {
- return IsPluginDelegateWindow(window) &&
- GetPluginPropertyFromWindow(
- window, kPluginNameAtomProperty, plugin_name);
-}
-
-// static
-bool WebPluginDelegateImpl::GetPluginVersionFromWindow(
- HWND window, base::string16* plugin_version) {
- return IsPluginDelegateWindow(window) &&
- GetPluginPropertyFromWindow(
- window, kPluginVersionAtomProperty, plugin_version);
-}
-
-bool WebPluginDelegateImpl::IsDummyActivationWindow(HWND window) {
- if (!IsWindow(window))
- return false;
-
- wchar_t window_title[MAX_PATH + 1] = {0};
- if (GetWindowText(window, window_title, arraysize(window_title))) {
- return (0 == lstrcmpiW(window_title, kDummyActivationWindowName));
- }
- return false;
-}
-
-HWND WebPluginDelegateImpl::GetDefaultWindowParent() {
- return GetDesktopWindow();
-}
-
LRESULT CALLBACK WebPluginDelegateImpl::HandleEventMessageFilterHook(
int code, WPARAM wParam, LPARAM lParam) {
if (g_current_plugin_instance) {
@@ -512,14 +458,14 @@
// The window will be sized and shown later.
windowed_handle_ = CreateWindowEx(
WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR,
- kNativeWindowClassName,
+ webkit::npapi::kNativeWindowClassName,
0,
WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
0,
0,
0,
0,
- GetDefaultWindowParent(),
+ webkit::npapi::GetDefaultWindowParent(),
0,
GetModuleHandle(NULL),
0);
@@ -552,7 +498,7 @@
ATOM plugin_name_atom = GlobalAddAtomW(plugin_name.c_str());
DCHECK_NE(0, plugin_name_atom);
result = SetProp(windowed_handle_,
- kPluginNameAtomProperty,
+ webkit::npapi::kPluginNameAtomProperty,
reinterpret_cast<HANDLE>(plugin_name_atom));
DCHECK(result == TRUE) << "SetProp failed, last error = " <<
GetLastError();
@@ -562,7 +508,7 @@
ATOM plugin_version_atom = GlobalAddAtomW(plugin_version.c_str());
DCHECK_NE(0, plugin_version_atom);
result = SetProp(windowed_handle_,
- kPluginVersionAtomProperty,
+ webkit::npapi::kPluginVersionAtomProperty,
reinterpret_cast<HANDLE>(plugin_version_atom));
DCHECK(result == TRUE) << "SetProp failed, last error = " <<
GetLastError();
@@ -786,7 +732,7 @@
dummy_window_for_activation_ = CreateWindowEx(
0,
L"Static",
- kDummyActivationWindowName,
+ webkit::npapi::kDummyActivationWindowName,
WS_CHILD,
0,
0,
@@ -794,7 +740,7 @@
0,
// We don't know the parent of the dummy window yet, so just set it to the
// desktop and it'll get parented by the browser.
- GetDefaultWindowParent(),
+ webkit::npapi::GetDefaultWindowParent(),
0,
GetModuleHandle(NULL),
0);
@@ -927,7 +873,7 @@
// implement WM_ERASEBKGND correctly if we have a valid background brush.
wcex.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW+1);
wcex.lpszMenuName = 0;
- wcex.lpszClassName = kNativeWindowClassName;
+ wcex.lpszClassName = webkit::npapi::kNativeWindowClassName;
wcex.hIconSm = 0;
return RegisterClassEx(&wcex);
@@ -1060,11 +1006,11 @@
if (message == WM_NCDESTROY) {
RemoveProp(hwnd, kWebPluginDelegateProperty);
ATOM plugin_name_atom = reinterpret_cast<ATOM>(
- RemoveProp(hwnd, kPluginNameAtomProperty));
+ RemoveProp(hwnd, webkit::npapi::kPluginNameAtomProperty));
if (plugin_name_atom != 0)
GlobalDeleteAtom(plugin_name_atom);
ATOM plugin_version_atom = reinterpret_cast<ATOM>(
- RemoveProp(hwnd, kPluginVersionAtomProperty));
+ RemoveProp(hwnd, webkit::npapi::kPluginVersionAtomProperty));
if (plugin_version_atom != 0)
GlobalDeleteAtom(plugin_version_atom);
ClearThrottleQueueForWindow(hwnd);
@@ -1308,7 +1254,8 @@
// also require some changes in RenderWidgetHost to detect this in the
// WM_MOUSEACTIVATE handler and inform the renderer accordingly.
bool valid =
- GetParent(dummy_window_for_activation_) != GetDefaultWindowParent();
+ GetParent(dummy_window_for_activation_) !=
+ webkit::npapi::GetDefaultWindowParent();
if (valid) {
last_focus_window = ::SetFocus(dummy_window_for_activation_);
} else {
@@ -1432,7 +1379,7 @@
if (::GetCurrentThreadId() != window_thread_id) {
bool valid =
GetParent(g_current_plugin_instance->dummy_window_for_activation_) !=
- GetDefaultWindowParent();
+ webkit::npapi::GetDefaultWindowParent();
if (valid) {
window = g_current_plugin_instance->dummy_window_for_activation_;
} else {
@@ -1516,7 +1463,7 @@
void WebPluginDelegateImpl::HandleCaptureForMessage(HWND window,
UINT message) {
- if (!WebPluginDelegateImpl::IsPluginDelegateWindow(window))
+ if (!webkit::npapi::IsPluginDelegateWindow(window))
return;
switch (message) {
@@ -1543,5 +1490,4 @@
}
}
-} // namespace npapi
-} // namespace webkit
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698