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

Side by Side Diff: chrome/browser/plugin_process_host_mac.cc

Issue 6538111: Move the rest of the core files in chrome\browser to content\browser.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/plugin_process_host.cc ('k') | chrome/browser/plugin_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 <Carbon/Carbon.h>
6
7 #include "build/build_config.h"
8
9 #include <vector>
10
11 #include "base/logging.h"
12 #include "base/mac/mac_util.h"
13 #include "chrome/browser/browser_thread.h"
14 #include "chrome/browser/plugin_process_host.h"
15 #include "chrome/common/plugin_messages.h"
16 #include "ui/gfx/rect.h"
17
18 void PluginProcessHost::OnPluginSelectWindow(uint32 window_id,
19 gfx::Rect window_rect,
20 bool modal) {
21 plugin_visible_windows_set_.insert(window_id);
22 if (modal)
23 plugin_modal_windows_set_.insert(window_id);
24 }
25
26 void PluginProcessHost::OnPluginShowWindow(uint32 window_id,
27 gfx::Rect window_rect,
28 bool modal) {
29 plugin_visible_windows_set_.insert(window_id);
30 if (modal)
31 plugin_modal_windows_set_.insert(window_id);
32 CGRect window_bounds = {
33 { window_rect.x(), window_rect.y() },
34 { window_rect.width(), window_rect.height() }
35 };
36 CGRect main_display_bounds = CGDisplayBounds(CGMainDisplayID());
37 if (CGRectEqualToRect(window_bounds, main_display_bounds) &&
38 (plugin_fullscreen_windows_set_.find(window_id) ==
39 plugin_fullscreen_windows_set_.end())) {
40 plugin_fullscreen_windows_set_.insert(window_id);
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.
43 // (but only if we haven't already seen this fullscreen window, since
44 // otherwise our refcounting can get skewed).
45 BrowserThread::PostTask(
46 BrowserThread::UI, FROM_HERE,
47 NewRunnableFunction(base::mac::RequestFullScreen,
48 base::mac::kFullScreenModeHideAll));
49 }
50 }
51
52 // Must be called on the UI thread.
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.
55 static void ReleasePluginFullScreen(pid_t plugin_pid) {
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.
58 base::mac::ActivateProcess(base::GetCurrentProcId());
59 base::mac::ReleaseFullScreen(base::mac::kFullScreenModeHideAll);
60 if (plugin_pid != -1) {
61 base::mac::ActivateProcess(plugin_pid);
62 }
63 }
64
65 void PluginProcessHost::OnPluginHideWindow(uint32 window_id,
66 gfx::Rect window_rect) {
67 bool had_windows = !plugin_visible_windows_set_.empty();
68 plugin_visible_windows_set_.erase(window_id);
69 bool browser_needs_activation = had_windows &&
70 plugin_visible_windows_set_.empty();
71
72 plugin_modal_windows_set_.erase(window_id);
73 if (plugin_fullscreen_windows_set_.find(window_id) !=
74 plugin_fullscreen_windows_set_.end()) {
75 plugin_fullscreen_windows_set_.erase(window_id);
76 pid_t plugin_pid = browser_needs_activation ? -1 : handle();
77 browser_needs_activation = false;
78 BrowserThread::PostTask(
79 BrowserThread::UI, FROM_HERE,
80 NewRunnableFunction(ReleasePluginFullScreen, plugin_pid));
81 }
82
83 if (browser_needs_activation) {
84 BrowserThread::PostTask(
85 BrowserThread::UI, FROM_HERE,
86 NewRunnableFunction(base::mac::ActivateProcess,
87 base::GetCurrentProcId()));
88 }
89 }
90
91 void PluginProcessHost::OnAppActivation() {
92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
93
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.
96 if (!plugin_modal_windows_set_.empty()) {
97 BrowserThread::PostTask(
98 BrowserThread::UI, FROM_HERE,
99 NewRunnableFunction(base::mac::ActivateProcess, handle()));
100 }
101 }
102
103 void PluginProcessHost::OnPluginSetCursorVisibility(bool visible) {
104 if (plugin_cursor_visible_ != visible) {
105 plugin_cursor_visible_ = visible;
106 BrowserThread::PostTask(
107 BrowserThread::UI, FROM_HERE,
108 NewRunnableFunction(base::mac::SetCursorVisibility,
109 visible));
110 }
111 }
OLDNEW
« no previous file with comments | « chrome/browser/plugin_process_host.cc ('k') | chrome/browser/plugin_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698