| Index: chrome/browser/ui/webui/options/content_settings_handler.cc
|
| diff --git a/chrome/browser/ui/webui/options/content_settings_handler.cc b/chrome/browser/ui/webui/options/content_settings_handler.cc
|
| index f3a773cff6ea05c1e68904ac82354bfbdb1703d0..81bfe95a3249f2ac4a9987740126a696af1294ad 100644
|
| --- a/chrome/browser/ui/webui/options/content_settings_handler.cc
|
| +++ b/chrome/browser/ui/webui/options/content_settings_handler.cc
|
| @@ -10,6 +10,7 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/bind_helpers.h"
|
| +#include "base/command_line.h"
|
| #include "base/logging.h"
|
| #include "base/prefs/pref_service.h"
|
| #include "base/strings/string_number_conversions.h"
|
| @@ -24,6 +25,7 @@
|
| #include "chrome/browser/notifications/desktop_notification_profile_util.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/ui/browser_list.h"
|
| +#include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "chrome/common/url_constants.h"
|
| @@ -518,11 +520,21 @@ void ContentSettingsHandler::InitializeHandler() {
|
| base::Unretained(this),
|
| CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC));
|
| pref_change_registrar_.Add(
|
| + prefs::kAudioCaptureAllowedUrls,
|
| + base::Bind(&ContentSettingsHandler::UpdateExceptionsViewFromModel,
|
| + base::Unretained(this),
|
| + CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC));
|
| + pref_change_registrar_.Add(
|
| prefs::kVideoCaptureAllowed,
|
| base::Bind(&ContentSettingsHandler::UpdateSettingDefaultFromModel,
|
| base::Unretained(this),
|
| CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA));
|
| pref_change_registrar_.Add(
|
| + prefs::kVideoCaptureAllowedUrls,
|
| + base::Bind(&ContentSettingsHandler::UpdateExceptionsViewFromModel,
|
| + base::Unretained(this),
|
| + CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA));
|
| + pref_change_registrar_.Add(
|
| prefs::kEnableDRM,
|
| base::Bind(
|
| &ContentSettingsHandler::UpdateProtectedContentExceptionsButton,
|
| @@ -1099,6 +1111,49 @@ void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap(
|
| type_string, exceptions);
|
| }
|
|
|
| +base::ListValue* ContentSettingsHandler::GetPolicyAllowedUrls(
|
| + ContentSettingsType type) {
|
| + DCHECK(type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
|
| + type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
|
| +
|
| + PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
|
| + const base::ListValue* policy_urls = prefs->GetList(
|
| + type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC
|
| + ? prefs::kAudioCaptureAllowedUrls
|
| + : prefs::kVideoCaptureAllowedUrls);
|
| +
|
| + // Convert the URLs to |ContentSettingsPattern|s. Ignore any invalid ones.
|
| + std::vector<ContentSettingsPattern> patterns;
|
| + for (const base::Value* entry : *policy_urls) {
|
| + std::string url;
|
| + bool valid_string = entry->GetAsString(&url);
|
| + if (!valid_string)
|
| + continue;
|
| +
|
| + ContentSettingsPattern pattern = ContentSettingsPattern::FromString(url);
|
| + if (!pattern.IsValid())
|
| + continue;
|
| +
|
| + patterns.push_back(pattern);
|
| + }
|
| +
|
| + // The patterns are shown in the UI in a reverse order defined by
|
| + // |ContentSettingsPattern::operator<|.
|
| + std::sort(
|
| + patterns.begin(), patterns.end(), std::greater<ContentSettingsPattern>());
|
| +
|
| + base::ListValue* exceptions = new base::ListValue();
|
| + for (const ContentSettingsPattern& pattern : patterns) {
|
| + exceptions->Append(GetExceptionForPage(
|
| + pattern,
|
| + ContentSettingsPattern(),
|
| + CONTENT_SETTING_ALLOW,
|
| + kPolicyProviderId));
|
| + }
|
| +
|
| + return exceptions;
|
| +}
|
| +
|
| void ContentSettingsHandler::GetExceptionsFromHostContentSettingsMap(
|
| const HostContentSettingsMap* map,
|
| ContentSettingsType type,
|
| @@ -1180,6 +1235,18 @@ void ContentSettingsHandler::GetExceptionsFromHostContentSettingsMap(
|
| }
|
| }
|
|
|
| + // For camera and microphone, we do not have policy exceptions, but we do have
|
| + // the policy-set allowed URLs, which should be displayed in the same manner.
|
| + if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
|
| + type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) {
|
| + scoped_ptr<base::ListValue> exceptions_list(GetPolicyAllowedUrls(type));
|
| + std::vector<base::Value*>& policy_exceptions = all_provider_exceptions.at(
|
| + HostContentSettingsMap::GetProviderTypeFromSource(kPolicyProviderId));
|
| +
|
| + for (const base::Value* exception : *exceptions_list)
|
| + policy_exceptions.push_back(exception->DeepCopy());
|
| + }
|
| +
|
| for (size_t i = 0; i < all_provider_exceptions.size(); ++i) {
|
| for (size_t j = 0; j < all_provider_exceptions[i].size(); ++j) {
|
| exceptions->Append(all_provider_exceptions[i][j]);
|
|
|