OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <Carbon/Carbon.h> | 5 #include <Carbon/Carbon.h> |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/mac_util.h" | 12 #include "base/mac/mac_util.h" |
13 #include "chrome/browser/browser_thread.h" | 13 #include "chrome/browser/browser_thread.h" |
14 #include "chrome/browser/plugin_process_host.h" | 14 #include "chrome/browser/plugin_process_host.h" |
15 #include "chrome/common/plugin_messages.h" | 15 #include "chrome/common/plugin_messages.h" |
16 #include "gfx/rect.h" | 16 #include "gfx/rect.h" |
17 | 17 |
18 void PluginProcessHost::OnPluginSelectWindow(uint32 window_id, | 18 void PluginProcessHost::OnPluginSelectWindow(uint32 window_id, |
19 gfx::Rect window_rect, | 19 gfx::Rect window_rect, |
20 bool modal) { | 20 bool modal) { |
21 plugin_visible_windows_set_.insert(window_id); | 21 plugin_visible_windows_set_.insert(window_id); |
22 if (modal) | 22 if (modal) |
(...skipping 14 matching lines...) Expand all Loading... |
37 if (CGRectEqualToRect(window_bounds, main_display_bounds) && | 37 if (CGRectEqualToRect(window_bounds, main_display_bounds) && |
38 (plugin_fullscreen_windows_set_.find(window_id) == | 38 (plugin_fullscreen_windows_set_.find(window_id) == |
39 plugin_fullscreen_windows_set_.end())) { | 39 plugin_fullscreen_windows_set_.end())) { |
40 plugin_fullscreen_windows_set_.insert(window_id); | 40 plugin_fullscreen_windows_set_.insert(window_id); |
41 // If the plugin has just shown a window that's the same dimensions as | 41 // If the plugin has just shown a window that's the same dimensions as |
42 // the main display, hide the menubar so that it has the whole screen. | 42 // the main display, hide the menubar so that it has the whole screen. |
43 // (but only if we haven't already seen this fullscreen window, since | 43 // (but only if we haven't already seen this fullscreen window, since |
44 // otherwise our refcounting can get skewed). | 44 // otherwise our refcounting can get skewed). |
45 BrowserThread::PostTask( | 45 BrowserThread::PostTask( |
46 BrowserThread::UI, FROM_HERE, | 46 BrowserThread::UI, FROM_HERE, |
47 NewRunnableFunction(mac_util::RequestFullScreen, | 47 NewRunnableFunction(base::mac::RequestFullScreen, |
48 mac_util::kFullScreenModeHideAll)); | 48 base::mac::kFullScreenModeHideAll)); |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 // Must be called on the UI thread. | 52 // Must be called on the UI thread. |
53 // If plugin_pid is -1, the browser will be the active process on return, | 53 // If plugin_pid is -1, the browser will be the active process on return, |
54 // otherwise that process will be given focus back before this function returns. | 54 // otherwise that process will be given focus back before this function returns. |
55 static void ReleasePluginFullScreen(pid_t plugin_pid) { | 55 static void ReleasePluginFullScreen(pid_t plugin_pid) { |
56 // Releasing full screen only works if we are the frontmost process; grab | 56 // Releasing full screen only works if we are the frontmost process; grab |
57 // focus, but give it back to the plugin process if requested. | 57 // focus, but give it back to the plugin process if requested. |
58 mac_util::ActivateProcess(base::GetCurrentProcId()); | 58 base::mac::ActivateProcess(base::GetCurrentProcId()); |
59 mac_util::ReleaseFullScreen(mac_util::kFullScreenModeHideAll); | 59 base::mac::ReleaseFullScreen(base::mac::kFullScreenModeHideAll); |
60 if (plugin_pid != -1) { | 60 if (plugin_pid != -1) { |
61 mac_util::ActivateProcess(plugin_pid); | 61 base::mac::ActivateProcess(plugin_pid); |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 void PluginProcessHost::OnPluginHideWindow(uint32 window_id, | 65 void PluginProcessHost::OnPluginHideWindow(uint32 window_id, |
66 gfx::Rect window_rect) { | 66 gfx::Rect window_rect) { |
67 bool had_windows = !plugin_visible_windows_set_.empty(); | 67 bool had_windows = !plugin_visible_windows_set_.empty(); |
68 plugin_visible_windows_set_.erase(window_id); | 68 plugin_visible_windows_set_.erase(window_id); |
69 bool browser_needs_activation = had_windows && | 69 bool browser_needs_activation = had_windows && |
70 plugin_visible_windows_set_.empty(); | 70 plugin_visible_windows_set_.empty(); |
71 | 71 |
72 plugin_modal_windows_set_.erase(window_id); | 72 plugin_modal_windows_set_.erase(window_id); |
73 if (plugin_fullscreen_windows_set_.find(window_id) != | 73 if (plugin_fullscreen_windows_set_.find(window_id) != |
74 plugin_fullscreen_windows_set_.end()) { | 74 plugin_fullscreen_windows_set_.end()) { |
75 plugin_fullscreen_windows_set_.erase(window_id); | 75 plugin_fullscreen_windows_set_.erase(window_id); |
76 pid_t plugin_pid = browser_needs_activation ? -1 : handle(); | 76 pid_t plugin_pid = browser_needs_activation ? -1 : handle(); |
77 browser_needs_activation = false; | 77 browser_needs_activation = false; |
78 BrowserThread::PostTask( | 78 BrowserThread::PostTask( |
79 BrowserThread::UI, FROM_HERE, | 79 BrowserThread::UI, FROM_HERE, |
80 NewRunnableFunction(ReleasePluginFullScreen, plugin_pid)); | 80 NewRunnableFunction(ReleasePluginFullScreen, plugin_pid)); |
81 } | 81 } |
82 | 82 |
83 if (browser_needs_activation) { | 83 if (browser_needs_activation) { |
84 BrowserThread::PostTask( | 84 BrowserThread::PostTask( |
85 BrowserThread::UI, FROM_HERE, | 85 BrowserThread::UI, FROM_HERE, |
86 NewRunnableFunction(mac_util::ActivateProcess, | 86 NewRunnableFunction(base::mac::ActivateProcess, |
87 base::GetCurrentProcId())); | 87 base::GetCurrentProcId())); |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 void PluginProcessHost::OnAppActivation() { | 91 void PluginProcessHost::OnAppActivation() { |
92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
93 | 93 |
94 // If our plugin process has any modal windows up, we need to bring it forward | 94 // If our plugin process has any modal windows up, we need to bring it forward |
95 // so that they act more like an in-process modal window would. | 95 // so that they act more like an in-process modal window would. |
96 if (!plugin_modal_windows_set_.empty()) { | 96 if (!plugin_modal_windows_set_.empty()) { |
97 BrowserThread::PostTask( | 97 BrowserThread::PostTask( |
98 BrowserThread::UI, FROM_HERE, | 98 BrowserThread::UI, FROM_HERE, |
99 NewRunnableFunction(mac_util::ActivateProcess, handle())); | 99 NewRunnableFunction(base::mac::ActivateProcess, handle())); |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 void PluginProcessHost::OnPluginSetCursorVisibility(bool visible) { | 103 void PluginProcessHost::OnPluginSetCursorVisibility(bool visible) { |
104 if (plugin_cursor_visible_ != visible) { | 104 if (plugin_cursor_visible_ != visible) { |
105 plugin_cursor_visible_ = visible; | 105 plugin_cursor_visible_ = visible; |
106 BrowserThread::PostTask( | 106 BrowserThread::PostTask( |
107 BrowserThread::UI, FROM_HERE, | 107 BrowserThread::UI, FROM_HERE, |
108 NewRunnableFunction(mac_util::SetCursorVisibility, | 108 NewRunnableFunction(base::mac::SetCursorVisibility, |
109 visible)); | 109 visible)); |
110 } | 110 } |
111 } | 111 } |
OLD | NEW |