summaryrefslogtreecommitdiffstats
path: root/content/plugin
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-12 18:53:34 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-12 18:53:34 +0000
commit2bcc56e08363522d5155d281fa91b5b0a1f4df49 (patch)
tree6bec0bcc7e75482bbad7946e869bf9a4cc9a3acb /content/plugin
parent09af2247b5bfac76d72e415fb6656d24fa0f1f0d (diff)
downloadchromium_src-2bcc56e08363522d5155d281fa91b5b0a1f4df49.zip
chromium_src-2bcc56e08363522d5155d281fa91b5b0a1f4df49.tar.gz
chromium_src-2bcc56e08363522d5155d281fa91b5b0a1f4df49.tar.bz2
Move content_plugin_client.h to content\public\plugin.
The plugin_carbon_interpose_mac.cc which intercepts system API's in plugin processes on the Mac has been moved to content\plugin. The plugin_carbon_interpose shared library target which lives in chrome.gyp refers to this file. This is a short term workaround while we look into switching the interposing mechanism on the mac. Changes as part of creating a Content API BUG=98716 Review URL: http://codereview.chromium.org/8224021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105128 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/plugin')
-rw-r--r--content/plugin/DEPS1
-rw-r--r--content/plugin/content_plugin_client.h23
-rw-r--r--content/plugin/plugin_carbon_interpose_mac.cc193
-rw-r--r--content/plugin/plugin_thread.cc2
4 files changed, 195 insertions, 24 deletions
diff --git a/content/plugin/DEPS b/content/plugin/DEPS
index f5b3524..6a3fdfa 100644
--- a/content/plugin/DEPS
+++ b/content/plugin/DEPS
@@ -1,5 +1,6 @@
include_rules = [
"-chrome",
+ "+content/public/plugin",
"+sandbox/src",
"+skia/ext",
"+third_party/npapi",
diff --git a/content/plugin/content_plugin_client.h b/content/plugin/content_plugin_client.h
deleted file mode 100644
index e2640d9..0000000
--- a/content/plugin/content_plugin_client.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_PLUGIN_CONTENT_PLUGIN_CLIENT_H_
-#define CONTENT_PLUGIN_CONTENT_PLUGIN_CLIENT_H_
-#pragma once
-
-#include "base/string16.h"
-#include "content/common/content_client.h"
-
-namespace content {
-
-// Embedder API for participating in plugin logic.
-class ContentPluginClient {
- public:
- // Notifies that a plugin process has started.
- virtual void PluginProcessStarted(const string16& plugin_name) = 0;
-};
-
-} // namespace content
-
-#endif // CONTENT_PLUGIN_CONTENT_PLUGIN_CLIENT_H_
diff --git a/content/plugin/plugin_carbon_interpose_mac.cc b/content/plugin/plugin_carbon_interpose_mac.cc
new file mode 100644
index 0000000..20a7d54
--- /dev/null
+++ b/content/plugin/plugin_carbon_interpose_mac.cc
@@ -0,0 +1,193 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#if !defined(__LP64__)
+
+#include <Carbon/Carbon.h>
+
+#include "content/plugin/plugin_interpose_util_mac.h"
+#include "ui/gfx/rect.h"
+#include "webkit/plugins/npapi/carbon_plugin_window_tracker_mac.h"
+
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
+// Returns true if the given window is modal.
+static bool IsModalWindow(WindowRef window) {
+ WindowModality modality = kWindowModalityNone;
+ WindowRef modal_target = NULL;
+ OSStatus status = GetWindowModality(window, &modality, &modal_target);
+ return (status == noErr) && (modality != kWindowModalityNone);
+}
+
+static bool IsContainingWindowActive(const OpaquePluginRef delegate) {
+ return mac_plugin_interposing::GetPluginWindowHasFocus(delegate);
+}
+
+static CGRect CGRectForWindow(WindowRef window) {
+ CGRect bounds = { { 0, 0 }, { 0, 0 } };
+ HIWindowGetBounds(window, kWindowContentRgn, kHICoordSpace72DPIGlobal,
+ &bounds);
+ return bounds;
+}
+
+struct WindowInfo {
+ uint32 window_id;
+ CGRect bounds;
+ WindowInfo(WindowRef window) {
+ window_id = HIWindowGetCGWindowID(window);
+ bounds = CGRectForWindow(window);
+ }
+};
+
+static void OnPluginWindowClosed(const WindowInfo& window_info) {
+ mac_plugin_interposing::NotifyBrowserOfPluginHideWindow(window_info.window_id,
+ window_info.bounds);
+}
+
+static void OnPluginWindowShown(WindowRef window) {
+ mac_plugin_interposing::NotifyBrowserOfPluginShowWindow(
+ HIWindowGetCGWindowID(window), CGRectForWindow(window),
+ IsModalWindow(window));
+}
+
+static void OnPluginWindowSelected(WindowRef window) {
+ mac_plugin_interposing::NotifyBrowserOfPluginSelectWindow(
+ HIWindowGetCGWindowID(window), CGRectForWindow(window),
+ IsModalWindow(window));
+}
+
+#pragma mark -
+
+static Boolean ChromePluginIsWindowActive(WindowRef window) {
+ const OpaquePluginRef delegate =
+ webkit::npapi::CarbonPluginWindowTracker::SharedInstance()->
+ GetDelegateForDummyWindow(window);
+ return delegate ? IsContainingWindowActive(delegate)
+ : IsWindowActive(window);
+}
+
+static Boolean ChromePluginIsWindowHilited(WindowRef window) {
+ const OpaquePluginRef delegate =
+ webkit::npapi::CarbonPluginWindowTracker::SharedInstance()->
+ GetDelegateForDummyWindow(window);
+ return delegate ? IsContainingWindowActive(delegate)
+ : IsWindowHilited(window);
+}
+
+static void ChromePluginSelectWindow(WindowRef window) {
+ mac_plugin_interposing::SwitchToPluginProcess();
+ SelectWindow(window);
+ OnPluginWindowSelected(window);
+}
+
+static void ChromePluginShowWindow(WindowRef window) {
+ mac_plugin_interposing::SwitchToPluginProcess();
+ ShowWindow(window);
+ OnPluginWindowShown(window);
+}
+
+static void ChromePluginDisposeWindow(WindowRef window) {
+ WindowInfo window_info(window);
+ DisposeWindow(window);
+ OnPluginWindowClosed(window_info);
+}
+
+static void ChromePluginHideWindow(WindowRef window) {
+ WindowInfo window_info(window);
+ HideWindow(window);
+ OnPluginWindowClosed(window_info);
+}
+
+static void ChromePluginShowHide(WindowRef window, Boolean show) {
+ if (show) {
+ mac_plugin_interposing::SwitchToPluginProcess();
+ ShowHide(window, show);
+ OnPluginWindowShown(window);
+ } else {
+ WindowInfo window_info(window);
+ ShowHide(window, show);
+ OnPluginWindowClosed(window_info);
+ }
+}
+
+static void ChromePluginReleaseWindow(WindowRef window) {
+ WindowInfo window_info(window);
+ ReleaseWindow(window);
+ OnPluginWindowClosed(window_info);
+}
+
+static void ChromePluginDisposeDialog(DialogRef dialog) {
+ WindowRef window = GetDialogWindow(dialog);
+ WindowInfo window_info(window);
+ DisposeDialog(dialog);
+ OnPluginWindowClosed(window_info);
+}
+
+static WindowPartCode ChromePluginFindWindow(Point point, WindowRef* window) {
+ OpaquePluginRef delegate = mac_plugin_interposing::GetActiveDelegate();
+ webkit::npapi::CarbonPluginWindowTracker* tracker =
+ webkit::npapi::CarbonPluginWindowTracker::SharedInstance();
+ WindowRef plugin_window = tracker->GetDummyWindowForDelegate(delegate);
+ if (plugin_window) {
+ // If plugin_window is non-NULL, then we are in the middle of routing an
+ // event to the plugin, so we know it's destined for this window already,
+ // so we don't have to worry that we'll be stealing an event meant for an
+ // overlapping window.
+ Rect window_bounds;
+ GetWindowBounds(plugin_window, kWindowContentRgn, &window_bounds);
+ if (PtInRect(point, &window_bounds)) {
+ if (window)
+ *window = plugin_window;
+ return inContent;
+ }
+ }
+ return FindWindow(point, window);
+}
+
+static OSStatus ChromePluginSetThemeCursor(ThemeCursor cursor) {
+ OpaquePluginRef delegate = mac_plugin_interposing::GetActiveDelegate();
+ if (delegate) {
+ mac_plugin_interposing::NotifyPluginOfSetThemeCursor(delegate, cursor);
+ return noErr;
+ }
+ return SetThemeCursor(cursor);
+}
+
+static void ChromePluginSetCursor(const Cursor* cursor) {
+ OpaquePluginRef delegate = mac_plugin_interposing::GetActiveDelegate();
+ if (delegate) {
+ mac_plugin_interposing::NotifyPluginOfSetCursor(delegate, cursor);
+ return;
+ }
+ return SetCursor(cursor);
+}
+
+#pragma mark -
+
+struct interpose_substitution {
+ const void* replacement;
+ const void* original;
+};
+
+#define INTERPOSE_FUNCTION(function) \
+ { reinterpret_cast<const void*>(ChromePlugin##function), \
+ reinterpret_cast<const void*>(function) }
+
+__attribute__((used)) static const interpose_substitution substitutions[]
+ __attribute__((section("__DATA, __interpose"))) = {
+ INTERPOSE_FUNCTION(IsWindowActive),
+ INTERPOSE_FUNCTION(IsWindowHilited),
+ INTERPOSE_FUNCTION(SelectWindow),
+ INTERPOSE_FUNCTION(ShowWindow),
+ INTERPOSE_FUNCTION(ShowHide),
+ INTERPOSE_FUNCTION(DisposeWindow),
+ INTERPOSE_FUNCTION(HideWindow),
+ INTERPOSE_FUNCTION(ReleaseWindow),
+ INTERPOSE_FUNCTION(DisposeDialog),
+ INTERPOSE_FUNCTION(FindWindow),
+ INTERPOSE_FUNCTION(SetThemeCursor),
+ INTERPOSE_FUNCTION(SetCursor),
+};
+
+#endif // !__LP64__
diff --git a/content/plugin/plugin_thread.cc b/content/plugin/plugin_thread.cc
index f7840df..89c8307 100644
--- a/content/plugin/plugin_thread.cc
+++ b/content/plugin/plugin_thread.cc
@@ -23,7 +23,7 @@
#include "content/common/content_switches.h"
#include "content/common/npobject_util.h"
#include "content/common/plugin_messages.h"
-#include "content/plugin/content_plugin_client.h"
+#include "content/public/plugin/content_plugin_client.h"
#include "ipc/ipc_channel_handle.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/plugins/npapi/plugin_lib.h"