| 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 scoped_ptr<webkit::npapi::PluginGroup> group( | 334 const webkit::npapi::PluginGroup* group = |
| 335 webkit::npapi::PluginList::Singleton()->GetPluginGroup(info)); | 335 webkit::npapi::PluginList::Singleton()->GetPluginGroup(info); |
| 336 DCHECK(group != NULL); |
| 336 | 337 |
| 337 ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT; | 338 ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT; |
| 338 std::string resource; | 339 std::string resource; |
| 339 if (cmd->HasSwitch(switches::kEnableResourceContentSettings)) | 340 if (cmd->HasSwitch(switches::kEnableResourceContentSettings)) |
| 340 resource = group->identifier(); | 341 resource = group->identifier(); |
| 341 render_view->Send(new ChromeViewHostMsg_GetPluginContentSetting( | 342 render_view->Send(new ChromeViewHostMsg_GetPluginContentSetting( |
| 342 frame->top()->document().url(), resource, &plugin_setting)); | 343 frame->top()->document().url(), resource, &plugin_setting)); |
| 343 DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT); | 344 DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT); |
| 344 | 345 |
| 345 WebPluginParams params(original_params); | 346 WebPluginParams params(original_params); |
| 346 for (size_t i = 0; i < info.mime_types.size(); ++i) { | 347 for (size_t i = 0; i < info.mime_types.size(); ++i) { |
| 347 if (info.mime_types[i].mime_type == actual_mime_type) { | 348 if (info.mime_types[i].mime_type == actual_mime_type) { |
| 348 AppendParams(info.mime_types[i].additional_param_names, | 349 AppendParams(info.mime_types[i].additional_param_names, |
| 349 info.mime_types[i].additional_param_values, | 350 info.mime_types[i].additional_param_values, |
| 350 ¶ms.attributeNames, | 351 ¶ms.attributeNames, |
| 351 ¶ms.attributeValues); | 352 ¶ms.attributeValues); |
| 352 break; | 353 break; |
| 353 } | 354 } |
| 354 } | 355 } |
| 355 | 356 |
| 356 ContentSetting outdated_policy = CONTENT_SETTING_ASK; | 357 ContentSetting outdated_policy = CONTENT_SETTING_ASK; |
| 357 ContentSetting authorize_policy = CONTENT_SETTING_ASK; | 358 ContentSetting authorize_policy = CONTENT_SETTING_ASK; |
| 358 if (group->IsVulnerable(info) || group->RequiresAuthorization(info)) { | 359 if (group->IsVulnerable() || group->RequiresAuthorization()) { |
| 359 // These policies are dynamic and can changed at runtime, so they aren't | 360 // These policies are dynamic and can changed at runtime, so they aren't |
| 360 // cached here. | 361 // cached here. |
| 361 render_view->Send(new ChromeViewHostMsg_GetPluginPolicies( | 362 render_view->Send(new ChromeViewHostMsg_GetPluginPolicies( |
| 362 &outdated_policy, &authorize_policy)); | 363 &outdated_policy, &authorize_policy)); |
| 363 } | 364 } |
| 364 | 365 |
| 365 if (group->IsVulnerable(info)) { | 366 if (group->IsVulnerable()) { |
| 366 if (outdated_policy == CONTENT_SETTING_ASK || | 367 if (outdated_policy == CONTENT_SETTING_ASK || |
| 367 outdated_policy == CONTENT_SETTING_BLOCK) { | 368 outdated_policy == CONTENT_SETTING_BLOCK) { |
| 368 if (outdated_policy == CONTENT_SETTING_ASK) { | 369 if (outdated_policy == CONTENT_SETTING_ASK) { |
| 369 render_view->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( | 370 render_view->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( |
| 370 render_view->routing_id(), group->GetGroupName(), | 371 render_view->routing_id(), group->GetGroupName(), |
| 371 GURL(group->GetUpdateURL()))); | 372 GURL(group->GetUpdateURL()))); |
| 372 } | 373 } |
| 373 return CreatePluginPlaceholder( | 374 return CreatePluginPlaceholder( |
| 374 render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML, | 375 render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML, |
| 375 IDS_PLUGIN_OUTDATED, false, outdated_policy == CONTENT_SETTING_ASK); | 376 IDS_PLUGIN_OUTDATED, false, outdated_policy == CONTENT_SETTING_ASK); |
| 376 } else { | 377 } else { |
| 377 DCHECK(outdated_policy == CONTENT_SETTING_ALLOW); | 378 DCHECK(outdated_policy == CONTENT_SETTING_ALLOW); |
| 378 } | 379 } |
| 379 } | 380 } |
| 380 | 381 |
| 381 ContentSettingsObserver* observer = ContentSettingsObserver::Get(render_view); | 382 ContentSettingsObserver* observer = ContentSettingsObserver::Get(render_view); |
| 382 ContentSetting host_setting = | 383 ContentSetting host_setting = |
| 383 observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS); | 384 observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS); |
| 384 | 385 |
| 385 if (group->RequiresAuthorization(info) && | 386 if (group->RequiresAuthorization() && |
| 386 authorize_policy == CONTENT_SETTING_ASK && | 387 authorize_policy == CONTENT_SETTING_ASK && |
| 387 (plugin_setting == CONTENT_SETTING_ALLOW || | 388 (plugin_setting == CONTENT_SETTING_ALLOW || |
| 388 plugin_setting == CONTENT_SETTING_ASK) && | 389 plugin_setting == CONTENT_SETTING_ASK) && |
| 389 host_setting == CONTENT_SETTING_DEFAULT) { | 390 host_setting == CONTENT_SETTING_DEFAULT) { |
| 390 render_view->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( | 391 render_view->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( |
| 391 render_view->routing_id(), group->GetGroupName(), GURL())); | 392 render_view->routing_id(), group->GetGroupName(), GURL())); |
| 392 return CreatePluginPlaceholder( | 393 return CreatePluginPlaceholder( |
| 393 render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML, | 394 render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML, |
| 394 IDS_PLUGIN_NOT_AUTHORIZED, false, true); | 395 IDS_PLUGIN_NOT_AUTHORIZED, false, true); |
| 395 } | 396 } |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 if (spellcheck_.get()) | 770 if (spellcheck_.get()) |
| 770 thread->RemoveObserver(spellcheck_.get()); | 771 thread->RemoveObserver(spellcheck_.get()); |
| 771 SpellCheck* new_spellcheck = new SpellCheck(); | 772 SpellCheck* new_spellcheck = new SpellCheck(); |
| 772 if (spellcheck_provider_) | 773 if (spellcheck_provider_) |
| 773 spellcheck_provider_->SetSpellCheck(new_spellcheck); | 774 spellcheck_provider_->SetSpellCheck(new_spellcheck); |
| 774 spellcheck_.reset(new_spellcheck); | 775 spellcheck_.reset(new_spellcheck); |
| 775 thread->AddObserver(new_spellcheck); | 776 thread->AddObserver(new_spellcheck); |
| 776 } | 777 } |
| 777 | 778 |
| 778 } // namespace chrome | 779 } // namespace chrome |
| OLD | NEW |