diff options
author | Ben Murdoch <benm@google.com> | 2010-07-29 17:14:53 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-08-04 14:29:45 +0100 |
commit | c407dc5cd9bdc5668497f21b26b09d988ab439de (patch) | |
tree | 7eaf8707c0309516bdb042ad976feedaf72b0bb1 /webkit/glue/plugins/carbon_plugin_window_tracker_mac.cc | |
parent | 0998b1cdac5733f299c12d88bc31ef9c8035b8fa (diff) | |
download | external_chromium-c407dc5cd9bdc5668497f21b26b09d988ab439de.zip external_chromium-c407dc5cd9bdc5668497f21b26b09d988ab439de.tar.gz external_chromium-c407dc5cd9bdc5668497f21b26b09d988ab439de.tar.bz2 |
Merge Chromium src@r53293
Change-Id: Ia79acf8670f385cee48c45b0a75371d8e950af34
Diffstat (limited to 'webkit/glue/plugins/carbon_plugin_window_tracker_mac.cc')
-rw-r--r-- | webkit/glue/plugins/carbon_plugin_window_tracker_mac.cc | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/webkit/glue/plugins/carbon_plugin_window_tracker_mac.cc b/webkit/glue/plugins/carbon_plugin_window_tracker_mac.cc new file mode 100644 index 0000000..6131b45 --- /dev/null +++ b/webkit/glue/plugins/carbon_plugin_window_tracker_mac.cc @@ -0,0 +1,55 @@ +// 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/carbon_plugin_window_tracker_mac.h" + +CarbonPluginWindowTracker::CarbonPluginWindowTracker() { +} + +CarbonPluginWindowTracker* CarbonPluginWindowTracker::SharedInstance() { + static CarbonPluginWindowTracker* tracker = new CarbonPluginWindowTracker(); + return tracker; +} + +WindowRef CarbonPluginWindowTracker::CreateDummyWindowForDelegate( + WebPluginDelegateImpl* delegate) { + // 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, + kWindowNoTitleBarAttribute, + &window_bounds, + &new_ref) == noErr) { + window_to_delegate_map_[new_ref] = delegate; + delegate_to_window_map_[delegate] = new_ref; + } + return new_ref; +} + +WebPluginDelegateImpl* CarbonPluginWindowTracker::GetDelegateForDummyWindow( + WindowRef window) const { + WindowToDelegateMap::const_iterator i = window_to_delegate_map_.find(window); + if (i != window_to_delegate_map_.end()) + return i->second; + return NULL; +} + +WindowRef CarbonPluginWindowTracker::GetDummyWindowForDelegate( + WebPluginDelegateImpl* delegate) const { + DelegateToWindowMap::const_iterator i = + delegate_to_window_map_.find(delegate); + if (i != delegate_to_window_map_.end()) + return i->second; + return NULL; +} + +void CarbonPluginWindowTracker::DestroyDummyWindowForDelegate( + WebPluginDelegateImpl* delegate, WindowRef window) { + DCHECK(GetDelegateForDummyWindow(window) == delegate); + window_to_delegate_map_.erase(window); + delegate_to_window_map_.erase(delegate); + if (window) // Check just in case the initial window creation failed. + DisposeWindow(window); +} |