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