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

Side by Side Diff: chrome/browser/ui/website_settings/website_settings.cc

Issue 542253003: Add a global on/off switch for content settings and expose a toggle on the Website Settings options… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@global-settings
Patch Set: Forgot to clarify ownership comments. Created 6 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser/ui/website_settings/website_settings.h" 5 #include "chrome/browser/ui/website_settings/website_settings.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 if (type != CONTENT_SETTINGS_TYPE_MEDIASTREAM) { 267 if (type != CONTENT_SETTINGS_TYPE_MEDIASTREAM) {
268 // Permission settings are specified via rules. There exists always at least 268 // Permission settings are specified via rules. There exists always at least
269 // one rule for the default setting. Get the rule that currently defines 269 // one rule for the default setting. Get the rule that currently defines
270 // the permission for the given permission |type|. Then test whether the 270 // the permission for the given permission |type|. Then test whether the
271 // existing rule is more specific than the rule we are about to create. If 271 // existing rule is more specific than the rule we are about to create. If
272 // the existing rule is more specific, than change the existing rule instead 272 // the existing rule is more specific, than change the existing rule instead
273 // of creating a new rule that would be hidden behind the existing rule. 273 // of creating a new rule that would be hidden behind the existing rule.
274 // This is not a concern for CONTENT_SETTINGS_TYPE_MEDIASTREAM since users 274 // This is not a concern for CONTENT_SETTINGS_TYPE_MEDIASTREAM since users
275 // can not create media settings exceptions by hand. 275 // can not create media settings exceptions by hand.
276 content_settings::SettingInfo info; 276 content_settings::SettingInfo info;
277 scoped_ptr<base::Value> v(content_settings_->GetWebsiteSetting( 277 scoped_ptr<base::Value> v =
278 site_url_, site_url_, type, std::string(), &info)); 278 content_settings_->GetWebsiteSettingWithoutOverride(
Bernhard Bauer 2014/09/10 17:44:54 Why do you need the setting without override here?
Daniel Nishi 2014/09/10 17:55:52 The Website Settings site info dialog, which would
279 site_url_, site_url_, type, std::string(), &info);
279 content_settings_->SetNarrowestWebsiteSetting( 280 content_settings_->SetNarrowestWebsiteSetting(
280 primary_pattern, secondary_pattern, type, std::string(), setting, info); 281 primary_pattern, secondary_pattern, type, std::string(), setting, info);
281 } else { 282 } else {
282 base::Value* value = NULL; 283 base::Value* value = NULL;
283 if (setting != CONTENT_SETTING_DEFAULT) 284 if (setting != CONTENT_SETTING_DEFAULT)
284 value = new base::FundamentalValue(setting); 285 value = new base::FundamentalValue(setting);
285 content_settings_->SetWebsiteSetting( 286 content_settings_->SetWebsiteSetting(
286 primary_pattern, secondary_pattern, type, std::string(), value); 287 primary_pattern, secondary_pattern, type, std::string(), value);
287 } 288 }
288 289
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 for (size_t i = 0; i < arraysize(kPermissionType); ++i) { 610 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
610 permission_info.type = kPermissionType[i]; 611 permission_info.type = kPermissionType[i];
611 if (permission_info.type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { 612 if (permission_info.type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
612 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 613 const CommandLine* command_line = CommandLine::ForCurrentProcess();
613 if (!command_line->HasSwitch(switches::kEnableWebMIDI)) 614 if (!command_line->HasSwitch(switches::kEnableWebMIDI))
614 continue; 615 continue;
615 } 616 }
616 617
617 content_settings::SettingInfo info; 618 content_settings::SettingInfo info;
618 if (permission_info.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { 619 if (permission_info.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) {
619 scoped_ptr<base::Value> mic_value(content_settings_->GetWebsiteSetting( 620 scoped_ptr<base::Value> mic_value =
620 site_url_, 621 content_settings_->GetWebsiteSettingWithoutOverride(
621 site_url_, 622 site_url_,
622 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, 623 site_url_,
623 std::string(), 624 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
624 &info)); 625 std::string(),
626 &info);
625 ContentSetting mic_setting = 627 ContentSetting mic_setting =
626 content_settings::ValueToContentSetting(mic_value.get()); 628 content_settings::ValueToContentSetting(mic_value.get());
627 629
628 scoped_ptr<base::Value> camera_value(content_settings_->GetWebsiteSetting( 630 scoped_ptr<base::Value> camera_value =
629 site_url_, 631 content_settings_->GetWebsiteSettingWithoutOverride(
630 site_url_, 632 site_url_,
631 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, 633 site_url_,
632 std::string(), 634 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
633 &info)); 635 std::string(),
636 &info);
634 ContentSetting camera_setting = 637 ContentSetting camera_setting =
635 content_settings::ValueToContentSetting(camera_value.get()); 638 content_settings::ValueToContentSetting(camera_value.get());
636 639
637 if (mic_setting != camera_setting || mic_setting == CONTENT_SETTING_ASK) 640 if (mic_setting != camera_setting || mic_setting == CONTENT_SETTING_ASK)
638 permission_info.setting = CONTENT_SETTING_DEFAULT; 641 permission_info.setting = CONTENT_SETTING_DEFAULT;
639 else 642 else
640 permission_info.setting = mic_setting; 643 permission_info.setting = mic_setting;
641 } else { 644 } else {
642 scoped_ptr<base::Value> value(content_settings_->GetWebsiteSetting( 645 scoped_ptr<base::Value> value =
643 site_url_, site_url_, permission_info.type, std::string(), &info)); 646 content_settings_->GetWebsiteSettingWithoutOverride(
647 site_url_, site_url_, permission_info.type, std::string(), &info);
644 DCHECK(value.get()); 648 DCHECK(value.get());
645 if (value->GetType() == base::Value::TYPE_INTEGER) { 649 if (value->GetType() == base::Value::TYPE_INTEGER) {
646 permission_info.setting = 650 permission_info.setting =
647 content_settings::ValueToContentSetting(value.get()); 651 content_settings::ValueToContentSetting(value.get());
648 } else { 652 } else {
649 NOTREACHED(); 653 NOTREACHED();
650 } 654 }
651 } 655 }
652 656
653 permission_info.source = info.source; 657 permission_info.source = info.source;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 if (visited_before_today) { 742 if (visited_before_today) {
739 first_visit_text = l10n_util::GetStringFUTF16( 743 first_visit_text = l10n_util::GetStringFUTF16(
740 IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY, 744 IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY,
741 base::TimeFormatShortDate(first_visit)); 745 base::TimeFormatShortDate(first_visit));
742 } else { 746 } else {
743 first_visit_text = l10n_util::GetStringUTF16( 747 first_visit_text = l10n_util::GetStringUTF16(
744 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY); 748 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY);
745 } 749 }
746 ui_->SetFirstVisit(first_visit_text); 750 ui_->SetFirstVisit(first_visit_text);
747 } 751 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698