OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/browser_plugin/browser_plugin_manager.h" | 5 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/threading/thread_local.h" | 8 #include "base/threading/thread_local.h" |
9 #include "content/common/browser_plugin_messages.h" | |
9 #include "content/public/renderer/render_thread.h" | 10 #include "content/public/renderer/render_thread.h" |
10 #include "content/renderer/browser_plugin/browser_plugin.h" | 11 #include "content/renderer/browser_plugin/browser_plugin_impl.h" |
11 #include "content/renderer/browser_plugin/browser_plugin_manager_factory.h" | 12 #include "content/renderer/browser_plugin/browser_plugin_manager_factory.h" |
12 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" | 13 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" |
13 | 14 |
14 namespace content { | 15 namespace content { |
15 | 16 |
16 // static | 17 // static |
17 BrowserPluginManagerFactory* BrowserPluginManager::factory_ = NULL; | 18 BrowserPluginManagerFactory* BrowserPluginManager::factory_ = NULL; |
18 | 19 |
19 BrowserPluginManager* BrowserPluginManager::Create( | 20 BrowserPluginManager* BrowserPluginManager::Create( |
20 RenderViewImpl* render_view) { | 21 RenderViewImpl* render_view) { |
21 if (factory_) | 22 if (factory_) |
22 return factory_->CreateBrowserPluginManager(render_view); | 23 return factory_->CreateBrowserPluginManager(render_view); |
23 return new BrowserPluginManagerImpl(render_view); | 24 return new BrowserPluginManagerImpl(render_view); |
24 } | 25 } |
25 | 26 |
26 BrowserPluginManager::BrowserPluginManager(RenderViewImpl* render_view) | 27 BrowserPluginManager::BrowserPluginManager(RenderViewImpl* render_view) |
27 : RenderViewObserver(render_view), | 28 : RenderViewObserver(render_view), |
28 render_view_(render_view->AsWeakPtr()), | 29 render_view_(render_view->AsWeakPtr()), |
29 browser_plugin_counter_(0) { | 30 browser_plugin_counter_(0) { |
30 } | 31 } |
31 | 32 |
32 BrowserPluginManager::~BrowserPluginManager() { | 33 BrowserPluginManager::~BrowserPluginManager() { |
33 } | 34 } |
34 | 35 |
35 void BrowserPluginManager::AddBrowserPlugin( | 36 void BrowserPluginManager::AddBrowserPlugin( |
36 int instance_id, | 37 int instance_id, |
37 BrowserPlugin* browser_plugin) { | 38 BrowserPluginImpl* browser_plugin) { |
38 instances_.AddWithID(browser_plugin, instance_id); | 39 instances_.AddWithID(browser_plugin, instance_id); |
39 } | 40 } |
40 | 41 |
41 void BrowserPluginManager::RemoveBrowserPlugin(int instance_id) { | 42 void BrowserPluginManager::RemoveBrowserPlugin(int instance_id) { |
42 instances_.Remove(instance_id); | 43 instances_.Remove(instance_id); |
43 } | 44 } |
44 | 45 |
45 BrowserPlugin* BrowserPluginManager::GetBrowserPlugin(int instance_id) const { | 46 BrowserPluginImpl* BrowserPluginManager::GetBrowserPlugin( |
47 int instance_id) const { | |
46 return instances_.Lookup(instance_id); | 48 return instances_.Lookup(instance_id); |
47 } | 49 } |
48 | 50 |
49 void BrowserPluginManager::SetEmbedderFocus(const RenderViewImpl* embedder, | 51 void BrowserPluginManager::SetEmbedderFocus(const RenderViewImpl* embedder, |
50 bool focused) { | 52 bool focused) { |
51 IDMap<BrowserPlugin>::iterator iter(&instances_); | 53 IDMap<BrowserPluginImpl>::iterator iter(&instances_); |
52 while (!iter.IsAtEnd()) { | 54 while (!iter.IsAtEnd()) { |
53 BrowserPlugin* browser_plugin = iter.GetCurrentValue(); | 55 BrowserPluginImpl* browser_plugin = iter.GetCurrentValue(); |
54 if (browser_plugin->render_view() == embedder) | 56 if (browser_plugin->render_view() == embedder) |
55 browser_plugin->SetEmbedderFocus(focused); | 57 browser_plugin->SetEmbedderFocus(focused); |
56 iter.Advance(); | 58 iter.Advance(); |
57 } | 59 } |
58 } | 60 } |
59 | 61 |
62 void BrowserPluginManager::RequestMessage(uint32 message_id) { | |
63 browser_plugin_messages_.insert(message_id); | |
64 } | |
65 | |
66 bool BrowserPluginManager::ShouldForwardToBrowserPlugin( | |
67 const IPC::Message& message) { | |
68 switch (message.type()) { | |
69 case BrowserPluginMsg_AdvanceFocus::ID: | |
70 case BrowserPluginMsg_GuestContentWindowReady::ID: | |
71 case BrowserPluginMsg_GuestGone::ID: | |
72 case BrowserPluginMsg_GuestResponsive::ID: | |
73 case BrowserPluginMsg_GuestUnresponsive::ID: | |
74 case BrowserPluginMsg_LoadAbort::ID: | |
75 case BrowserPluginMsg_LoadCommit::ID: | |
76 case BrowserPluginMsg_LoadRedirect::ID: | |
77 case BrowserPluginMsg_LoadStart::ID: | |
78 case BrowserPluginMsg_LoadStop::ID: | |
79 case BrowserPluginMsg_SetCursor::ID: | |
80 case BrowserPluginMsg_ShouldAcceptTouchEvents::ID: | |
81 case BrowserPluginMsg_UpdateRect::ID: | |
sadrul
2013/01/09 15:21:54
Can this default set of messages be added to brows
Fady Samuel
2013/01/09 17:41:24
Done.
| |
82 return true; | |
83 default: | |
84 break; | |
85 } | |
86 return browser_plugin_messages_.count(message.type()); | |
87 } | |
88 | |
60 } // namespace content | 89 } // namespace content |
OLD | NEW |