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

Side by Side Diff: chrome/plugin/plugin_thread.cc

Issue 399090: Mac: Simulate the OS-level focus handling that windows and linux plugins... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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/plugin/plugin_thread.h ('k') | chrome/plugin/webplugin_delegate_stub.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/plugin/plugin_thread.h" 5 #include "chrome/plugin/plugin_thread.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/process_util.h" 11 #include "base/process_util.h"
12 #include "base/thread_local.h" 12 #include "base/thread_local.h"
13 #include "chrome/common/child_process.h" 13 #include "chrome/common/child_process.h"
14 #include "chrome/common/chrome_plugin_lib.h" 14 #include "chrome/common/chrome_plugin_lib.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/plugin_messages.h" 16 #include "chrome/common/plugin_messages.h"
17 #include "chrome/common/render_messages.h" 17 #include "chrome/common/render_messages.h"
18 #include "chrome/plugin/chrome_plugin_host.h" 18 #include "chrome/plugin/chrome_plugin_host.h"
19 #include "chrome/plugin/npobject_util.h" 19 #include "chrome/plugin/npobject_util.h"
20 #include "chrome/renderer/render_thread.h" 20 #include "chrome/renderer/render_thread.h"
21 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
22 #include "webkit/glue/plugins/plugin_lib.h" 22 #include "webkit/glue/plugins/plugin_lib.h"
23 #include "webkit/glue/webkit_glue.h" 23 #include "webkit/glue/webkit_glue.h"
24 #include "webkit/glue/plugins/webplugin_delegate_impl.h"
24 25
25 static base::LazyInstance<base::ThreadLocalPointer<PluginThread> > lazy_tls( 26 static base::LazyInstance<base::ThreadLocalPointer<PluginThread> > lazy_tls(
26 base::LINKER_INITIALIZED); 27 base::LINKER_INITIALIZED);
27 28
28 PluginThread::PluginThread() 29 PluginThread::PluginThread()
29 : preloaded_plugin_module_(NULL) { 30 : preloaded_plugin_module_(NULL) {
30 plugin_path_ = 31 plugin_path_ =
31 CommandLine::ForCurrentProcess()->GetSwitchValuePath( 32 CommandLine::ForCurrentProcess()->GetSwitchValuePath(
32 switches::kPluginPath); 33 switches::kPluginPath);
33 34
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 96 }
96 97
97 PluginThread* PluginThread::current() { 98 PluginThread* PluginThread::current() {
98 return lazy_tls.Pointer()->Get(); 99 return lazy_tls.Pointer()->Get();
99 } 100 }
100 101
101 void PluginThread::OnControlMessageReceived(const IPC::Message& msg) { 102 void PluginThread::OnControlMessageReceived(const IPC::Message& msg) {
102 IPC_BEGIN_MESSAGE_MAP(PluginThread, msg) 103 IPC_BEGIN_MESSAGE_MAP(PluginThread, msg)
103 IPC_MESSAGE_HANDLER(PluginProcessMsg_CreateChannel, OnCreateChannel) 104 IPC_MESSAGE_HANDLER(PluginProcessMsg_CreateChannel, OnCreateChannel)
104 IPC_MESSAGE_HANDLER(PluginProcessMsg_PluginMessage, OnPluginMessage) 105 IPC_MESSAGE_HANDLER(PluginProcessMsg_PluginMessage, OnPluginMessage)
106 #if defined(OS_MACOSX)
107 IPC_MESSAGE_HANDLER(PluginProcessMsg_PluginFocusNotify,
108 OnPluginFocusNotify)
109 #endif
105 IPC_END_MESSAGE_MAP() 110 IPC_END_MESSAGE_MAP()
106 } 111 }
107 112
108 void PluginThread::OnCreateChannel(int renderer_id, 113 void PluginThread::OnCreateChannel(int renderer_id,
109 bool off_the_record) { 114 bool off_the_record) {
110 scoped_refptr<PluginChannel> channel = PluginChannel::GetPluginChannel( 115 scoped_refptr<PluginChannel> channel = PluginChannel::GetPluginChannel(
111 renderer_id, ChildProcess::current()->io_message_loop()); 116 renderer_id, ChildProcess::current()->io_message_loop());
112 IPC::ChannelHandle channel_handle; 117 IPC::ChannelHandle channel_handle;
113 if (channel.get()) { 118 if (channel.get()) {
114 channel_handle.name = channel->channel_name(); 119 channel_handle.name = channel->channel_name();
(...skipping 16 matching lines...) Expand all
131 ChildProcess::current()->AddRefProcess(); 136 ChildProcess::current()->AddRefProcess();
132 ChromePluginLib *chrome_plugin = ChromePluginLib::Find(plugin_path_); 137 ChromePluginLib *chrome_plugin = ChromePluginLib::Find(plugin_path_);
133 if (chrome_plugin) { 138 if (chrome_plugin) {
134 void *data_ptr = const_cast<void*>(reinterpret_cast<const void*>(&data[0])); 139 void *data_ptr = const_cast<void*>(reinterpret_cast<const void*>(&data[0]));
135 uint32 data_len = static_cast<uint32>(data.size()); 140 uint32 data_len = static_cast<uint32>(data.size());
136 chrome_plugin->functions().on_message(data_ptr, data_len); 141 chrome_plugin->functions().on_message(data_ptr, data_len);
137 } 142 }
138 ChildProcess::current()->ReleaseProcess(); 143 ChildProcess::current()->ReleaseProcess();
139 } 144 }
140 145
146 #if defined(OS_MACOSX)
147 void PluginThread::OnPluginFocusNotify(uint32 instance_id) {
148 WebPluginDelegateImpl* instance =
149 reinterpret_cast<WebPluginDelegateImpl*>(instance_id);
150 std::set<WebPluginDelegateImpl*> active_delegates =
151 WebPluginDelegateImpl::GetActiveDelegates();
152 for (std::set<WebPluginDelegateImpl*>::iterator iter =
153 active_delegates.begin();
154 iter != active_delegates.end(); iter++) {
155 (*iter)->FocusNotify(instance);
156 }
157 }
158 #endif
159
141 namespace webkit_glue { 160 namespace webkit_glue {
142 161
143 #if defined(OS_WIN) 162 #if defined(OS_WIN)
144 bool DownloadUrl(const std::string& url, HWND caller_window) { 163 bool DownloadUrl(const std::string& url, HWND caller_window) {
145 PluginThread* plugin_thread = PluginThread::current(); 164 PluginThread* plugin_thread = PluginThread::current();
146 if (!plugin_thread) { 165 if (!plugin_thread) {
147 return false; 166 return false;
148 } 167 }
149 168
150 IPC::Message* message = 169 IPC::Message* message =
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } 264 }
246 265
247 if (!result || net_error != net::OK) 266 if (!result || net_error != net::OK)
248 return false; 267 return false;
249 268
250 *proxy_list = proxy_result; 269 *proxy_list = proxy_result;
251 return true; 270 return true;
252 } 271 }
253 272
254 } // namespace webkit_glue 273 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « chrome/plugin/plugin_thread.h ('k') | chrome/plugin/webplugin_delegate_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698