diff options
author | joaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-31 07:12:44 +0000 |
---|---|---|
committer | joaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-31 07:12:44 +0000 |
commit | 2bf2bd9bf5a57b22d17ed5ca27692ab303376b83 (patch) | |
tree | eb14c5119b6a83510c8bd7e8823d0eda8bea054d /chrome | |
parent | a47040f8d7c8eccf16a8484ff8e02d93d0f0dbc5 (diff) | |
download | chromium_src-2bf2bd9bf5a57b22d17ed5ca27692ab303376b83.zip chromium_src-2bf2bd9bf5a57b22d17ed5ca27692ab303376b83.tar.gz chromium_src-2bf2bd9bf5a57b22d17ed5ca27692ab303376b83.tar.bz2 |
AllowOutdatedPlugins policy.
BUG=74435
TEST=unit_tests, set the AllowOutdatedPlugins policy and open a page
running an outdated plugin.
Review URL: http://codereview.chromium.org/6676113
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79964 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
20 files changed, 153 insertions, 53 deletions
diff --git a/chrome/app/policy/policy_templates.json b/chrome/app/policy/policy_templates.json index 2fbf7e5..cb5b707 100644 --- a/chrome/app/policy/policy_templates.json +++ b/chrome/app/policy/policy_templates.json @@ -94,7 +94,7 @@ # persistent IDs for all fields (but not for groups!) are needed. These are # specified by the 'id' keys of each policy. NEVER CHANGE EXISTING IDs, # because doing so would break the deployed wire format! -# For your editing convenience: highest ID currently used: 80 +# For your editing convenience: highest ID currently used: 81 # # Placeholders: # The following placeholder strings are automatically substituted: @@ -1421,6 +1421,22 @@ If you enable or disable this setting, users cannot change or override this setting in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>.''', }, + { + 'name': 'AllowOutdatedPlugins', + 'type': 'main', + 'supported_on': ['chrome.*:12-', 'chrome_os:0.11-'], + 'features': {'dynamic_refresh': 1}, + 'example_value': True, + 'id': 81, + 'caption': '''Allow running plugins that are outdated''', + 'desc': '''Allows <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> to run plugins that are outdated. + + If you enable this setting, outdated plugins are used as normal plugins. + + If you disable this setting, outdated plugins will not be used and users will not be asked for permission to run them. + + If this setting is not set, users will be asked for permission to run outdated plugins.''', + }, ], 'messages': { # Messages that are not associated to any policies. diff --git a/chrome/browser/policy/config_dir_policy_provider_unittest.cc b/chrome/browser/policy/config_dir_policy_provider_unittest.cc index 944cfa9..d2dfc23 100644 --- a/chrome/browser/policy/config_dir_policy_provider_unittest.cc +++ b/chrome/browser/policy/config_dir_policy_provider_unittest.cc @@ -353,6 +353,9 @@ INSTANTIATE_TEST_CASE_P( key::kCloudPrintProxyEnabled), ValueTestParams::ForBooleanPolicy( kPolicyTranslateEnabled, - key::kTranslateEnabled))); + key::kTranslateEnabled), + ValueTestParams::ForBooleanPolicy( + kPolicyAllowOutdatedPlugins, + key::kAllowOutdatedPlugins))); } // namespace policy diff --git a/chrome/browser/policy/configuration_policy_pref_store.cc b/chrome/browser/policy/configuration_policy_pref_store.cc index cae0144..67825f3 100644 --- a/chrome/browser/policy/configuration_policy_pref_store.cc +++ b/chrome/browser/policy/configuration_policy_pref_store.cc @@ -269,6 +269,8 @@ const ConfigurationPolicyPrefKeeper::PolicyToPreferenceMapEntry { Value::TYPE_BOOLEAN, kPolicyCloudPrintProxyEnabled, prefs::kCloudPrintProxyEnabled }, { Value::TYPE_BOOLEAN, kPolicyTranslateEnabled, prefs::kEnableTranslate }, + { Value::TYPE_BOOLEAN, kPolicyAllowOutdatedPlugins, + prefs::kPluginsAllowOutdated }, #if defined(OS_CHROMEOS) { Value::TYPE_BOOLEAN, kPolicyChromeOsLockOnIdleSuspend, @@ -978,6 +980,8 @@ ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList() { { kPolicyDownloadDirectory, Value::TYPE_STRING, key::kDownloadDirectory }, { kPolicyTranslateEnabled, Value::TYPE_BOOLEAN, key::kTranslateEnabled }, + { kPolicyAllowOutdatedPlugins, Value::TYPE_BOOLEAN, + key::kAllowOutdatedPlugins }, #if defined(OS_CHROMEOS) { kPolicyChromeOsLockOnIdleSuspend, Value::TYPE_BOOLEAN, diff --git a/chrome/browser/policy/configuration_policy_pref_store_unittest.cc b/chrome/browser/policy/configuration_policy_pref_store_unittest.cc index 1c353f0..7387df3 100644 --- a/chrome/browser/policy/configuration_policy_pref_store_unittest.cc +++ b/chrome/browser/policy/configuration_policy_pref_store_unittest.cc @@ -205,7 +205,9 @@ INSTANTIATE_TEST_CASE_P( TypeAndName(kPolicyDisable3DAPIs, prefs::kDisable3DAPIs), TypeAndName(kPolicyTranslateEnabled, - prefs::kEnableTranslate))); + prefs::kEnableTranslate), + TypeAndName(kPolicyAllowOutdatedPlugins, + prefs::kPluginsAllowOutdated))); #if defined(OS_CHROMEOS) INSTANTIATE_TEST_CASE_P( diff --git a/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc b/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc index 7bf04ee..c248f77 100644 --- a/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc +++ b/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc @@ -324,6 +324,9 @@ INSTANTIATE_TEST_CASE_P( key::kCloudPrintProxyEnabled), PolicyTestParams::ForBooleanPolicy( kPolicyTranslateEnabled, - key::kTranslateEnabled))); + key::kTranslateEnabled), + PolicyTestParams::ForBooleanPolicy( + kPolicyAllowOutdatedPlugins, + key::kAllowOutdatedPlugins))); } // namespace policy diff --git a/chrome/browser/policy/configuration_policy_provider_win_unittest.cc b/chrome/browser/policy/configuration_policy_provider_win_unittest.cc index 52f21e8..f1427c9 100644 --- a/chrome/browser/policy/configuration_policy_provider_win_unittest.cc +++ b/chrome/browser/policy/configuration_policy_provider_win_unittest.cc @@ -482,6 +482,9 @@ INSTANTIATE_TEST_CASE_P( key::kCloudPrintProxyEnabled), PolicyTestParams::ForBooleanPolicy( kPolicyTranslateEnabled, - key::kTranslateEnabled))); + key::kTranslateEnabled), + PolicyTestParams::ForBooleanPolicy( + kPolicyAllowOutdatedPlugins, + key::kAllowOutdatedPlugins))); } // namespace policy diff --git a/chrome/browser/prefs/command_line_pref_store.cc b/chrome/browser/prefs/command_line_pref_store.cc index 4bdf7c4..c0438c7 100644 --- a/chrome/browser/prefs/command_line_pref_store.cc +++ b/chrome/browser/prefs/command_line_pref_store.cc @@ -30,6 +30,7 @@ const CommandLinePrefStore::BooleanSwitchToPreferenceMapEntry { switches::kDisable3DAPIs, prefs::kDisable3DAPIs, true }, { switches::kEnableCloudPrintProxy, prefs::kCloudPrintProxyEnabled, true }, + { switches::kAllowOutdatedPlugins, prefs::kPluginsAllowOutdated, true }, }; CommandLinePrefStore::CommandLinePrefStore(const CommandLine* command_line) diff --git a/chrome/browser/prefs/pref_member.cc b/chrome/browser/prefs/pref_member.cc index 25ccc55..405aab6 100644 --- a/chrome/browser/prefs/pref_member.cc +++ b/chrome/browser/prefs/pref_member.cc @@ -44,13 +44,6 @@ void PrefMemberBase::Destroy() { } } -bool PrefMemberBase::IsManaged() const { - VerifyValuePrefName(); - const PrefService::Preference* pref = - prefs_->FindPreference(pref_name_.c_str()); - return pref && pref->IsManaged(); -} - void PrefMemberBase::MoveToThread(BrowserThread::ID thread_id) { VerifyValuePrefName(); // Load the value from preferences if it hasn't been loaded so far. @@ -80,7 +73,7 @@ void PrefMemberBase::UpdateValueFromPref() const { DCHECK(pref); if (!internal()) CreateInternal(); - internal()->UpdateValue(pref->GetValue()->DeepCopy()); + internal()->UpdateValue(pref->GetValue()->DeepCopy(), pref->IsManaged()); } PrefMemberBase::Internal::Internal() : thread_id_(BrowserThread::UI) { } @@ -93,17 +86,18 @@ bool PrefMemberBase::Internal::IsOnCorrectThread() const { !BrowserThread::IsMessageLoopValid(BrowserThread::UI))); } -void PrefMemberBase::Internal::UpdateValue(Value* v) const { +void PrefMemberBase::Internal::UpdateValue(Value* v, bool is_managed) const { scoped_ptr<Value> value(v); if (IsOnCorrectThread()) { bool rv = UpdateValueInternal(*value); DCHECK(rv); + is_managed_ = is_managed; } else { bool rv = BrowserThread::PostTask( thread_id_, FROM_HERE, NewRunnableMethod(this, &PrefMemberBase::Internal::UpdateValue, - value.release())); + value.release(), is_managed)); DCHECK(rv); } } diff --git a/chrome/browser/prefs/pref_member.h b/chrome/browser/prefs/pref_member.h index a543cf1..88a0071 100644 --- a/chrome/browser/prefs/pref_member.h +++ b/chrome/browser/prefs/pref_member.h @@ -47,10 +47,15 @@ class PrefMemberBase : public NotificationObserver { // Update the value, either by calling |UpdateValueInternal| directly // or by dispatching to the right thread. // Takes ownership of |value|. - virtual void UpdateValue(Value* value) const; + virtual void UpdateValue(Value* value, bool is_managed) const; void MoveToThread(BrowserThread::ID thread_id); + // See PrefMember<> for description. + bool IsManaged() const { + return is_managed_; + } + protected: friend class base::RefCountedThreadSafe<Internal>; virtual ~Internal(); @@ -67,6 +72,7 @@ class PrefMemberBase : public NotificationObserver { bool IsOnCorrectThread() const; BrowserThread::ID thread_id_; + mutable bool is_managed_; DISALLOW_COPY_AND_ASSIGN(Internal); }; @@ -83,9 +89,6 @@ class PrefMemberBase : public NotificationObserver { // See PrefMember<> for description. void Destroy(); - // See PrefMember<> for description. - bool IsManaged() const; - void MoveToThread(BrowserThread::ID thread_id); // NotificationObserver @@ -100,6 +103,14 @@ class PrefMemberBase : public NotificationObserver { // seen by the outside world. It is just doing a lazy load behind the scenes. virtual void UpdateValueFromPref() const; + // Verifies the preference name, and lazily loads the preference value if + // it hasn't been loaded yet. + void VerifyPref() const { + VerifyValuePrefName(); + if (!internal()) + UpdateValueFromPref(); + } + const std::string& pref_name() const { return pref_name_; } PrefService* prefs() { return prefs_; } const PrefService* prefs() const { return prefs_; } @@ -153,20 +164,18 @@ class PrefMember : public subtle::PrefMemberBase { // Check whether the pref is managed, i.e. controlled externally through // enterprise configuration management (e.g. windows group policy). Returns // false for unknown prefs. - // This method should only be called on the UI thread. + // This method should only be used from the thread the PrefMember is currently + // on, which is the UI thread unless changed by |MoveToThread|. bool IsManaged() const { - return subtle::PrefMemberBase::IsManaged(); + VerifyPref(); + return internal_->IsManaged(); } // Retrieve the value of the member variable. // This method should only be used from the thread the PrefMember is currently // on, which is the UI thread unless changed by |MoveToThread|. ValueType GetValue() const { - VerifyValuePrefName(); - // We lazily fetch the value from the pref service the first time GetValue - // is called. - if (!internal_.get()) - UpdateValueFromPref(); + VerifyPref(); return internal_->value(); } diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 795d304..27344c80 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -673,7 +673,6 @@ void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer( // Propagate the following switches to the renderer command line (along // with any associated values) if present in the browser command line. static const char* const kSwitchNames[] = { - switches::kAllowOutdatedPlugins, switches::kAllowScriptingGallery, switches::kAlwaysAuthorizePlugins, switches::kAppsGalleryURL, diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.cc b/chrome/browser/renderer_host/chrome_render_message_filter.cc index fd1c802..7075ff3 100644 --- a/chrome/browser/renderer_host/chrome_render_message_filter.cc +++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc @@ -12,11 +12,13 @@ #include "chrome/browser/nacl_host/nacl_process_host.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/net/predictor_api.h" +#include "chrome/browser/prefs/pref_member.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/task_manager/task_manager.h" #include "chrome/common/extensions/extension_file_util.h" #include "chrome/common/extensions/extension_message_bundle.h" #include "chrome/common/extensions/extension_messages.h" +#include "chrome/common/pref_names.h" #include "chrome/common/render_messages.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" @@ -34,11 +36,17 @@ ChromeRenderMessageFilter::ChromeRenderMessageFilter( render_process_id_(render_process_id), profile_(profile), request_context_(request_context) { + allow_outdated_plugins_ = new BooleanPrefMember(); + allow_outdated_plugins_->Init(prefs::kPluginsAllowOutdated, + profile_->GetPrefs(), NULL); + allow_outdated_plugins_->MoveToThread(BrowserThread::IO); } ChromeRenderMessageFilter::~ChromeRenderMessageFilter() { // This function should be called on the IO thread. DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, + allow_outdated_plugins_); } bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message, @@ -58,6 +66,8 @@ bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message, #if defined(USE_TCMALLOC) IPC_MESSAGE_HANDLER(ViewHostMsg_RendererTcmalloc, OnRendererTcmalloc) #endif + IPC_MESSAGE_HANDLER(ViewHostMsg_GetOutdatedPluginsPolicy, + OnGetOutdatedPluginsPolicy) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -228,3 +238,14 @@ void ChromeRenderMessageFilter::OnRendererTcmalloc(base::ProcessId pid, AboutTcmallocRendererCallback(pid, output); } #endif + +void ChromeRenderMessageFilter::OnGetOutdatedPluginsPolicy( + ContentSetting* policy) { + *policy = CONTENT_SETTING_ALLOW; + if (!allow_outdated_plugins_->GetValue()) { + // If this is false by policy, the plugin is blocked; otherwise, it is + // blocked initially but the user can load it manually. + *policy = allow_outdated_plugins_->IsManaged() ? + CONTENT_SETTING_BLOCK : CONTENT_SETTING_ASK; + } +} diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.h b/chrome/browser/renderer_host/chrome_render_message_filter.h index dbfa3ab..34f88d5 100644 --- a/chrome/browser/renderer_host/chrome_render_message_filter.h +++ b/chrome/browser/renderer_host/chrome_render_message_filter.h @@ -6,9 +6,12 @@ #define CHROME_BROWSER_RENDERER_HOST_CHROME_RENDER_MESSAGE_FILTER_H_ #pragma once +#include "chrome/common/content_settings.h" #include "content/browser/browser_message_filter.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" +template<class T> class PrefMember; +typedef PrefMember<bool> BooleanPrefMember; class FilePath; class Profile; class ResourceDispatcherHost; @@ -34,7 +37,7 @@ class ChromeRenderMessageFilter : public BrowserMessageFilter { friend class DeleteTask<ChromeRenderMessageFilter>; virtual ~ChromeRenderMessageFilter(); - + void OnLaunchNaCl(const std::wstring& url, int channel_descriptor, IPC::Message* reply_msg); @@ -60,7 +63,7 @@ class ChromeRenderMessageFilter : public BrowserMessageFilter { int receiver_port_id, int tab_id, const std::string& extension_id, const std::string& channel_name); - + void OnGetExtensionMessageBundle(const std::string& extension_id, IPC::Message* reply_msg); void OnGetExtensionMessageBundleOnFileThread( @@ -71,6 +74,7 @@ class ChromeRenderMessageFilter : public BrowserMessageFilter { #if defined(USE_TCMALLOC) void OnRendererTcmalloc(base::ProcessId pid, const std::string& output); #endif + void OnGetOutdatedPluginsPolicy(ContentSetting* policy); ResourceDispatcherHost* resource_dispatcher_host_; int render_process_id_; @@ -80,6 +84,11 @@ class ChromeRenderMessageFilter : public BrowserMessageFilter { Profile* profile_; scoped_refptr<URLRequestContextGetter> request_context_; + // |allow_outdated_plugins_| is a weak pointer because it must be deleted on + // the UI thread, but the dtor is called on the IO thread. The dtor posts a + // DeleteTask on the UI thread to delete this pointer. + BooleanPrefMember* allow_outdated_plugins_; + DISALLOW_COPY_AND_ASSIGN(ChromeRenderMessageFilter); }; diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index c95f423..ae9a172 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -2088,9 +2088,10 @@ void Browser::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterIntegerPref(prefs::kDevToolsSplitLocation, -1); prefs->RegisterDictionaryPref(prefs::kBrowserWindowPlacement); prefs->RegisterDictionaryPref(prefs::kPreferencesWindowPlacement); - // We need to register the type of this preference in order to query - // it even though it's only typically controlled via policy. + // We need to register the type of these preferences in order to query + // them even though they're only typically controlled via policy. prefs->RegisterBooleanPref(prefs::kDisable3DAPIs, false); + prefs->RegisterBooleanPref(prefs::kPluginsAllowOutdated, false); } // static diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 0395c0e..fcde88d 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -574,6 +574,9 @@ const char kPluginsShowSetReaderDefaultInfobar[] = // Whether about:plugins is shown in the details mode or not. const char kPluginsShowDetails[] = "plugins.show_details"; +// Boolean that indicates whether outdated plugins are allowed or not. +const char kPluginsAllowOutdated[] = "plugins.allow_outdated"; + // Boolean that indicates whether we should check if we are the default browser // on start-up. const char kCheckDefaultBrowser[] = "browser.check_default_browser"; diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 9622eb2..4fb2846 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -210,6 +210,7 @@ extern const char kPluginsEnabledPlugins[]; extern const char kPluginsEnabledInternalPDF[]; extern const char kPluginsShowSetReaderDefaultInfobar[]; extern const char kPluginsShowDetails[]; +extern const char kPluginsAllowOutdated[]; extern const char kCheckDefaultBrowser[]; extern const char kDefaultBrowserSettingEnabled[]; #if defined(OS_MACOSX) diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 5212785..c3e28df 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -406,12 +406,20 @@ IPC_MESSAGE_CONTROL2(ViewHostMsg_V8HeapStats, // Request for a DNS prefetch of the names in the array. // NameList is typedef'ed std::vector<std::string> IPC_MESSAGE_CONTROL1(ViewHostMsg_DnsPrefetch, - std::vector<std::string> /* hostnames */) + std::vector<std::string> /* hostnames */) // Notifies when default plugin updates status of the missing plugin. IPC_MESSAGE_ROUTED1(ViewHostMsg_MissingPluginStatus, int /* status */) +// Requests the outdated plugins policy. +// |policy| is one of ALLOW, BLOCK or ASK. Anything else is an error. +// ALLOW means that outdated plugins are allowed, and BLOCK that they should +// be blocked. The default is ASK, which blocks the plugin initially but allows +// the user to start them manually. +IPC_SYNC_MESSAGE_ROUTED0_1(ViewHostMsg_GetOutdatedPluginsPolicy, + ContentSetting /* policy */) + // Notifies when a plugin couldn't be loaded because it's outdated. IPC_MESSAGE_ROUTED2(ViewHostMsg_BlockedOutdatedPlugin, string16, /* name */ diff --git a/chrome/renderer/blocked_plugin.cc b/chrome/renderer/blocked_plugin.cc index 879de9b..5e6c883 100644 --- a/chrome/renderer/blocked_plugin.cc +++ b/chrome/renderer/blocked_plugin.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -58,12 +58,14 @@ BlockedPlugin::BlockedPlugin(RenderView* render_view, const WebPreferences& preferences, int template_id, const string16& message, - bool is_blocked_for_prerendering) + bool is_blocked_for_prerendering, + bool allow_loading) : RenderViewObserver(render_view), frame_(frame), plugin_params_(params), is_blocked_for_prerendering_(is_blocked_for_prerendering), - hidden_(false) { + hidden_(false), + allow_loading_(allow_loading) { const base::StringPiece template_html( ResourceBundle::GetSharedInstance().GetRawDataResource(template_id)); @@ -115,7 +117,8 @@ void BlockedPlugin::ShowContextMenu(const WebKit::WebMouseEvent& event) { WebMenuItemInfo run_item; run_item.action = kMenuActionLoad; - run_item.enabled = true; + // Disable this menu item if the plugin is blocked by policy. + run_item.enabled = allow_loading_; run_item.label = WebString::fromUTF8( l10n_util::GetStringUTF8(IDS_CONTENT_CONTEXT_PLUGIN_RUN).c_str()); run_item.hasTextDirectionOverride = false; @@ -172,6 +175,8 @@ void BlockedPlugin::LoadPlugin() { // event propagation changes between "close" vs. "click-to-play". if (hidden_) return; + if (!allow_loading_) + return; WebPluginContainer* container = plugin_->container(); WebPlugin* new_plugin = render_view()->CreatePluginNoCheck(frame_, plugin_params_); diff --git a/chrome/renderer/blocked_plugin.h b/chrome/renderer/blocked_plugin.h index deda427..93bf00a 100644 --- a/chrome/renderer/blocked_plugin.h +++ b/chrome/renderer/blocked_plugin.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -34,7 +34,8 @@ class BlockedPlugin : public RenderViewObserver, const WebPreferences& settings, int template_id, const string16& message, - bool is_blocked_for_prerendering); + bool is_blocked_for_prerendering, + bool allow_loading); webkit::npapi::WebViewPlugin* plugin() { return plugin_; } @@ -77,6 +78,7 @@ class BlockedPlugin : public RenderViewObserver, // Plugin will automatically be loaded when the page is displayed. bool is_blocked_for_prerendering_; bool hidden_; + bool allow_loading_; }; #endif // CHROME_RENDERER_BLOCKED_PLUGIN_H_ diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index c2327602..a997758 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc @@ -75,14 +75,27 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( webkit::npapi::PluginList::Singleton()->GetPluginGroup(info); DCHECK(group != NULL); - if (group->IsVulnerable() && - !cmd->HasSwitch(switches::kAllowOutdatedPlugins)) { - render_view->Send(new ViewHostMsg_BlockedOutdatedPlugin( - render_view->routing_id(), group->GetGroupName(), - GURL(group->GetUpdateURL()))); - return CreatePluginPlaceholder( - render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML, - IDS_PLUGIN_OUTDATED, false); + if (group->IsVulnerable()) { + // The outdated plugins policy isn't cached here because + // it's a dynamic policy that can be modified at runtime. + ContentSetting outdated_plugins_policy; + render_view->Send(new ViewHostMsg_GetOutdatedPluginsPolicy( + render_view->routing_id(), &outdated_plugins_policy)); + + if (outdated_plugins_policy == CONTENT_SETTING_ASK || + outdated_plugins_policy == CONTENT_SETTING_BLOCK) { + if (outdated_plugins_policy == CONTENT_SETTING_ASK) { + render_view->Send(new ViewHostMsg_BlockedOutdatedPlugin( + render_view->routing_id(), group->GetGroupName(), + GURL(group->GetUpdateURL()))); + } + return CreatePluginPlaceholder( + render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML, + IDS_PLUGIN_OUTDATED, false, + outdated_plugins_policy == CONTENT_SETTING_ASK); + } else { + DCHECK(outdated_plugins_policy == CONTENT_SETTING_ALLOW); + } } ContentSetting host_setting = render_view->current_content_settings_. @@ -97,7 +110,7 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( render_view->routing_id(), group->GetGroupName(), GURL())); return CreatePluginPlaceholder( render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML, - IDS_PLUGIN_NOT_AUTHORIZED, false); + IDS_PLUGIN_NOT_AUTHORIZED, false, true); } if (info.path.value() == webkit::npapi::kDefaultPluginLibraryName || @@ -107,7 +120,7 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( if (render_view->is_prerendering_) { return CreatePluginPlaceholder( render_view, frame, params, *group, IDR_CLICK_TO_PLAY_PLUGIN_HTML, - IDS_PLUGIN_LOAD, true); + IDS_PLUGIN_LOAD, true, true); } scoped_refptr<webkit::ppapi::PluginModule> pepper_module( @@ -128,11 +141,11 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( if (plugin_setting == CONTENT_SETTING_ASK) { return CreatePluginPlaceholder( render_view, frame, params, *group, IDR_CLICK_TO_PLAY_PLUGIN_HTML, - IDS_PLUGIN_LOAD, false); + IDS_PLUGIN_LOAD, false, true); } else { return CreatePluginPlaceholder( render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML, - IDS_PLUGIN_BLOCKED, false); + IDS_PLUGIN_BLOCKED, false, true); } } @@ -143,7 +156,8 @@ WebPlugin* ChromeContentRendererClient::CreatePluginPlaceholder( const webkit::npapi::PluginGroup& group, int resource_id, int message_id, - bool is_blocked_for_prerendering) { + bool is_blocked_for_prerendering, + bool allow_loading) { // |blocked_plugin| will delete itself when the WebViewPlugin // is destroyed. BlockedPlugin* blocked_plugin = @@ -155,7 +169,8 @@ WebPlugin* ChromeContentRendererClient::CreatePluginPlaceholder( resource_id, l10n_util::GetStringFUTF16(message_id, group.GetGroupName()), - is_blocked_for_prerendering); + is_blocked_for_prerendering, + allow_loading); return blocked_plugin->plugin(); } diff --git a/chrome/renderer/chrome_content_renderer_client.h b/chrome/renderer/chrome_content_renderer_client.h index 3489181..4d90a92 100644 --- a/chrome/renderer/chrome_content_renderer_client.h +++ b/chrome/renderer/chrome_content_renderer_client.h @@ -39,7 +39,8 @@ class ChromeContentRendererClient : public content::ContentRendererClient { const webkit::npapi::PluginGroup& group, int resource_id, int message_id, - bool is_blocked_for_prerendering); + bool is_blocked_for_prerendering, + bool allow_loading); }; } // namespace chrome |