| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "webkit/plugins/npapi/carbon_plugin_window_tracker_mac.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 | |
| 9 namespace webkit { | |
| 10 namespace npapi { | |
| 11 | |
| 12 CarbonPluginWindowTracker::CarbonPluginWindowTracker() {} | |
| 13 | |
| 14 CarbonPluginWindowTracker::~CarbonPluginWindowTracker() {} | |
| 15 | |
| 16 CarbonPluginWindowTracker* CarbonPluginWindowTracker::SharedInstance() { | |
| 17 static CarbonPluginWindowTracker* tracker = new CarbonPluginWindowTracker(); | |
| 18 return tracker; | |
| 19 } | |
| 20 | |
| 21 WindowRef CarbonPluginWindowTracker::CreateDummyWindowForDelegate( | |
| 22 OpaquePluginRef delegate) { | |
| 23 // The real size will be set by the plugin instance, once that size is known. | |
| 24 Rect window_bounds = { 0, 0, 100, 100 }; | |
| 25 WindowRef new_ref = NULL; | |
| 26 if (CreateNewWindow(kDocumentWindowClass, | |
| 27 kWindowNoTitleBarAttribute, | |
| 28 &window_bounds, | |
| 29 &new_ref) == noErr) { | |
| 30 window_to_delegate_map_[new_ref] = delegate; | |
| 31 delegate_to_window_map_[delegate] = new_ref; | |
| 32 } | |
| 33 return new_ref; | |
| 34 } | |
| 35 | |
| 36 OpaquePluginRef CarbonPluginWindowTracker::GetDelegateForDummyWindow( | |
| 37 WindowRef window) const { | |
| 38 WindowToDelegateMap::const_iterator i = window_to_delegate_map_.find(window); | |
| 39 if (i != window_to_delegate_map_.end()) | |
| 40 return i->second; | |
| 41 return NULL; | |
| 42 } | |
| 43 | |
| 44 WindowRef CarbonPluginWindowTracker::GetDummyWindowForDelegate( | |
| 45 OpaquePluginRef delegate) const { | |
| 46 DelegateToWindowMap::const_iterator i = | |
| 47 delegate_to_window_map_.find(delegate); | |
| 48 if (i != delegate_to_window_map_.end()) | |
| 49 return i->second; | |
| 50 return NULL; | |
| 51 } | |
| 52 | |
| 53 void CarbonPluginWindowTracker::DestroyDummyWindowForDelegate( | |
| 54 OpaquePluginRef delegate, WindowRef window) { | |
| 55 DCHECK(GetDelegateForDummyWindow(window) == delegate); | |
| 56 window_to_delegate_map_.erase(window); | |
| 57 delegate_to_window_map_.erase(delegate); | |
| 58 if (window) // Check just in case the initial window creation failed. | |
| 59 DisposeWindow(window); | |
| 60 } | |
| 61 | |
| 62 } // namespace npapi | |
| 63 } // namespace webkit | |
| OLD | NEW |