OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/renderer/blocked_plugin.h" | 5 #include "chrome/renderer/blocked_plugin.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/string_piece.h" | 9 #include "base/string_piece.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 registrar_.Add(this, | 61 registrar_.Add(this, |
62 NotificationType::SHOULD_LOAD_PLUGINS, | 62 NotificationType::SHOULD_LOAD_PLUGINS, |
63 NotificationService::AllSources()); | 63 NotificationService::AllSources()); |
64 } | 64 } |
65 | 65 |
66 BlockedPlugin::~BlockedPlugin() {} | 66 BlockedPlugin::~BlockedPlugin() {} |
67 | 67 |
68 void BlockedPlugin::BindWebFrame(WebFrame* frame) { | 68 void BlockedPlugin::BindWebFrame(WebFrame* frame) { |
69 BindToJavascript(frame, L"plugin"); | 69 BindToJavascript(frame, L"plugin"); |
70 BindMethod("load", &BlockedPlugin::Load); | 70 BindMethod("load", &BlockedPlugin::Load); |
71 BindMethod("hide", &BlockedPlugin::Hide); | |
71 } | 72 } |
72 | 73 |
73 void BlockedPlugin::WillDestroyPlugin() { | 74 void BlockedPlugin::WillDestroyPlugin() { |
74 delete this; | 75 delete this; |
75 } | 76 } |
76 | 77 |
77 void BlockedPlugin::Observe(NotificationType type, | 78 void BlockedPlugin::Observe(NotificationType type, |
78 const NotificationSource& source, | 79 const NotificationSource& source, |
79 const NotificationDetails& details) { | 80 const NotificationDetails& details) { |
80 if (type == NotificationType::SHOULD_LOAD_PLUGINS) { | 81 if (type == NotificationType::SHOULD_LOAD_PLUGINS) { |
81 LoadPlugin(); | 82 LoadPlugin(); |
82 } else { | 83 } else { |
83 NOTREACHED(); | 84 NOTREACHED(); |
84 } | 85 } |
85 } | 86 } |
86 | 87 |
87 void BlockedPlugin::Load(const CppArgumentList& args, CppVariant* result) { | 88 void BlockedPlugin::Load(const CppArgumentList& args, CppVariant* result) { |
88 LoadPlugin(); | 89 LoadPlugin(); |
89 } | 90 } |
90 | 91 |
92 void BlockedPlugin::Hide(const CppArgumentList& args, CppVariant* result) { | |
93 WebPluginContainer* container = plugin_->container(); | |
94 container->element().setAttribute("width", "0"); | |
95 container->element().setAttribute("height", "0"); | |
Bernhard Bauer
2010/11/29 15:57:54
Is setting the element to 0x0 what we want to do?
| |
96 } | |
97 | |
91 void BlockedPlugin::LoadPlugin() { | 98 void BlockedPlugin::LoadPlugin() { |
92 CHECK(plugin_); | 99 CHECK(plugin_); |
93 WebPluginContainer* container = plugin_->container(); | 100 WebPluginContainer* container = plugin_->container(); |
94 WebPlugin* new_plugin = | 101 WebPlugin* new_plugin = |
95 render_view_->CreatePluginNoCheck(frame_, | 102 render_view_->CreatePluginNoCheck(frame_, |
96 plugin_params_); | 103 plugin_params_); |
97 if (new_plugin && new_plugin->initialize(container)) { | 104 if (new_plugin && new_plugin->initialize(container)) { |
98 container->setPlugin(new_plugin); | 105 container->setPlugin(new_plugin); |
99 container->invalidate(); | 106 container->invalidate(); |
100 container->reportGeometry(); | 107 container->reportGeometry(); |
101 plugin_->ReplayReceivedData(new_plugin); | 108 plugin_->ReplayReceivedData(new_plugin); |
102 plugin_->destroy(); | 109 plugin_->destroy(); |
103 } | 110 } |
104 } | 111 } |
OLD | NEW |