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

Side by Side Diff: content/renderer/browser_plugin/browser_plugin_manager.cc

Issue 617123005: Remove BrowserPlugin tests (only one test remaining with existing coverage) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@make_lifetime_explicit
Patch Set: More cleanup Created 6 years, 2 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
OLDNEW
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"
8 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
9 #include "base/threading/thread_local.h"
10 #include "base/values.h"
11 #include "content/common/browser_plugin/browser_plugin_constants.h" 8 #include "content/common/browser_plugin/browser_plugin_constants.h"
9 #include "content/public/renderer/browser_plugin_delegate.h"
12 #include "content/public/renderer/render_thread.h" 10 #include "content/public/renderer/render_thread.h"
13 #include "content/renderer/browser_plugin/browser_plugin.h" 11 #include "content/renderer/browser_plugin/browser_plugin.h"
14 #include "content/renderer/browser_plugin/browser_plugin_manager_factory.h"
15 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h"
16 12
17 namespace content { 13 namespace content {
18 14
19 // static 15 // static
20 BrowserPluginManagerFactory* BrowserPluginManager::factory_ = NULL;
21
22 // static
23 BrowserPluginManager* BrowserPluginManager::Create( 16 BrowserPluginManager* BrowserPluginManager::Create(
24 RenderViewImpl* render_view) { 17 RenderViewImpl* render_view) {
25 if (factory_) 18 return new BrowserPluginManager(render_view);
26 return factory_->CreateBrowserPluginManager(render_view);
27 return new BrowserPluginManagerImpl(render_view);
28 } 19 }
29 20
30 BrowserPluginManager::BrowserPluginManager(RenderViewImpl* render_view) 21 BrowserPluginManager::BrowserPluginManager(RenderViewImpl* render_view)
31 : RenderViewObserver(render_view), 22 : RenderViewObserver(render_view),
32 current_instance_id_(browser_plugin::kInstanceIDNone), 23 current_instance_id_(browser_plugin::kInstanceIDNone),
33 render_view_(render_view->AsWeakPtr()) { 24 render_view_(render_view->AsWeakPtr()) {
34 } 25 }
35 26
36 BrowserPluginManager::~BrowserPluginManager() { 27 BrowserPluginManager::~BrowserPluginManager() {
37 } 28 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 iter.Advance(); 61 iter.Advance();
71 } 62 }
72 } 63 }
73 64
74 void BrowserPluginManager::Attach(int browser_plugin_instance_id) { 65 void BrowserPluginManager::Attach(int browser_plugin_instance_id) {
75 BrowserPlugin* plugin = GetBrowserPlugin(browser_plugin_instance_id); 66 BrowserPlugin* plugin = GetBrowserPlugin(browser_plugin_instance_id);
76 if (plugin) 67 if (plugin)
77 plugin->Attach(); 68 plugin->Attach();
78 } 69 }
79 70
71 BrowserPlugin* BrowserPluginManager::CreateBrowserPlugin(
72 RenderViewImpl* render_view,
73 blink::WebFrame* frame,
74 scoped_ptr<BrowserPluginDelegate> delegate) {
75 return new BrowserPlugin(render_view, frame, delegate.Pass());
76 }
77
78 void BrowserPluginManager::DidCommitCompositorFrame() {
79 IDMap<BrowserPlugin>::iterator iter(&instances_);
80 while (!iter.IsAtEnd()) {
81 iter.GetCurrentValue()->DidCommitCompositorFrame();
82 iter.Advance();
83 }
84 }
85
86 bool BrowserPluginManager::OnMessageReceived(
87 const IPC::Message& message) {
88 if (BrowserPlugin::ShouldForwardToBrowserPlugin(message)) {
89 int browser_plugin_instance_id = browser_plugin::kInstanceIDNone;
90 // All allowed messages must have |browser_plugin_instance_id| as their
91 // first parameter.
92 PickleIterator iter(message);
93 bool success = iter.ReadInt(&browser_plugin_instance_id);
94 DCHECK(success);
95 BrowserPlugin* plugin = GetBrowserPlugin(browser_plugin_instance_id);
96 if (plugin && plugin->OnMessageReceived(message))
97 return true;
98 }
99
100 return false;
101 }
102
103 bool BrowserPluginManager::Send(IPC::Message* msg) {
104 return RenderThread::Get()->Send(msg);
105 }
106
80 } // namespace content 107 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698