summaryrefslogtreecommitdiffstats
path: root/components/content_settings/core/browser/content_settings_default_provider.cc
blob: 07adc4d80961f04f9ca7cdc752e4cb87db3d2c31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
// 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 "components/content_settings/core/browser/content_settings_default_provider.h"

#include <string>
#include <vector>

#include "base/auto_reset.h"
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
#include "base/prefs/scoped_user_pref_update.h"
#include "components/content_settings/core/browser/content_settings_rule.h"
#include "components/content_settings/core/browser/content_settings_utils.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "url/gurl.h"

namespace {

struct DefaultContentSettingInfo {
  // The profile preference associated with this default setting.
  const char* pref_name;

  // The default value of this default setting.
  const ContentSetting default_value;

  // Whether this preference should be synced.
  const bool syncable;
};

// The corresponding preference, default value and syncability for each
// default content setting. This array must be kept in sync with the enum
// |ContentSettingsType|.
const DefaultContentSettingInfo kDefaultSettings[] = {

  {prefs::kDefaultCookiesSetting, CONTENT_SETTING_ALLOW, true},
  {prefs::kDefaultImagesSetting, CONTENT_SETTING_ALLOW, true},
  {prefs::kDefaultJavaScriptSetting, CONTENT_SETTING_ALLOW, true},
  {prefs::kDefaultPluginsSetting, CONTENT_SETTING_ALLOW, true},
  {prefs::kDefaultPopupsSetting, CONTENT_SETTING_BLOCK, true},
  {prefs::kDefaultGeolocationSetting, CONTENT_SETTING_ASK, false},
  {prefs::kDefaultNotificationsSetting, CONTENT_SETTING_ASK, false},
  {prefs::kDefaultAutoSelectCertificateSetting, CONTENT_SETTING_DEFAULT, false},
  {prefs::kDefaultFullScreenSetting, CONTENT_SETTING_ASK, true},
  {prefs::kDefaultMouseLockSetting, CONTENT_SETTING_ASK, true},
  {prefs::kDefaultMixedScriptSetting, CONTENT_SETTING_DEFAULT, true},
  {prefs::kDefaultMediaStreamSetting, CONTENT_SETTING_ASK, false},
  {prefs::kDefaultMediaStreamMicSetting, CONTENT_SETTING_ASK, false},
  {prefs::kDefaultMediaStreamCameraSetting, CONTENT_SETTING_ASK, false},
  {prefs::kDefaultProtocolHandlersSetting, CONTENT_SETTING_DEFAULT, true},
  {prefs::kDefaultPpapiBrokerSetting, CONTENT_SETTING_ASK, false},
  {prefs::kDefaultAutomaticDownloadsSetting, CONTENT_SETTING_ASK, true},
  {prefs::kDefaultMidiSysexSetting, CONTENT_SETTING_ASK, true},
  {prefs::kDefaultPushMessagingSetting, CONTENT_SETTING_ASK, true},
  {prefs::kDefaultSSLCertDecisionsSetting, CONTENT_SETTING_ALLOW, false},
#if defined(OS_WIN)
  {prefs::kDefaultMetroSwitchToDesktopSetting, CONTENT_SETTING_ASK, true},
#elif defined(OS_ANDROID) || defined(OS_CHROMEOS)
  {prefs::kDefaultProtectedMediaIdentifierSetting, CONTENT_SETTING_ASK, false},
#endif
  {prefs::kDefaultAppBannerSetting, CONTENT_SETTING_DEFAULT, false}

};
static_assert(arraysize(kDefaultSettings) == CONTENT_SETTINGS_NUM_TYPES,
              "kDefaultSettings should have CONTENT_SETTINGS_NUM_TYPES "
              "elements");

}  // namespace

namespace content_settings {

namespace {

class DefaultRuleIterator : public RuleIterator {
 public:
  explicit DefaultRuleIterator(const base::Value* value) {
    if (value)
      value_.reset(value->DeepCopy());
  }

  bool HasNext() const override { return value_.get() != NULL; }

  Rule Next() override {
    DCHECK(value_.get());
    return Rule(ContentSettingsPattern::Wildcard(),
                ContentSettingsPattern::Wildcard(),
                value_.release());
  }

