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" |
11 #include "base/feature_list.h" | 11 #include "base/feature_list.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/common/chrome_features.h" | 15 #include "chrome/common/chrome_features.h" |
| 16 #include "chrome/common/features.h" |
16 #include "chrome/common/prerender_messages.h" | 17 #include "chrome/common/prerender_messages.h" |
17 #include "chrome/common/render_messages.h" | 18 #include "chrome/common/render_messages.h" |
18 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
19 #include "chrome/grit/renderer_resources.h" | 20 #include "chrome/grit/renderer_resources.h" |
20 #include "chrome/renderer/chrome_content_renderer_client.h" | 21 #include "chrome/renderer/chrome_content_renderer_client.h" |
21 #include "chrome/renderer/content_settings_observer.h" | 22 #include "chrome/renderer/content_settings_observer.h" |
22 #include "chrome/renderer/custom_menu_commands.h" | 23 #include "chrome/renderer/custom_menu_commands.h" |
23 #include "chrome/renderer/plugins/plugin_preroller.h" | 24 #include "chrome/renderer/plugins/plugin_preroller.h" |
24 #include "chrome/renderer/plugins/plugin_uma.h" | 25 #include "chrome/renderer/plugins/plugin_uma.h" |
25 #include "components/strings/grit/components_strings.h" | 26 #include "components/strings/grit/components_strings.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 70 } |
70 | 71 |
71 ChromePluginPlaceholder::~ChromePluginPlaceholder() { | 72 ChromePluginPlaceholder::~ChromePluginPlaceholder() { |
72 RenderThread::Get()->RemoveObserver(this); | 73 RenderThread::Get()->RemoveObserver(this); |
73 if (context_menu_request_id_ && render_frame()) | 74 if (context_menu_request_id_ && render_frame()) |
74 render_frame()->CancelContextMenu(context_menu_request_id_); | 75 render_frame()->CancelContextMenu(context_menu_request_id_); |
75 | 76 |
76 if (placeholder_routing_id_ == MSG_ROUTING_NONE) | 77 if (placeholder_routing_id_ == MSG_ROUTING_NONE) |
77 return; | 78 return; |
78 RenderThread::Get()->RemoveRoute(placeholder_routing_id_); | 79 RenderThread::Get()->RemoveRoute(placeholder_routing_id_); |
79 #if defined(ENABLE_PLUGIN_INSTALLATION) | 80 #if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) |
80 if (has_host_) { | 81 if (has_host_) { |
81 RenderThread::Get()->Send(new ChromeViewHostMsg_RemovePluginPlaceholderHost( | 82 RenderThread::Get()->Send(new ChromeViewHostMsg_RemovePluginPlaceholderHost( |
82 routing_id(), placeholder_routing_id_)); | 83 routing_id(), placeholder_routing_id_)); |
83 } | 84 } |
84 #endif | 85 #endif |
85 } | 86 } |
86 | 87 |
87 // static | 88 // static |
88 bool ChromePluginPlaceholder::IsSmallContentFilterEnabled() { | 89 bool ChromePluginPlaceholder::IsSmallContentFilterEnabled() { |
89 return base::FeatureList::IsEnabled(features::kBlockSmallContent); | 90 return base::FeatureList::IsEnabled(features::kBlockSmallContent); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 177 |
177 int32_t ChromePluginPlaceholder::CreateRoutingId() { | 178 int32_t ChromePluginPlaceholder::CreateRoutingId() { |
178 placeholder_routing_id_ = RenderThread::Get()->GenerateRoutingID(); | 179 placeholder_routing_id_ = RenderThread::Get()->GenerateRoutingID(); |
179 RenderThread::Get()->AddRoute(placeholder_routing_id_, this); | 180 RenderThread::Get()->AddRoute(placeholder_routing_id_, this); |
180 return placeholder_routing_id_; | 181 return placeholder_routing_id_; |
181 } | 182 } |
182 | 183 |
183 bool ChromePluginPlaceholder::OnMessageReceived(const IPC::Message& message) { | 184 bool ChromePluginPlaceholder::OnMessageReceived(const IPC::Message& message) { |
184 bool handled = true; | 185 bool handled = true; |
185 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message) | 186 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message) |
186 #if defined(ENABLE_PLUGIN_INSTALLATION) | 187 #if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) |
187 IPC_MESSAGE_HANDLER(ChromeViewMsg_FoundMissingPlugin, OnFoundMissingPlugin) | 188 IPC_MESSAGE_HANDLER(ChromeViewMsg_FoundMissingPlugin, OnFoundMissingPlugin) |
188 IPC_MESSAGE_HANDLER(ChromeViewMsg_DidNotFindMissingPlugin, | 189 IPC_MESSAGE_HANDLER(ChromeViewMsg_DidNotFindMissingPlugin, |
189 OnDidNotFindMissingPlugin) | 190 OnDidNotFindMissingPlugin) |
190 IPC_MESSAGE_HANDLER(ChromeViewMsg_StartedDownloadingPlugin, | 191 IPC_MESSAGE_HANDLER(ChromeViewMsg_StartedDownloadingPlugin, |
191 OnStartedDownloadingPlugin) | 192 OnStartedDownloadingPlugin) |
192 IPC_MESSAGE_HANDLER(ChromeViewMsg_FinishedDownloadingPlugin, | 193 IPC_MESSAGE_HANDLER(ChromeViewMsg_FinishedDownloadingPlugin, |
193 OnFinishedDownloadingPlugin) | 194 OnFinishedDownloadingPlugin) |
194 IPC_MESSAGE_HANDLER(ChromeViewMsg_ErrorDownloadingPlugin, | 195 IPC_MESSAGE_HANDLER(ChromeViewMsg_ErrorDownloadingPlugin, |
195 OnErrorDownloadingPlugin) | 196 OnErrorDownloadingPlugin) |
196 IPC_MESSAGE_HANDLER(ChromeViewMsg_CancelledDownloadingPlugin, | 197 IPC_MESSAGE_HANDLER(ChromeViewMsg_CancelledDownloadingPlugin, |
(...skipping 24 matching lines...) Expand all Loading... |
221 void ChromePluginPlaceholder::OpenAboutPluginsCallback() { | 222 void ChromePluginPlaceholder::OpenAboutPluginsCallback() { |
222 RenderThread::Get()->Send( | 223 RenderThread::Get()->Send( |
223 new ChromeViewHostMsg_OpenAboutPlugins(routing_id())); | 224 new ChromeViewHostMsg_OpenAboutPlugins(routing_id())); |
224 } | 225 } |
225 | 226 |
226 void ChromePluginPlaceholder::ShowPermissionBubbleCallback() { | 227 void ChromePluginPlaceholder::ShowPermissionBubbleCallback() { |
227 RenderThread::Get()->Send( | 228 RenderThread::Get()->Send( |
228 new ChromeViewHostMsg_ShowFlashPermissionBubble(routing_id())); | 229 new ChromeViewHostMsg_ShowFlashPermissionBubble(routing_id())); |
229 } | 230 } |
230 | 231 |
231 #if defined(ENABLE_PLUGIN_INSTALLATION) | 232 #if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) |
232 void ChromePluginPlaceholder::OnDidNotFindMissingPlugin() { | 233 void ChromePluginPlaceholder::OnDidNotFindMissingPlugin() { |
233 SetMessage(l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_FOUND)); | 234 SetMessage(l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_FOUND)); |
234 } | 235 } |
235 | 236 |
236 void ChromePluginPlaceholder::OnFoundMissingPlugin( | 237 void ChromePluginPlaceholder::OnFoundMissingPlugin( |
237 const base::string16& plugin_name) { | 238 const base::string16& plugin_name) { |
238 if (status_ == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound) | 239 if (status_ == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound) |
239 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_FOUND, plugin_name)); | 240 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_FOUND, plugin_name)); |
240 has_host_ = true; | 241 has_host_ = true; |
241 plugin_name_ = plugin_name; | 242 plugin_name_ = plugin_name; |
(...skipping 14 matching lines...) Expand all Loading... |
256 void ChromePluginPlaceholder::OnErrorDownloadingPlugin( | 257 void ChromePluginPlaceholder::OnErrorDownloadingPlugin( |
257 const std::string& error) { | 258 const std::string& error) { |
258 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_ERROR, | 259 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_ERROR, |
259 base::UTF8ToUTF16(error))); | 260 base::UTF8ToUTF16(error))); |
260 } | 261 } |
261 | 262 |
262 void ChromePluginPlaceholder::OnCancelledDownloadingPlugin() { | 263 void ChromePluginPlaceholder::OnCancelledDownloadingPlugin() { |
263 SetMessage( | 264 SetMessage( |
264 l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_CANCELLED, plugin_name_)); | 265 l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_CANCELLED, plugin_name_)); |
265 } | 266 } |
266 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 267 #endif // BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) |
267 | 268 |
268 void ChromePluginPlaceholder::OnPluginComponentUpdateDownloading() { | 269 void ChromePluginPlaceholder::OnPluginComponentUpdateDownloading() { |
269 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOADING, plugin_name_)); | 270 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOADING, plugin_name_)); |
270 } | 271 } |
271 | 272 |
272 void ChromePluginPlaceholder::OnPluginComponentUpdateSuccess() { | 273 void ChromePluginPlaceholder::OnPluginComponentUpdateSuccess() { |
273 PluginListChanged(); | 274 PluginListChanged(); |
274 } | 275 } |
275 | 276 |
276 void ChromePluginPlaceholder::OnPluginComponentUpdateFailure() { | 277 void ChromePluginPlaceholder::OnPluginComponentUpdateFailure() { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 | 423 |
423 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 424 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
424 switches::kEnablePluginPlaceholderTesting)) { | 425 switches::kEnablePluginPlaceholderTesting)) { |
425 builder.SetMethod<void (ChromePluginPlaceholder::*)()>( | 426 builder.SetMethod<void (ChromePluginPlaceholder::*)()>( |
426 "didFinishIconRepositionForTesting", | 427 "didFinishIconRepositionForTesting", |
427 &ChromePluginPlaceholder::DidFinishIconRepositionForTestingCallback); | 428 &ChromePluginPlaceholder::DidFinishIconRepositionForTestingCallback); |
428 } | 429 } |
429 | 430 |
430 return builder; | 431 return builder; |
431 } | 432 } |
OLD | NEW |