OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chrome_content_renderer_client.h" | 5 #include "chrome/renderer/chrome_content_renderer_client.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 PLUGIN_TYPE_MISMATCH_NUM_EVENTS); | 324 PLUGIN_TYPE_MISMATCH_NUM_EVENTS); |
325 // We do not permit URL-sniff based plug-in MIME type overrides aside from | 325 // We do not permit URL-sniff based plug-in MIME type overrides aside from |
326 // the case where the "type" was initially missing or generic | 326 // the case where the "type" was initially missing or generic |
327 // (application/octet-stream). | 327 // (application/octet-stream). |
328 // We collected stats to determine this approach isn't a major compat issue, | 328 // We collected stats to determine this approach isn't a major compat issue, |
329 // and we defend against content confusion attacks in various cases, such | 329 // and we defend against content confusion attacks in various cases, such |
330 // as when the user doesn't have the Flash plug-in enabled. | 330 // as when the user doesn't have the Flash plug-in enabled. |
331 return NULL; | 331 return NULL; |
332 } | 332 } |
333 | 333 |
334 const webkit::npapi::PluginGroup* group = | 334 scoped_ptr<webkit::npapi::PluginGroup> group( |
335 webkit::npapi::PluginList::Singleton()->GetPluginGroup(info); | 335 webkit::npapi::PluginList::Singleton()->GetPluginGroup(info)); |
336 DCHECK(group != NULL); | |
337 | 336 |
338 ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT; | 337 ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT; |
339 std::string resource; | 338 std::string resource; |
340 if (cmd->HasSwitch(switches::kEnableResourceContentSettings)) | 339 if (cmd->HasSwitch(switches::kEnableResourceContentSettings)) |
341 resource = group->identifier(); | 340 resource = group->identifier(); |
342 render_view->Send(new ChromeViewHostMsg_GetPluginContentSetting( | 341 render_view->Send(new ChromeViewHostMsg_GetPluginContentSetting( |
343 frame->top()->document().url(), resource, &plugin_setting)); | 342 frame->top()->document().url(), resource, &plugin_setting)); |
344 DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT); | 343 DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT); |
345 | 344 |
346 WebPluginParams params(original_params); | 345 WebPluginParams params(original_params); |
347 for (size_t i = 0; i < info.mime_types.size(); ++i) { | 346 for (size_t i = 0; i < info.mime_types.size(); ++i) { |
348 if (info.mime_types[i].mime_type == actual_mime_type) { | 347 if (info.mime_types[i].mime_type == actual_mime_type) { |
349 AppendParams(info.mime_types[i].additional_param_names, | 348 AppendParams(info.mime_types[i].additional_param_names, |
350 info.mime_types[i].additional_param_values, | 349 info.mime_types[i].additional_param_values, |
351 ¶ms.attributeNames, | 350 ¶ms.attributeNames, |
352 ¶ms.attributeValues); | 351 ¶ms.attributeValues); |
353 break; | 352 break; |
354 } | 353 } |
355 } | 354 } |
356 | 355 |
357 ContentSetting outdated_policy = CONTENT_SETTING_ASK; | 356 ContentSetting outdated_policy = CONTENT_SETTING_ASK; |
358 ContentSetting authorize_policy = CONTENT_SETTING_ASK; | 357 ContentSetting authorize_policy = CONTENT_SETTING_ASK; |
359 if (group->IsVulnerable() || group->RequiresAuthorization()) { | 358 if (group->IsVulnerable(info) || group->RequiresAuthorization(info)) { |
360 // These policies are dynamic and can changed at runtime, so they aren't | 359 // These policies are dynamic and can changed at runtime, so they aren't |
361 // cached here. | 360 // cached here. |
362 render_view->Send(new ChromeViewHostMsg_GetPluginPolicies( | 361 render_view->Send(new ChromeViewHostMsg_GetPluginPolicies( |
363 &outdated_policy, &authorize_policy)); | 362 &outdated_policy, &authorize_policy)); |
364 } | 363 } |
365 | 364 |
366 if (group->IsVulnerable()) { | 365 if (group->IsVulnerable(info)) { |
367 if (outdated_policy == CONTENT_SETTING_ASK || | 366 if (outdated_policy == CONTENT_SETTING_ASK || |
368 outdated_policy == CONTENT_SETTING_BLOCK) { | 367 outdated_policy == CONTENT_SETTING_BLOCK) { |
369 if (outdated_policy == CONTENT_SETTING_ASK) { | 368 if (outdated_policy == CONTENT_SETTING_ASK) { |
370 render_view->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( | 369 render_view->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( |
371 render_view->routing_id(), group->GetGroupName(), | 370 render_view->routing_id(), group->GetGroupName(), |
372 GURL(group->GetUpdateURL()))); | 371 GURL(group->GetUpdateURL()))); |
373 } | 372 } |
374 return CreatePluginPlaceholder( | 373 return CreatePluginPlaceholder( |
375 render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML, | 374 render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML, |
376 IDS_PLUGIN_OUTDATED, false, outdated_policy == CONTENT_SETTING_ASK); | 375 IDS_PLUGIN_OUTDATED, false, outdated_policy == CONTENT_SETTING_ASK); |
377 } else { | 376 } else { |
378 DCHECK(outdated_policy == CONTENT_SETTING_ALLOW); | 377 DCHECK(outdated_policy == CONTENT_SETTING_ALLOW); |
379 } | 378 } |
380 } | 379 } |
381 | 380 |
382 ContentSettingsObserver* observer = ContentSettingsObserver::Get(render_view); | 381 ContentSettingsObserver* observer = ContentSettingsObserver::Get(render_view); |
383 ContentSetting host_setting = | 382 ContentSetting host_setting = |
384 observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS); | 383 observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS); |
385 | 384 |
386 if (group->RequiresAuthorization() && | 385 if (group->RequiresAuthorization(info) && |
387 authorize_policy == CONTENT_SETTING_ASK && | 386 authorize_policy == CONTENT_SETTING_ASK && |
388 (plugin_setting == CONTENT_SETTING_ALLOW || | 387 (plugin_setting == CONTENT_SETTING_ALLOW || |
389 plugin_setting == CONTENT_SETTING_ASK) && | 388 plugin_setting == CONTENT_SETTING_ASK) && |
390 host_setting == CONTENT_SETTING_DEFAULT) { | 389 host_setting == CONTENT_SETTING_DEFAULT) { |
391 render_view->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( | 390 render_view->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( |
392 render_view->routing_id(), group->GetGroupName(), GURL())); | 391 render_view->routing_id(), group->GetGroupName(), GURL())); |
393 return CreatePluginPlaceholder( | 392 return CreatePluginPlaceholder( |
394 render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML, | 393 render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML, |
395 IDS_PLUGIN_NOT_AUTHORIZED, false, true); | 394 IDS_PLUGIN_NOT_AUTHORIZED, false, true); |
396 } | 395 } |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 if (spellcheck_.get()) | 769 if (spellcheck_.get()) |
771 thread->RemoveObserver(spellcheck_.get()); | 770 thread->RemoveObserver(spellcheck_.get()); |
772 SpellCheck* new_spellcheck = new SpellCheck(); | 771 SpellCheck* new_spellcheck = new SpellCheck(); |
773 if (spellcheck_provider_) | 772 if (spellcheck_provider_) |
774 spellcheck_provider_->SetSpellCheck(new_spellcheck); | 773 spellcheck_provider_->SetSpellCheck(new_spellcheck); |
775 spellcheck_.reset(new_spellcheck); | 774 spellcheck_.reset(new_spellcheck); |
776 thread->AddObserver(new_spellcheck); | 775 thread->AddObserver(new_spellcheck); |
777 } | 776 } |
778 | 777 |
779 } // namespace chrome | 778 } // namespace chrome |
OLD | NEW |