 private:
  scoped_ptr<base::Value> value_;
};

}  // namespace

// static
void DefaultProvider::RegisterProfilePrefs(
    user_prefs::PrefRegistrySyncable* registry) {
  // The registration of the preference prefs::kDefaultContentSettings should
  // also include the default values for default content settings. This allows
  // functional tests to get default content settings by reading the preference
  // prefs::kDefaultContentSettings via pyauto.
  // TODO(markusheintz): Write pyauto hooks for the content settings map as
  // content settings should be read from the host content settings map.
  base::DictionaryValue* default_content_settings = new base::DictionaryValue();
  registry->RegisterDictionaryPref(
      prefs::kDefaultContentSettings,
      default_content_settings,
      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);

  // Register individual default setting preferences.
  // TODO(msramek): The aggregate preference above is deprecated. Remove it
  // after two stable releases.
  for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
    registry->RegisterIntegerPref(
        kDefaultSettings[i].pref_name,
        kDefaultSettings[i].default_value,
        kDefaultSettings[i].syncable
            ? user_prefs::PrefRegistrySyncable::SYNCABLE_PREF
            : user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
  }

  // Whether the deprecated dictionary preference has already been migrated
  // into the individual preferences in this profile.
  registry->RegisterBooleanPref(
      prefs::kMigratedDefaultContentSettings,
      false,
      user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);

  // Whether the deprecated mediastream default setting has already been
  // migrated into microphone and camera default settings.
  registry->RegisterBooleanPref(
      prefs::kMigratedDefaultMediaStreamSetting,
      false,
      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
}

DefaultProvider::DefaultProvider(PrefService* prefs, bool incognito)
    : prefs_(prefs),
      is_incognito_(incognito),
      updating_preferences_(false) {
  DCHECK(prefs_);

  // Migrate the dictionary of default content settings to the new individual
  // preferences.
  MigrateDefaultSettings();

  // Migrate the obsolete media stream default setting into the new microphone
  // and camera settings.
  MigrateObsoleteMediaContentSetting();

  // Read global defaults.
  ReadDefaultSettings();

  UMA_HISTOGRAM_ENUMERATION(
      "ContentSettings.DefaultCookiesSetting",
      IntToContentSetting(prefs_->GetInteger(
          kDefaultSettings[CONTENT_SETTINGS_TYPE_COOKIES].pref_name)),
      CONTENT_SETTING_NUM_SETTINGS);
  UMA_HISTOGRAM_ENUMERATION(
      "ContentSettings.DefaultImagesSetting",
      IntToContentSetting(prefs_->GetInteger(
          kDefaultSettings[CONTENT_SETTINGS_TYPE_IMAGES].pref_name)),
      CONTENT_SETTING_NUM_SETTINGS);
  UMA_HISTOGRAM_ENUMERATION(
      "ContentSettings.DefaultJavaScriptSetting",
      IntToContentSetting(prefs_->GetInteger(
          kDefaultSettings[CONTENT_SETTINGS_TYPE_JAVASCRIPT].pref_name)),
      CONTENT_SETTING_NUM_SETTINGS);
  UMA_HISTOGRAM_ENUMERATION(
      "ContentSettings.DefaultPluginsSetting",
      IntToContentSetting(prefs_->GetInteger(
          kDefaultSettings[CONTENT_SETTINGS_TYPE_PLUGINS].pref_name)),
      CONTENT_SETTING_NUM_SETTINGS);
  UMA_HISTOGRAM_ENUMERATION(
      "ContentSettings.DefaultPopupsSetting",
      IntToContentSetting(prefs_->GetInteger(
          kDefaultSettings[CONTENT_SETTINGS_TYPE_POPUPS].pref_name)),
      CONTENT_SETTING_NUM_SETTINGS);
  UMA_HISTOGRAM_ENUMERATION(
      "ContentSettings.DefaultLocationSetting",
      IntToContentSetting(prefs_->GetInteger(
          kDefaultSettings[CONTENT_SETTINGS_TYPE_GEOLOCATION].pref_name)),
      CONTENT_SETTING_NUM_SETTINGS);
  UMA_HISTOGRAM_ENUMERATION(
      "ContentSettings.DefaultNotificationsSetting",
      IntToContentSetting(prefs_->GetInteger(
          kDefaultSettings[CONTENT_SETTINGS_TYPE_NOTIFICATIONS].pref_name)),
      CONTENT_SETTING_NUM_SETTINGS);
  UMA_HISTOGRAM_ENUMERATION(
      "ContentSettings.DefaultMouseCursorSetting",
      IntToContentSetting(prefs_->GetInteger(
          kDefaultSettings[CONTENT_SETTINGS_TYPE_MOUSELOCK].pref_name)),
      CONTENT_SETTING_NUM_SETTINGS);
  UMA_HISTOGRAM_ENUMERATION(
      "ContentSettings.DefaultMediaStreamSetting",
      IntToContentSetting(prefs_->GetInteger(
          kDefaultSettings[CONTENT_SETTINGS_TYPE_MEDIASTREAM].pref_name)),
      CONTENT_SETTING_NUM_SETTINGS);
  UMA_HISTOGRAM_ENUMERATION(
      "ContentSettings.DefaultMIDISysExSetting",
      IntToContentSetting(prefs_->GetInteger(
          kDefaultSettings[CONTENT_SETTINGS_TYPE_MIDI_SYSEX].pref_name)),
      CONTENT_SETTING_NUM_SETTINGS);
  UMA_HISTOGRAM_ENUMERATION(
      "ContentSettings.DefaultPushMessagingSetting",
      IntToContentSetting(prefs_->GetInteger(
          kDefaultSettings[CONTENT_SETTINGS_TYPE_PUSH_MESSAGING].pref_name)),
      CONTENT_SETTING_NUM_SETTINGS);

  pref_change_registrar_.Init(prefs_);
  PrefChangeRegistrar::NamedChangeCallback callback = base::Bind(
      &DefaultProvider::OnPreferenceChanged, base::Unretained(this));
  pref_change_registrar_.Add(prefs::kDefaultContentSettings, callback);

  for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i)
    pref_change_registrar_.Add(kDefaultSettings[i].pref_name, callback);
}

DefaultProvider::~DefaultProvider() {
}

bool DefaultProvider::SetWebsiteSetting(
    const ContentSettingsPattern& primary_pattern,
    const ContentSettingsPattern& secondary_pattern,
    ContentSettingsType content_type,
    const ResourceIdentifier& resource_identifier,
    base::Value* in_value) {
  DCHECK(CalledOnValidThread());
  DCHECK(prefs_);

  // Ignore non default settings
  if (primary_pattern != ContentSettingsPattern::Wildcard() ||
      secondary_pattern != ContentSettingsPattern::Wildcard()) {
    return false;
  }

  // The default settings may not be directly modified for OTR sessions.
  // Instead, they are synced to the main profile's setting.
  if (is_incognito_)
    return false;

  // Put |in_value| in a scoped pointer to ensure that it gets cleaned up
  // properly if we don't pass on the ownership.
  scoped_ptr<base::Value> value(in_value);
  {
    base::AutoReset<bool> auto_reset(&updating_preferences_, true);
    base::AutoLock lock(lock_);

    ChangeSetting(content_type, value.get());
    WriteIndividualPref(content_type, value.get());

    // If the changed setting is syncable, write it to the old dictionary
    // preference as well, so it can be synced to older versions of Chrome.
    // TODO(msramek): Remove this after two stable releases.
    if (kDefaultSettings[content_type].syncable)
      WriteDictionaryPref(content_type, value.get());
  }

  NotifyObservers(ContentSettingsPattern(),
                  ContentSettingsPattern(),
                  content_type,
                  std::string());

  return true;
}

RuleIterator* DefaultProvider::GetRuleIterator(
    ContentSettingsType content_type,
    const ResourceIdentifier& resource_identifier,
    bool incognito) const {
  base::AutoLock lock(lock_);
  if (resource_identifier.empty()) {
    ValueMap::const_iterator it(default_settings_.find(content_type));
    if (it != default_settings_.end()) {
      return new DefaultRuleIterator(it->second.get());
    }
    NOTREACHED();
  }
  return new EmptyRuleIterator();
}

void DefaultProvider::ClearAllContentSettingsRules(
    ContentSettingsType content_type) {
  // TODO(markusheintz): This method is only called when the
  // |DesktopNotificationService| calls |ClearAllSettingsForType| method on the
  // |HostContentSettingsMap|. Don't implement this method yet, otherwise the
  // default notification settings will be cleared as well.
}

void DefaultProvider::ShutdownOnUIThread() {
  DCHECK(CalledOnValidThread());
  DCHECK(prefs_);
  RemoveAllObservers();
  pref_change_registrar_.RemoveAll();
  prefs_ = NULL;
}

void DefaultProvider::ReadDefaultSettings() {
  base::AutoLock lock(lock_);
  for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
    ContentSettingsType content_type = ContentSettingsType(i);
    ChangeSetting(content_type, ReadIndividualPref(content_type).get());
  }
}

