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

Unified Diff: chrome/browser/content_settings/content_settings_platform_app_provider.cc

Issue 9169042: Block plugins for platform apps (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/content_settings/content_settings_platform_app_provider.cc
diff --git a/chrome/browser/content_settings/content_settings_platform_app_provider.cc b/chrome/browser/content_settings/content_settings_platform_app_provider.cc
new file mode 100644
index 0000000000000000000000000000000000000000..edfb20039e37a0535dc0892af06cff930558ad67
--- /dev/null
+++ b/chrome/browser/content_settings/content_settings_platform_app_provider.cc
@@ -0,0 +1,57 @@
+// Copyright (c) 2012 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.
+
+#include "chrome/browser/content_settings/content_settings_platform_app_provider.h"
+
+#include "chrome/browser/content_settings/content_settings_rule.h"
+#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/content_settings.h"
+#include "chrome/common/content_settings_pattern.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/url_constants.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/notification_details.h"
+#include "content/public/browser/notification_service.h"
+
+namespace content_settings {
+
+PlatformAppProvider::PlatformAppProvider() {
+ registrar_.Add(this, chrome::NOTIFICATION_PLATFORM_APP_STARTED,
+ content::NotificationService::AllSources());
+}
+
+RuleIterator* PlatformAppProvider::GetRuleIterator(
+ ContentSettingsType content_type,
+ const ResourceIdentifier& resource_identifier,
+ bool incognito) const {
+ return value_map_.GetRuleIterator(content_type, resource_identifier, &lock_);
+}
+
+void PlatformAppProvider::Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ DCHECK(type == chrome::NOTIFICATION_PLATFORM_APP_STARTED);
+ const Extension* extension = content::Details<const Extension>(details).ptr();
+ DCHECK(extension->is_platform_app());
+
+ base::AutoLock lock(lock_);
+ scoped_ptr<ContentSettingsPattern::BuilderInterface> pattern_builder(
+ ContentSettingsPattern::CreateBuilder(false));
+ pattern_builder->WithScheme(chrome::kExtensionScheme);
+ pattern_builder->WithHost(extension->id());
+ pattern_builder->WithPathWildcard();
+
+ value_map_.SetValue(pattern_builder->Build(),
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_PLUGINS,
+ ResourceIdentifier("adobe-flash-player"),
Bernhard Bauer 2012/01/25 13:59:04 Can't we just disallow all plug-ins already? ;-)
+ Value::CreateIntegerValue(CONTENT_SETTING_BLOCK));
+}
+
+void PlatformAppProvider::ShutdownOnUIThread() {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ registrar_.RemoveAll();
+}
+
+} // namespace content_settings

Powered by Google App Engine
This is Rietveld 408576698