| 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/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/common/child_process_logging.h" | 15 #include "chrome/common/child_process_logging.h" |
| 16 #include "chrome/common/chrome_content_client.h" | 16 #include "chrome/common/chrome_content_client.h" |
| 17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
| 18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/content_settings_pattern.h" |
| 19 #include "chrome/common/external_ipc_fuzzer.h" | 20 #include "chrome/common/external_ipc_fuzzer.h" |
| 20 #include "chrome/common/extensions/extension.h" | 21 #include "chrome/common/extensions/extension.h" |
| 21 #include "chrome/common/extensions/extension_constants.h" | 22 #include "chrome/common/extensions/extension_constants.h" |
| 22 #include "chrome/common/extensions/extension_set.h" | 23 #include "chrome/common/extensions/extension_set.h" |
| 23 #include "chrome/common/jstemplate_builder.h" | 24 #include "chrome/common/jstemplate_builder.h" |
| 24 #include "chrome/common/render_messages.h" | 25 #include "chrome/common/render_messages.h" |
| 25 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
| 26 #include "chrome/renderer/autofill/autofill_agent.h" | 27 #include "chrome/renderer/autofill/autofill_agent.h" |
| 27 #include "chrome/renderer/autofill/password_autofill_manager.h" | 28 #include "chrome/renderer/autofill/password_autofill_manager.h" |
| 28 #include "chrome/renderer/automation/automation_renderer_helper.h" | 29 #include "chrome/renderer/automation/automation_renderer_helper.h" |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 334 |
| 334 if (status.value == ChromeViewHostMsg_GetPluginInfo_Status::kDisabled) { | 335 if (status.value == ChromeViewHostMsg_GetPluginInfo_Status::kDisabled) { |
| 335 return CreatePluginPlaceholder( | 336 return CreatePluginPlaceholder( |
| 336 render_view, frame, plugin, original_params, group.get(), | 337 render_view, frame, plugin, original_params, group.get(), |
| 337 IDR_DISABLED_PLUGIN_HTML, IDS_PLUGIN_DISABLED, false, false); | 338 IDR_DISABLED_PLUGIN_HTML, IDS_PLUGIN_DISABLED, false, false); |
| 338 } | 339 } |
| 339 | 340 |
| 340 ContentSettingsType content_type = CONTENT_SETTINGS_TYPE_PLUGINS; | 341 ContentSettingsType content_type = CONTENT_SETTINGS_TYPE_PLUGINS; |
| 341 ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT; | 342 ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT; |
| 342 std::string resource = group->identifier(); | 343 std::string resource = group->identifier(); |
| 344 ContentSettingsPattern primary_pattern; |
| 345 ContentSettingsPattern secondary_pattern; |
| 343 render_view->Send(new ChromeViewHostMsg_GetPluginContentSetting( | 346 render_view->Send(new ChromeViewHostMsg_GetPluginContentSetting( |
| 344 frame->top()->document().url(), resource, &plugin_setting)); | 347 frame->top()->document().url(), resource, |
| 348 &plugin_setting, &primary_pattern, &secondary_pattern)); |
| 345 DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT); | 349 DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT); |
| 346 | 350 |
| 347 WebPluginParams params(original_params); | 351 WebPluginParams params(original_params); |
| 348 for (size_t i = 0; i < plugin.mime_types.size(); ++i) { | 352 for (size_t i = 0; i < plugin.mime_types.size(); ++i) { |
| 349 if (plugin.mime_types[i].mime_type == actual_mime_type) { | 353 if (plugin.mime_types[i].mime_type == actual_mime_type) { |
| 350 AppendParams(plugin.mime_types[i].additional_param_names, | 354 AppendParams(plugin.mime_types[i].additional_param_names, |
| 351 plugin.mime_types[i].additional_param_values, | 355 plugin.mime_types[i].additional_param_values, |
| 352 ¶ms.attributeNames, | 356 ¶ms.attributeNames, |
| 353 ¶ms.attributeValues); | 357 ¶ms.attributeValues); |
| 354 break; | 358 break; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 376 return CreatePluginPlaceholder( | 380 return CreatePluginPlaceholder( |
| 377 render_view, frame, plugin, params, group.get(), | 381 render_view, frame, plugin, params, group.get(), |
| 378 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_OUTDATED, false, | 382 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_OUTDATED, false, |
| 379 outdated_policy == CONTENT_SETTING_ASK); | 383 outdated_policy == CONTENT_SETTING_ASK); |
| 380 } else { | 384 } else { |
| 381 DCHECK(outdated_policy == CONTENT_SETTING_ALLOW); | 385 DCHECK(outdated_policy == CONTENT_SETTING_ALLOW); |
| 382 } | 386 } |
| 383 } | 387 } |
| 384 | 388 |
| 385 ContentSettingsObserver* observer = ContentSettingsObserver::Get(render_view); | 389 ContentSettingsObserver* observer = ContentSettingsObserver::Get(render_view); |
| 386 ContentSetting host_setting = | 390 ContentSettingsPattern wildcard = ContentSettingsPattern::Wildcard(); |
| 387 observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS); | |
| 388 | 391 |
| 389 if (group->RequiresAuthorization(plugin) && | 392 if (group->RequiresAuthorization(plugin) && |
| 390 authorize_policy == CONTENT_SETTING_ASK && | 393 authorize_policy == CONTENT_SETTING_ASK && |
| 391 (plugin_setting == CONTENT_SETTING_ALLOW || | 394 plugin_setting != CONTENT_SETTING_BLOCK && |
| 392 plugin_setting == CONTENT_SETTING_ASK) && | 395 primary_pattern == wildcard && |
| 393 host_setting == CONTENT_SETTING_DEFAULT) { | 396 secondary_pattern == wildcard && |
| 397 !observer->plugins_temporarily_allowed()) { |
| 394 render_view->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( | 398 render_view->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( |
| 395 render_view->GetRoutingId(), group->GetGroupName(), GURL())); | 399 render_view->GetRoutingId(), group->GetGroupName(), GURL())); |
| 396 return CreatePluginPlaceholder( | 400 return CreatePluginPlaceholder( |
| 397 render_view, frame, plugin, params, group.get(), | 401 render_view, frame, plugin, params, group.get(), |
| 398 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_NOT_AUTHORIZED, false, true); | 402 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_NOT_AUTHORIZED, false, true); |
| 399 } | 403 } |
| 400 | 404 |
| 401 // Treat Native Client invocations like Javascript. | 405 // Treat Native Client invocations like Javascript. |
| 402 bool is_nacl_plugin = plugin.name == | 406 bool is_nacl_plugin = plugin.name == |
| 403 ASCIIToUTF16(ChromeContentClient::kNaClPluginName); | 407 ASCIIToUTF16(ChromeContentClient::kNaClPluginName); |
| 404 if (is_nacl_plugin) { | 408 if (is_nacl_plugin) { |
| 405 content_type = CONTENT_SETTINGS_TYPE_JAVASCRIPT; | 409 content_type = CONTENT_SETTINGS_TYPE_JAVASCRIPT; |
| 406 plugin_setting = | 410 plugin_setting = |
| 407 observer->GetContentSetting(content_type); | 411 observer->GetContentSetting(content_type); |
| 408 } | 412 } |
| 409 | 413 |
| 410 if (plugin_setting == CONTENT_SETTING_ALLOW || | 414 if (plugin_setting == CONTENT_SETTING_ALLOW || |
| 411 host_setting == CONTENT_SETTING_ALLOW || | 415 observer->plugins_temporarily_allowed() || |
| 412 plugin.path.value() == webkit::npapi::kDefaultPluginLibraryName) { | 416 plugin.path.value() == webkit::npapi::kDefaultPluginLibraryName) { |
| 413 // Delay loading plugins if prerendering. | 417 // Delay loading plugins if prerendering. |
| 414 if (prerender::PrerenderHelper::IsPrerendering(render_view)) { | 418 if (prerender::PrerenderHelper::IsPrerendering(render_view)) { |
| 415 return CreatePluginPlaceholder( | 419 return CreatePluginPlaceholder( |
| 416 render_view, frame, plugin, params, group.get(), | 420 render_view, frame, plugin, params, group.get(), |
| 417 IDR_CLICK_TO_PLAY_PLUGIN_HTML, IDS_PLUGIN_LOAD, true, true); | 421 IDR_CLICK_TO_PLAY_PLUGIN_HTML, IDS_PLUGIN_LOAD, true, true); |
| 418 } | 422 } |
| 419 | 423 |
| 420 if (is_nacl_plugin && | 424 if (is_nacl_plugin && |
| 421 !IsNaClAllowed(plugin, | 425 !IsNaClAllowed(plugin, |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 it != extensions.end(); ++it) { | 860 it != extensions.end(); ++it) { |
| 857 if (it->second->HasAPIPermission(ExtensionAPIPermission::kExperimental) && | 861 if (it->second->HasAPIPermission(ExtensionAPIPermission::kExperimental) && |
| 858 it->second->name().find("Adblock") != std::string::npos && | 862 it->second->name().find("Adblock") != std::string::npos && |
| 859 it->second->name().find("Plus") != std::string::npos) | 863 it->second->name().find("Plus") != std::string::npos) |
| 860 return true; | 864 return true; |
| 861 } | 865 } |
| 862 return false; | 866 return false; |
| 863 } | 867 } |
| 864 | 868 |
| 865 } // namespace chrome | 869 } // namespace chrome |
| OLD | NEW |