bool DefaultProvider::IsValueEmptyOrDefault(ContentSettingsType content_type,
                                       base::Value* value) {
  return (!value ||
          ValueToContentSetting(value)
              == kDefaultSettings[content_type].default_value);
}

void DefaultProvider::ChangeSetting(ContentSettingsType content_type,
                                    base::Value* value) {
  if (!value) {
    default_settings_[content_type].reset(ContentSettingToValue(
        kDefaultSettings[content_type].default_value).release());
  } else {
    default_settings_[content_type].reset(value->DeepCopy());
  }
}

void DefaultProvider::WriteIndividualPref(ContentSettingsType content_type,
                                          base::Value* value) {
  if (IsValueEmptyOrDefault(content_type, value)) {
    prefs_->ClearPref(kDefaultSettings[content_type].pref_name);
    return;
  }

  int int_value = kDefaultSettings[content_type].default_value;
  bool is_integer = value->GetAsInteger(&int_value);
  DCHECK(is_integer);
  prefs_->SetInteger(kDefaultSettings[content_type].pref_name, int_value);
}

void DefaultProvider::WriteDictionaryPref(ContentSettingsType content_type,
                                          base::Value* value) {
  // |DefaultProvider| should not send any notifications when holding
  // |lock_|. |DictionaryPrefUpdate| destructor and
  // |PrefService::SetInteger()| send out notifications. As a response, the
  // upper layers may call |GetAllContentSettingRules| which acquires |lock_|
  // again.
  DictionaryPrefUpdate update(prefs_, prefs::kDefaultContentSettings);
  base::DictionaryValue* default_settings_dictionary = update.Get();

  if (IsValueEmptyOrDefault(content_type, value)) {
    default_settings_dictionary->RemoveWithoutPathExpansion(
        GetTypeName(content_type), NULL);
    return;
  }

  default_settings_dictionary->SetWithoutPathExpansion(
      GetTypeName(content_type), value->DeepCopy());
}

