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

Side by Side Diff: chrome/renderer/plugins/chrome_plugin_placeholder.cc

Issue 2154773002: Implement Just-In-Time Flash updates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First Review Pass Created 4 years, 4 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 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
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
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) {
185 bool handled = true;
187 #if defined(ENABLE_PLUGIN_INSTALLATION) 186 #if defined(ENABLE_PLUGIN_INSTALLATION)
188 bool handled = true;
189 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message) 187 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message)
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)
201 IPC_MESSAGE_UNHANDLED(handled = false) 199 IPC_MESSAGE_UNHANDLED(handled = false)
202 IPC_END_MESSAGE_MAP() 200 IPC_END_MESSAGE_MAP()
203 201
204 if (handled) 202 if (handled)
205 return true; 203 return true;
206 #endif 204 #endif
207 205
206 handled = true;
207 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message)
208 IPC_MESSAGE_HANDLER(ChromeViewMsg_PluginComponentUpdateDownloading,
Bernhard Bauer 2016/07/28 10:25:10 Couldn't you merge these message handlers into the
waffles 2016/07/28 20:06:27 Done.
209 OnPluginComponentUpdateDownloading)
210 IPC_MESSAGE_HANDLER(ChromeViewMsg_PluginComponentUpdateSuccess,
211 OnPluginComponentUpdateSuccess)
212 IPC_MESSAGE_HANDLER(ChromeViewMsg_PluginComponentUpdateFailure,
213 OnPluginComponentUpdateFailure)
214 IPC_MESSAGE_UNHANDLED(handled = false)
215 IPC_END_MESSAGE_MAP()
216
217 if (handled)
218 return true;
219
208 // We don't swallow these messages because multiple blocked plugins and other 220 // We don't swallow these messages because multiple blocked plugins and other
209 // objects have an interest in them. 221 // objects have an interest in them.
210 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message) 222 IPC_BEGIN_MESSAGE_MAP(ChromePluginPlaceholder, message)
211 IPC_MESSAGE_HANDLER(PrerenderMsg_SetIsPrerendering, OnSetIsPrerendering) 223 IPC_MESSAGE_HANDLER(PrerenderMsg_SetIsPrerendering, OnSetIsPrerendering)
212 IPC_MESSAGE_HANDLER(ChromeViewMsg_LoadBlockedPlugins, OnLoadBlockedPlugins) 224 IPC_MESSAGE_HANDLER(ChromeViewMsg_LoadBlockedPlugins, OnLoadBlockedPlugins)
213 IPC_END_MESSAGE_MAP() 225 IPC_END_MESSAGE_MAP()
214 226
215 return false; 227 return false;
216 } 228 }
217 229
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_ERROR, 262 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_ERROR,
251 base::UTF8ToUTF16(error))); 263 base::UTF8ToUTF16(error)));
252 } 264 }
253 265
254 void ChromePluginPlaceholder::OnCancelledDownloadingPlugin() { 266 void ChromePluginPlaceholder::OnCancelledDownloadingPlugin() {
255 SetMessage( 267 SetMessage(
256 l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_CANCELLED, plugin_name_)); 268 l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_CANCELLED, plugin_name_));
257 } 269 }
258 #endif // defined(ENABLE_PLUGIN_INSTALLATION) 270 #endif // defined(ENABLE_PLUGIN_INSTALLATION)
259 271
272 void ChromePluginPlaceholder::OnPluginComponentUpdateDownloading() {
273 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOADING, plugin_name_));
274 }
275
276 void ChromePluginPlaceholder::OnPluginComponentUpdateSuccess() {
277 PluginListChanged();
278 }
279
280 void ChromePluginPlaceholder::OnPluginComponentUpdateFailure() {
281 SetMessage(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_ERROR_SHORT,
282 plugin_name_));
283 }
284
260 void ChromePluginPlaceholder::PluginListChanged() { 285 void ChromePluginPlaceholder::PluginListChanged() {
261 if (!GetFrame() || !plugin()) 286 if (!GetFrame() || !plugin())
262 return; 287 return;
263 288
264 ChromeViewHostMsg_GetPluginInfo_Output output; 289 ChromeViewHostMsg_GetPluginInfo_Output output;
265 std::string mime_type(GetPluginParams().mimeType.utf8()); 290 std::string mime_type(GetPluginParams().mimeType.utf8());
266 blink::WebString top_origin = 291 blink::WebString top_origin =
267 GetFrame()->top()->getSecurityOrigin().toString(); 292 GetFrame()->top()->getSecurityOrigin().toString();
268 render_frame()->Send( 293 render_frame()->Send(
269 new ChromeViewHostMsg_GetPluginInfo(routing_id(), 294 new ChromeViewHostMsg_GetPluginInfo(routing_id(),
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 422
398 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 423 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
399 switches::kEnablePluginPlaceholderTesting)) { 424 switches::kEnablePluginPlaceholderTesting)) {
400 builder.SetMethod<void (ChromePluginPlaceholder::*)()>( 425 builder.SetMethod<void (ChromePluginPlaceholder::*)()>(
401 "didFinishIconRepositionForTesting", 426 "didFinishIconRepositionForTesting",
402 &ChromePluginPlaceholder::DidFinishIconRepositionForTestingCallback); 427 &ChromePluginPlaceholder::DidFinishIconRepositionForTestingCallback);
403 } 428 }
404 429
405 return builder; 430 return builder;
406 } 431 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698