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

Unified Diff: webkit/glue/plugins/fake_plugin_window_tracker_mac.cc

Issue 164100: Set up a interposing library for Carbon calls made by plugins. (Closed)
Patch Set: Review comments and files that were lost in the move Created 11 years, 4 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: webkit/glue/plugins/fake_plugin_window_tracker_mac.cc
diff --git a/webkit/glue/plugins/fake_plugin_window_tracker_mac.cc b/webkit/glue/plugins/fake_plugin_window_tracker_mac.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9f809a53ab78852a8794e5fd0f8562b89af0da74
--- /dev/null
+++ b/webkit/glue/plugins/fake_plugin_window_tracker_mac.cc
@@ -0,0 +1,49 @@
+// 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.
+
+#include "base/logging.h"
+#include "webkit/glue/plugins/fake_plugin_window_tracker_mac.h"
+
+FakePluginWindowTracker::FakePluginWindowTracker()
+ : window_to_delegate_map_(CFDictionaryCreateMutable(kCFAllocatorDefault,
+ 0, NULL, NULL)) {
+}
+
+FakePluginWindowTracker* FakePluginWindowTracker::SharedInstance() {
+ static FakePluginWindowTracker* tracker = new FakePluginWindowTracker();
+ return tracker;
+}
+
+WindowRef FakePluginWindowTracker::GenerateFakeWindowForDelegate(
+ WebPluginDelegateImpl* delegate) {
+ // TODO(stuartmorgan): Eventually we will be interposing enough that we don't
+ // even need a window, and can just use made-up identifiers, but for now we
+ // create one so that things that we don't interpose won't crash trying to use
+ // a bad WindowRef.
+
+ // The real size will be set by the plugin instance, once that size is known.
+ Rect window_bounds = { 0, 0, 100, 100 };
+ WindowRef new_ref = NULL;
+ if (CreateNewWindow(kDocumentWindowClass,
+ kWindowStandardDocumentAttributes,
+ &window_bounds,
+ &new_ref) == noErr) {
+ CFDictionaryAddValue(window_to_delegate_map_, new_ref, delegate);
+ }
+ return new_ref;
+}
+
+const WebPluginDelegateImpl* FakePluginWindowTracker::GetDelegateForFakeWindow(
+ WindowRef window) const {
+ return static_cast<const WebPluginDelegateImpl*>(
+ CFDictionaryGetValue(window_to_delegate_map_, window));
+}
+
+void FakePluginWindowTracker::RemoveFakeWindowForDelegate(
+ WebPluginDelegateImpl* delegate, WindowRef window) {
+ DCHECK(GetDelegateForFakeWindow(window) == delegate);
+ CFDictionaryRemoveValue(window_to_delegate_map_, delegate);
+ if (window) // Check just in case the initial window creation failed.
+ DisposeWindow(window);
+}
« no previous file with comments | « webkit/glue/plugins/fake_plugin_window_tracker_mac.h ('k') | webkit/glue/plugins/webplugin_delegate_impl_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698