void DefaultProvider::OnPreferenceChanged(const std::string& name) {
  DCHECK(CalledOnValidThread());
  if (updating_preferences_)
    return;

  // Write the changed setting from individual preferences to dictionary,
  // or vice versa - depending on which of them changed.
  // TODO(msramek): This is only necessary in the phase of migration between
  // the old dictionary preference and the new individual preferences. Remove
  // this after two stable releases.
  std::vector<ContentSettingsType> to_notify;

  if (name == prefs::kDefaultContentSettings) {
    // If the dictionary preference gets synced from an old version
    // of Chrome, we should update all individual preferences that
    // are marked as syncable.
    base::AutoLock lock(lock_);
    base::AutoReset<bool> auto_reset(&updating_preferences_, true);

    scoped_ptr<ValueMap> dictionary = ReadDictionaryPref();

    for (const auto& it : *dictionary) {
      if (!kDefaultSettings[it.first].syncable)
        continue;

      DCHECK(default_settings_.find(it.first) != default_settings_.end());
      ChangeSetting(it.first, it.second.get());
      WriteIndividualPref(it.first, it.second.get());
      to_notify.push_back(it.first);
    }
  } else {
    // Find out which content setting the preference corresponds to.
    ContentSettingsType content_type = CONTENT_SETTINGS_TYPE_DEFAULT;

    for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
      if (kDefaultSettings[i].pref_name == name) {
        content_type = ContentSettingsType(i);
        break;
      }
    }

    if (content_type == CONTENT_SETTINGS_TYPE_DEFAULT) {
      NOTREACHED() << "Unexpected preference observed";
      return;
    }

    // A new individual preference is changed. If it is syncable, we should
    // change its entry in the dictionary preference as well, so that it
    // can be synced to older versions of Chrome.
    base::AutoLock lock(lock_);
    base::AutoReset<bool> auto_reset(&updating_preferences_, true);

    ChangeSetting(content_type, ReadIndividualPref(content_type).get());
    if (kDefaultSettings[content_type].syncable)
      WriteDictionaryPref(content_type, default_settings_[content_type].get());
    to_notify.push_back(content_type);
  }

  for (const ContentSettingsType content_type : to_notify) {
    NotifyObservers(ContentSettingsPattern(),
                    ContentSettingsPattern(),
                    content_type,
                    std::string());
  }
}

