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

Side by Side Diff: chrome/renderer/render_view.cc

Issue 5516004: Clean up PluginGroup and related code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/render_view.h" 5 #include "chrome/renderer/render_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 2671 matching lines...) Expand 10 before | Expand all | Expand 10 after
2682 params.mimeType.utf8(), 2682 params.mimeType.utf8(),
2683 &found, 2683 &found,
2684 &info, 2684 &info,
2685 &plugin_setting, 2685 &plugin_setting,
2686 &actual_mime_type)); 2686 &actual_mime_type));
2687 2687
2688 if (!found) 2688 if (!found)
2689 return NULL; 2689 return NULL;
2690 DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT); 2690 DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT);
2691 2691
2692 scoped_ptr<PluginGroup> group(PluginGroup::CopyOrCreatePluginGroup(info)); 2692 PluginGroup group = NPAPI::PluginList::Singleton()->GetPluginGroup(info);
2693 group->AddPlugin(info, 0);
2694 2693
2695 if (!info.enabled) { 2694 if (!info.enabled) {
2696 if (cmd->HasSwitch(switches::kDisableOutdatedPlugins) && 2695 if (cmd->HasSwitch(switches::kDisableOutdatedPlugins) &&
2697 group->IsVulnerable()) { 2696 group.IsVulnerable()) {
2698 Send(new ViewHostMsg_DisabledOutdatedPlugin(routing_id_, 2697 Send(new ViewHostMsg_DisabledOutdatedPlugin(routing_id_,
2699 group->GetGroupName(), 2698 group.GetGroupName(),
2700 GURL(group->GetUpdateURL()))); 2699 GURL(group.GetUpdateURL())));
2701 return CreateOutdatedPluginPlaceholder(frame, params, group.get()); 2700 return CreateOutdatedPluginPlaceholder(frame, params, group);
2702 } 2701 }
2703 return NULL; 2702 return NULL;
2704 } 2703 }
2705 2704
2706 ContentSetting host_setting = 2705 ContentSetting host_setting =
2707 current_content_settings_.settings[CONTENT_SETTINGS_TYPE_PLUGINS]; 2706 current_content_settings_.settings[CONTENT_SETTINGS_TYPE_PLUGINS];
2708 if (info.path.value() == kDefaultPluginLibraryName || 2707 if (info.path.value() == kDefaultPluginLibraryName ||
2709 plugin_setting == CONTENT_SETTING_ALLOW || 2708 plugin_setting == CONTENT_SETTING_ALLOW ||
2710 host_setting == CONTENT_SETTING_ALLOW) { 2709 host_setting == CONTENT_SETTING_ALLOW) {
2711 scoped_refptr<pepper::PluginModule> pepper_module; 2710 scoped_refptr<pepper::PluginModule> pepper_module;
2712 if (PepperPluginRegistry::GetInstance()->RunOutOfProcessForPlugin( 2711 if (PepperPluginRegistry::GetInstance()->RunOutOfProcessForPlugin(
2713 info.path)) { 2712 info.path)) {
2714 pepper_module = 2713 pepper_module =
2715 pepper_delegate_.CreateOutOfProcessPepperPlugin(info.path); 2714 pepper_delegate_.CreateOutOfProcessPepperPlugin(info.path);
2716 } else { 2715 } else {
2717 pepper_module = 2716 pepper_module =
2718 PepperPluginRegistry::GetInstance()->GetModule(info.path); 2717 PepperPluginRegistry::GetInstance()->GetModule(info.path);
2719 } 2718 }
2720 if (pepper_module) { 2719 if (pepper_module) {
2721 return CreatePepperPlugin(frame, 2720 return CreatePepperPlugin(frame,
2722 params, 2721 params,
2723 info.path, 2722 info.path,
2724 pepper_module.get()); 2723 pepper_module.get());
2725 } 2724 }
2726 return CreateNPAPIPlugin(frame, params, info.path, actual_mime_type); 2725 return CreateNPAPIPlugin(frame, params, info.path, actual_mime_type);
2727 } 2726 }
2728 std::string resource; 2727 std::string resource;
2729 if (cmd->HasSwitch(switches::kEnableResourceContentSettings)) 2728 if (cmd->HasSwitch(switches::kEnableResourceContentSettings))
2730 resource = group->identifier(); 2729 resource = group.identifier();
2731 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, resource); 2730 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, resource);
2732 int resource_id; 2731 int resource_id;
2733 int message_id; 2732 int message_id;
2734 if (plugin_setting == CONTENT_SETTING_ASK) { 2733 if (plugin_setting == CONTENT_SETTING_ASK) {
2735 resource_id = IDR_BLOCKED_PLUGIN_HTML; 2734 resource_id = IDR_BLOCKED_PLUGIN_HTML;
2736 message_id = IDS_PLUGIN_LOAD; 2735 message_id = IDS_PLUGIN_LOAD;
2737 } else { 2736 } else {
2738 resource_id = IDR_OUTDATED_PLUGIN_HTML; 2737 resource_id = IDR_OUTDATED_PLUGIN_HTML;
2739 message_id = IDS_PLUGIN_BLOCKED; 2738 message_id = IDS_PLUGIN_BLOCKED;
2740 } 2739 }
2741 // |blocked_plugin| will delete itself when the WebViewPlugin 2740 // |blocked_plugin| will delete itself when the WebViewPlugin
2742 // is destroyed. 2741 // is destroyed.
2743 BlockedPlugin* blocked_plugin = 2742 BlockedPlugin* blocked_plugin =
2744 new BlockedPlugin(this, 2743 new BlockedPlugin(this,
2745 frame, 2744 frame,
2746 *group, 2745 group,
2747 params, 2746 params,
2748 webkit_preferences_, 2747 webkit_preferences_,
2749 resource_id, 2748 resource_id,
2750 l10n_util::GetStringUTF16(message_id)); 2749 l10n_util::GetStringUTF16(message_id));
2751 return blocked_plugin->plugin(); 2750 return blocked_plugin->plugin();
2752 } 2751 }
2753 2752
2754 WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) { 2753 WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) {
2755 WebApplicationCacheHostImpl* appcache_host = 2754 WebApplicationCacheHostImpl* appcache_host =
2756 WebApplicationCacheHostImpl::FromFrame(frame); 2755 WebApplicationCacheHostImpl::FromFrame(frame);
(...skipping 1637 matching lines...) Expand 10 before | Expand all | Expand 10 after
4394 const WebPluginParams& params, 4393 const WebPluginParams& params,
4395 const FilePath& path, 4394 const FilePath& path,
4396 const std::string& mime_type) { 4395 const std::string& mime_type) {
4397 return new webkit_glue::WebPluginImpl( 4396 return new webkit_glue::WebPluginImpl(
4398 frame, params, path, mime_type, AsWeakPtr()); 4397 frame, params, path, mime_type, AsWeakPtr());
4399 } 4398 }
4400 4399
4401 WebPlugin* RenderView::CreateOutdatedPluginPlaceholder( 4400 WebPlugin* RenderView::CreateOutdatedPluginPlaceholder(
4402 WebFrame* frame, 4401 WebFrame* frame,
4403 const WebPluginParams& params, 4402 const WebPluginParams& params,
4404 PluginGroup* group) { 4403 PluginGroup& group) {
4405 int resource_id = IDR_OUTDATED_PLUGIN_HTML; 4404 int resource_id = IDR_OUTDATED_PLUGIN_HTML;
4406 const base::StringPiece template_html( 4405 const base::StringPiece template_html(
4407 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); 4406 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id));
4408 4407
4409 DCHECK(!template_html.empty()) << "unable to load template. ID: " 4408 DCHECK(!template_html.empty()) << "unable to load template. ID: "
4410 << resource_id; 4409 << resource_id;
4411 4410
4412 DictionaryValue values; 4411 DictionaryValue values;
4413 values.SetString("message", 4412 values.SetString("message",
4414 l10n_util::GetStringFUTF8(IDS_PLUGIN_OUTDATED, group->GetGroupName())); 4413 l10n_util::GetStringFUTF8(IDS_PLUGIN_OUTDATED, group.GetGroupName()));
4415 values.Set("pluginGroup", group->GetDataForUI()); 4414 values.Set("pluginGroup", group.GetDataForUI());
4416 4415
4417 // "t" is the id of the templates root node. 4416 // "t" is the id of the templates root node.
4418 std::string htmlData = jstemplate_builder::GetTemplatesHtml( 4417 std::string htmlData = jstemplate_builder::GetTemplatesHtml(
4419 template_html, &values, "t"); 4418 template_html, &values, "t");
4420 4419
4421 return WebViewPlugin::Create(NULL, 4420 return WebViewPlugin::Create(NULL,
4422 webkit_preferences_, 4421 webkit_preferences_,
4423 htmlData, 4422 htmlData,
4424 GURL("chrome://outdatedplugin/")); 4423 GURL("chrome://outdatedplugin/"));
4425 } 4424 }
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
5685 external_popup_menu_.reset(); 5684 external_popup_menu_.reset();
5686 } 5685 }
5687 #endif 5686 #endif
5688 5687
5689 void RenderView::AddErrorToRootConsole(const string16& message) { 5688 void RenderView::AddErrorToRootConsole(const string16& message) {
5690 if (webview() && webview()->mainFrame()) { 5689 if (webview() && webview()->mainFrame()) {
5691 webview()->mainFrame()->addMessageToConsole( 5690 webview()->mainFrame()->addMessageToConsole(
5692 WebConsoleMessage(WebConsoleMessage::LevelError, message)); 5691 WebConsoleMessage(WebConsoleMessage::LevelError, message));
5693 } 5692 }
5694 } 5693 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698