| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/plugins/chrome_plugin_placeholder.h" | 5 #include "chrome/renderer/plugins/chrome_plugin_placeholder.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 context_menu_request_id_(0), | 67 context_menu_request_id_(0), |
| 68 did_send_blocked_content_notification_(false) { | 68 did_send_blocked_content_notification_(false) { |
| 69 RenderThread::Get()->AddObserver(this); | 69 RenderThread::Get()->AddObserver(this); |
| 70 } | 70 } |
| 71 | 71 |
| 72 ChromePluginPlaceholder::~ChromePluginPlaceholder() { | 72 ChromePluginPlaceholder::~ChromePluginPlaceholder() { |
| 73 RenderThread::Get()->RemoveObserver(this); | 73 RenderThread::Get()->RemoveObserver(this); |
| 74 if (context_menu_request_id_ && render_frame()) | 74 if (context_menu_request_id_ && render_frame()) |
| 75 render_frame()->CancelContextMenu(context_menu_request_id_); | 75 render_frame()->CancelContextMenu(context_menu_request_id_); |
| 76 | 76 |
| 77 #if defined(ENABLE_PLUGIN_INSTALLATION) | |
| 78 if (placeholder_routing_id_ == MSG_ROUTING_NONE) | 77 if (placeholder_routing_id_ == MSG_ROUTING_NONE) |
| 79 return; | 78 return; |
| 80 RenderThread::Get()->RemoveRoute(placeholder_routing_id_); | 79 RenderThread::Get()->RemoveRoute(placeholder_routing_id_); |
| 80 #if defined(ENABLE_PLUGIN_INSTALLATION) |
| 81 if (has_host_) { | 81 if (has_host_) { |
| 82 RenderThread::Get()->Send(new ChromeViewHostMsg_RemovePluginPlaceholderHost( | 82 RenderThread::Get()->Send(new ChromeViewHostMsg_RemovePluginPlaceholderHost( |
| 83 routing_id(), placeholder_routing_id_)); | 83 routing_id(), placeholder_routing_id_)); |
| 84 } | 84 } |
| 85 #endif | 85 #endif |
| 86 } | 86 } |
| 87 | 87 |
| 88 // static | 88 // static |
| 89 bool ChromePluginPlaceholder::IsSmallContentFilterEnabled() { | 89 bool ChromePluginPlaceholder::IsSmallContentFilterEnabled() { |
| 90 return base::FeatureList::IsEnabled(features::kBlockSmallContent); | 90 return base::FeatureList::IsEnabled(features::kBlockSmallContent); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 power_saver_info.blocked_for_background_tab); | 168 power_saver_info.blocked_for_background_tab); |
| 169 | 169 |
| 170 return blocked_plugin; | 170 return blocked_plugin; |
| 171 } | 171 } |
| 172 | 172 |
| 173 void ChromePluginPlaceholder::SetStatus( | 173 void ChromePluginPlaceholder::SetStatus( |
| 174 ChromeViewHostMsg_GetPluginInfo_Status status) { | 174 ChromeViewHostMsg_GetPluginInfo_Status status) { |
| 175 status_ = status; | 175 status_ = status; |
| 176 } | 176 } |
| 177 | 177 |
| 178 #if defined(ENABLE_PLUGIN_INSTALLATION) | |
| 179 int32_t ChromePluginPlaceholder::CreateRoutingId() { | 178 int32_t ChromePluginPlaceholder::CreateRoutingId() { |
| 180 placeholder_routing_id_ = RenderThread::Get()->GenerateRoutingID(); | 179 placeholder_routing_id_ = RenderThread::Get()->GenerateRoutingID(); |
| 181 RenderThread::Get()->AddRoute(placeholder_routing_id_, this); | 180 RenderThread::Get()->AddRoute(placeholder_routing_id_, this); |
| 182 return placeholder_routing_id_; | 181 return placeholder_routing_id_; |
| 183 } | 182 } |
| 184 #endif | |
| 185 | 183 |
| 186 bool ChromePluginPlaceholder::OnMessageReceived(const IPC::Message& message) { | 184 bool ChromePluginPlaceholder::OnMessageReceived(const IPC::Message& message) { |
| 187 #if defined(ENABLE_PLUGIN_INSTALLATION) | |
| 188 bool handled = true; | 185 bool handled = true; |
| 189 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message) | 186 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message) |
| 187 #if defined(ENABLE_PLUGIN_INSTALLATION) |
| 190 IPC_MESSAGE_HANDLER(ChromeViewMsg_FoundMissingPlugin, OnFoundMissingPlugin) | 188 IPC_MESSAGE_HANDLER(ChromeViewMsg_FoundMissingPlugin, OnFoundMissingPlugin) |
| 191 IPC_MESSAGE_HANDLER(ChromeViewMsg_DidNotFindMissingPlugin, | 189 IPC_MESSAGE_HANDLER(ChromeViewMsg_DidNotFindMissingPlugin, |
| 192 OnDidNotFindMissingPlugin) | 190 OnDidNotFindMissingPlugin) |
| 193 IPC_MESSAGE_HANDLER(ChromeViewMsg_StartedDownloadingPlugin, | 191 IPC_MESSAGE_HANDLER(ChromeViewMsg_StartedDownloadingPlugin, |
| 194 OnStartedDownloadingPlugin) | 192 OnStartedDownloadingPlugin) |
| 195 IPC_MESSAGE_HANDLER(ChromeViewMsg_FinishedDownloadingPlugin, | 193 IPC_MESSAGE_HANDLER(ChromeViewMsg_FinishedDownloadingPlugin, |
| 196 OnFinishedDownloadingPlugin) | 194 OnFinishedDownloadingPlugin) |
| 197 IPC_MESSAGE_HANDLER(ChromeViewMsg_ErrorDownloadingPlugin, | 195 IPC_MESSAGE_HANDLER(ChromeViewMsg_ErrorDownloadingPlugin, |
| 198 OnErrorDownloadingPlugin) | 196 OnErrorDownloadingPlugin) |
| 199 IPC_MESSAGE_HANDLER(ChromeViewMsg_CancelledDownloadingPlugin, | 197 IPC_MESSAGE_HANDLER(ChromeViewMsg_CancelledDownloadingPlugin, |
| 200 OnCancelledDownloadingPlugin) | 198 OnCancelledDownloadingPlugin) |
| 199 #endif |
| 200 IPC_MESSAGE_HANDLER(ChromeViewMsg_PluginComponentUpdateDownloading, |
| 201 OnPluginComponentUpdateDownloading) |
| 202 IPC_MESSAGE_HANDLER(ChromeViewMsg_PluginComponentUpdateSuccess, |
| 203 OnPluginComponentUpdateSuccess) |
| 204 IPC_MESSAGE_HANDLER(ChromeViewMsg_PluginComponentUpdateFailure, |
| 205 OnPluginComponentUpdateFailure) |
| 201 IPC_MESSAGE_UNHANDLED(handled = false) | 206 IPC_MESSAGE_UNHANDLED(handled = false) |
| 202 IPC_END_MESSAGE_MAP() | 207 IPC_END_MESSAGE_MAP() |
| 203 | 208 |
| 204 if (handled) | 209 if (handled) |
| 205 return true; | 210 return true; |
| 206 #endif | |
| 207 | 211 |
| 208 // We don't swallow these messages because multiple blocked plugins and other | 212 // We don't swallow these messages because multiple blocked plugins and other |
| 209 // objects have an interest in them. | 213 // objects have an interest in them. |
| 210 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message) | 214 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message) |
| 211 IPC_MESSAGE_HANDLER(PrerenderMsg_SetIsPrerendering, OnSetIsPrerendering) | 215 IPC_MESSAGE_HANDLER(PrerenderMsg_SetIsPrerendering, OnSetIsPrerendering) |
| 212 IPC_MESSAGE_HANDLER(ChromeViewMsg_LoadBlockedPlugins, OnLoadBlockedPlugins) | 216 IPC_MESSAGE_HANDLER(ChromeViewMsg_LoadBlockedPlugins, OnLoadBlockedPlugins) |
| 213 IPC_END_MESSAGE_MAP() | 217 IPC_END_MESSAGE_MAP() |
| 214 | 218 |
| 215 return false; | 219 return false; |
| 216 } | 220 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_ERROR, | 254 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_ERROR, |
| 251 base::UTF8ToUTF16(error))); | 255 base::UTF8ToUTF16(error))); |
| 252 } | 256 } |
| 253 | 257 |
| 254 void ChromePluginPlaceholder::OnCancelledDownloadingPlugin() { | 258 void ChromePluginPlaceholder::OnCancelledDownloadingPlugin() { |
| 255 SetMessage( | 259 SetMessage( |
| 256 l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_CANCELLED, plugin_name_)); | 260 l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_CANCELLED, plugin_name_)); |
| 257 } | 261 } |
| 258 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 262 #endif // defined(ENABLE_PLUGIN_INSTALLATION) |
| 259 | 263 |
| 264 void ChromePluginPlaceholder::OnPluginComponentUpdateDownloading() { |
| 265 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOADING, plugin_name_)); |
| 266 } |
| 267 |
| 268 void ChromePluginPlaceholder::OnPluginComponentUpdateSuccess() { |
| 269 PluginListChanged(); |
| 270 } |
| 271 |
| 272 void ChromePluginPlaceholder::OnPluginComponentUpdateFailure() { |
| 273 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_ERROR_SHORT, |
| 274 plugin_name_)); |
| 275 } |
| 276 |
| 260 void ChromePluginPlaceholder::PluginListChanged() { | 277 void ChromePluginPlaceholder::PluginListChanged() { |
| 261 if (!GetFrame() || !plugin()) | 278 if (!GetFrame() || !plugin()) |
| 262 return; | 279 return; |
| 263 | 280 |
| 264 ChromeViewHostMsg_GetPluginInfo_Output output; | 281 ChromeViewHostMsg_GetPluginInfo_Output output; |
| 265 std::string mime_type(GetPluginParams().mimeType.utf8()); | 282 std::string mime_type(GetPluginParams().mimeType.utf8()); |
| 266 blink::WebString top_origin = | 283 blink::WebString top_origin = |
| 267 GetFrame()->top()->getSecurityOrigin().toString(); | 284 GetFrame()->top()->getSecurityOrigin().toString(); |
| 268 render_frame()->Send( | 285 render_frame()->Send( |
| 269 new ChromeViewHostMsg_GetPluginInfo(routing_id(), | 286 new ChromeViewHostMsg_GetPluginInfo(routing_id(), |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 | 414 |
| 398 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 415 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 399 switches::kEnablePluginPlaceholderTesting)) { | 416 switches::kEnablePluginPlaceholderTesting)) { |
| 400 builder.SetMethod<void (ChromePluginPlaceholder::*)()>( | 417 builder.SetMethod<void (ChromePluginPlaceholder::*)()>( |
| 401 "didFinishIconRepositionForTesting", | 418 "didFinishIconRepositionForTesting", |
| 402 &ChromePluginPlaceholder::DidFinishIconRepositionForTestingCallback); | 419 &ChromePluginPlaceholder::DidFinishIconRepositionForTestingCallback); |
| 403 } | 420 } |
| 404 | 421 |
| 405 return builder; | 422 return builder; |
| 406 } | 423 } |
| OLD | NEW |