scoped_ptr<base::Value> DefaultProvider::ReadIndividualPref(
    ContentSettingsType content_type) {
  int int_value = prefs_->GetInteger(kDefaultSettings[content_type].pref_name);
  return ContentSettingToValue(IntToContentSetting(int_value)).Pass();
}

scoped_ptr<DefaultProvider::ValueMap> DefaultProvider::ReadDictionaryPref() {
  const base::DictionaryValue* default_settings_dictionary =
      prefs_->GetDictionary(prefs::kDefaultContentSettings);

  scoped_ptr<ValueMap> value_map =
      GetSettingsFromDictionary(default_settings_dictionary);

  ForceDefaultsToBeExplicit(value_map.get());

  // Migrate obsolete cookie prompt mode.
  if (ValueToContentSetting(
          (*value_map)[CONTENT_SETTINGS_TYPE_COOKIES].get()) ==
      CONTENT_SETTING_ASK) {
    (*value_map)[CONTENT_SETTINGS_TYPE_COOKIES].reset(
        new base::FundamentalValue(CONTENT_SETTING_BLOCK));
  }
#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
  // Migrate protected media from allow to ask.
  if (ValueToContentSetting(
          (*value_map)[CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER]
              .get()) == CONTENT_SETTING_ALLOW) {
    (*value_map)[CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER].reset(
        new base::FundamentalValue(CONTENT_SETTING_ASK));
  }
#endif
  return value_map.Pass();
}

void DefaultProvider::ForceDefaultsToBeExplicit(ValueMap* value_map) {
  for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
    ContentSettingsType type = ContentSettingsType(i);
    if (!(*value_map)[type].get()) {
      (*value_map)[type].reset(ContentSettingToValue(
          kDefaultSettings[i].default_value).release());
    }
  }
}

scoped_ptr<DefaultProvider::ValueMap>
    DefaultProvider::GetSettingsFromDictionary(
        const base::DictionaryValue* dictionary) {
  scoped_ptr<ValueMap> value_map(new ValueMap());
  if (!dictionary)
    return value_map.Pass();

  for (base::DictionaryValue::Iterator i(*dictionary);
       !i.IsAtEnd(); i.Advance()) {
    const std::string& content_type(i.key());
    for (int type = 0; type < CONTENT_SETTINGS_NUM_TYPES; ++type) {
      if (content_type == GetTypeName(ContentSettingsType(type))) {
        int int_value = CONTENT_SETTING_DEFAULT;
        bool is_integer = i.value().GetAsInteger(&int_value);
        DCHECK(is_integer);
        (*value_map)[ContentSettingsType(type)].reset(
            ContentSettingToValue(IntToContentSetting(int_value)).release());
        break;
      }
    }
  }

  return value_map.Pass();
}

void DefaultProvider::MigrateDefaultSettings() {
  // Only do the migration once.
  if (prefs_->GetBoolean(prefs::kMigratedDefaultContentSettings))
    return;

  scoped_ptr<DefaultProvider::ValueMap> value_map = ReadDictionaryPref();

  for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
    ContentSettingsType content_type = ContentSettingsType(i);
    WriteIndividualPref(content_type, (*value_map)[content_type].get());
  }

  prefs_->SetBoolean(prefs::kMigratedDefaultContentSettings, true);
}

void DefaultProvider::MigrateObsoleteMediaContentSetting() {
  // We only do the migration once.
  if (prefs_->GetBoolean(prefs::kMigratedDefaultMediaStreamSetting))
    return;

  scoped_ptr<base::Value> value = ReadIndividualPref(
      CONTENT_SETTINGS_TYPE_MEDIASTREAM);
  WriteIndividualPref(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, value.get());
  WriteIndividualPref(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, value.get());
  WriteIndividualPref(CONTENT_SETTINGS_TYPE_MEDIASTREAM, NULL);

  prefs_->SetBoolean(prefs::kMigratedDefaultMediaStreamSetting, true);
}

}  // namespace content_settings