OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 primary_pattern = ContentSettingsPattern::FromURL(site_url_); | 136 primary_pattern = ContentSettingsPattern::FromURL(site_url_); |
137 secondary_pattern = ContentSettingsPattern::Wildcard(); | 137 secondary_pattern = ContentSettingsPattern::Wildcard(); |
138 break; | 138 break; |
139 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: { | 139 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: { |
140 // We need to use the same same patterns as other places like infobar code | 140 // We need to use the same same patterns as other places like infobar code |
141 // to override the existing rule instead of creating the new one. | 141 // to override the existing rule instead of creating the new one. |
142 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_); | 142 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_); |
143 secondary_pattern = ContentSettingsPattern::Wildcard(); | 143 secondary_pattern = ContentSettingsPattern::Wildcard(); |
144 // Set permission for both microphone and camera. | 144 // Set permission for both microphone and camera. |
145 content_settings_->SetContentSetting( | 145 content_settings_->SetContentSetting( |
146 primary_pattern, secondary_pattern, | 146 primary_pattern, |
147 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, "", setting); | 147 secondary_pattern, |
| 148 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
| 149 std::string(), |
| 150 setting); |
148 | 151 |
149 content_settings_->SetContentSetting( | 152 content_settings_->SetContentSetting( |
150 primary_pattern, secondary_pattern, | 153 primary_pattern, |
151 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, "", setting); | 154 secondary_pattern, |
| 155 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, |
| 156 std::string(), |
| 157 setting); |
152 break; | 158 break; |
153 } | 159 } |
154 default: | 160 default: |
155 NOTREACHED() << "ContentSettingsType " << type << "is not supported."; | 161 NOTREACHED() << "ContentSettingsType " << type << "is not supported."; |
156 break; | 162 break; |
157 } | 163 } |
158 | 164 |
159 if (type != CONTENT_SETTINGS_TYPE_MEDIASTREAM) { | 165 if (type != CONTENT_SETTINGS_TYPE_MEDIASTREAM) { |
160 // Permission settings are specified via rules. There exists always at least | 166 // Permission settings are specified via rules. There exists always at least |
161 // one rule for the default setting. Get the rule that currently defines | 167 // one rule for the default setting. Get the rule that currently defines |
162 // the permission for the given permission |type|. Then test whether the | 168 // the permission for the given permission |type|. Then test whether the |
163 // existing rule is more specific than the rule we are about to create. If | 169 // existing rule is more specific than the rule we are about to create. If |
164 // the existing rule is more specific, than change the existing rule instead | 170 // the existing rule is more specific, than change the existing rule instead |
165 // of creating a new rule that would be hidden behind the existing rule. | 171 // of creating a new rule that would be hidden behind the existing rule. |
166 // This is not a concern for CONTENT_SETTINGS_TYPE_MEDIASTREAM since users | 172 // This is not a concern for CONTENT_SETTINGS_TYPE_MEDIASTREAM since users |
167 // can not create media settings exceptions by hand. | 173 // can not create media settings exceptions by hand. |
168 content_settings::SettingInfo info; | 174 content_settings::SettingInfo info; |
169 scoped_ptr<Value> v(content_settings_->GetWebsiteSetting( | 175 scoped_ptr<Value> v(content_settings_->GetWebsiteSetting( |
170 site_url_, site_url_, type, "", &info)); | 176 site_url_, site_url_, type, std::string(), &info)); |
171 DCHECK(info.source == content_settings::SETTING_SOURCE_USER); | 177 DCHECK(info.source == content_settings::SETTING_SOURCE_USER); |
172 ContentSettingsPattern::Relation r1 = | 178 ContentSettingsPattern::Relation r1 = |
173 info.primary_pattern.Compare(primary_pattern); | 179 info.primary_pattern.Compare(primary_pattern); |
174 DCHECK(r1 != ContentSettingsPattern::DISJOINT_ORDER_POST && | 180 DCHECK(r1 != ContentSettingsPattern::DISJOINT_ORDER_POST && |
175 r1 != ContentSettingsPattern::DISJOINT_ORDER_PRE); | 181 r1 != ContentSettingsPattern::DISJOINT_ORDER_PRE); |
176 if (r1 == ContentSettingsPattern::PREDECESSOR) { | 182 if (r1 == ContentSettingsPattern::PREDECESSOR) { |
177 primary_pattern = info.primary_pattern; | 183 primary_pattern = info.primary_pattern; |
178 } else if (r1 == ContentSettingsPattern::IDENTITY) { | 184 } else if (r1 == ContentSettingsPattern::IDENTITY) { |
179 ContentSettingsPattern::Relation r2 = | 185 ContentSettingsPattern::Relation r2 = |
180 info.secondary_pattern.Compare(secondary_pattern); | 186 info.secondary_pattern.Compare(secondary_pattern); |
181 DCHECK(r2 != ContentSettingsPattern::DISJOINT_ORDER_POST && | 187 DCHECK(r2 != ContentSettingsPattern::DISJOINT_ORDER_POST && |
182 r2 != ContentSettingsPattern::DISJOINT_ORDER_PRE); | 188 r2 != ContentSettingsPattern::DISJOINT_ORDER_PRE); |
183 if (r2 == ContentSettingsPattern::PREDECESSOR) | 189 if (r2 == ContentSettingsPattern::PREDECESSOR) |
184 secondary_pattern = info.secondary_pattern; | 190 secondary_pattern = info.secondary_pattern; |
185 } | 191 } |
186 | 192 |
187 Value* value = NULL; | 193 Value* value = NULL; |
188 if (setting != CONTENT_SETTING_DEFAULT) | 194 if (setting != CONTENT_SETTING_DEFAULT) |
189 value = Value::CreateIntegerValue(setting); | 195 value = Value::CreateIntegerValue(setting); |
190 content_settings_->SetWebsiteSetting( | 196 content_settings_->SetWebsiteSetting( |
191 primary_pattern, secondary_pattern, type, "", value); | 197 primary_pattern, secondary_pattern, type, std::string(), value); |
192 } | 198 } |
193 | 199 |
194 show_info_bar_ = true; | 200 show_info_bar_ = true; |
195 | 201 |
196 // TODO(markusheintz): This is a temporary hack to fix issue: | 202 // TODO(markusheintz): This is a temporary hack to fix issue: |
197 // http://crbug.com/144203. | 203 // http://crbug.com/144203. |
198 #if defined(OS_MACOSX) | 204 #if defined(OS_MACOSX) |
199 // Refresh the UI to reflect the new setting. | 205 // Refresh the UI to reflect the new setting. |
200 PresentSitePermissions(); | 206 PresentSitePermissions(); |
201 #endif | 207 #endif |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 void WebsiteSettings::PresentSitePermissions() { | 451 void WebsiteSettings::PresentSitePermissions() { |
446 PermissionInfoList permission_info_list; | 452 PermissionInfoList permission_info_list; |
447 | 453 |
448 WebsiteSettingsUI::PermissionInfo permission_info; | 454 WebsiteSettingsUI::PermissionInfo permission_info; |
449 for (size_t i = 0; i < arraysize(kPermissionType); ++i) { | 455 for (size_t i = 0; i < arraysize(kPermissionType); ++i) { |
450 permission_info.type = kPermissionType[i]; | 456 permission_info.type = kPermissionType[i]; |
451 | 457 |
452 content_settings::SettingInfo info; | 458 content_settings::SettingInfo info; |
453 if (permission_info.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { | 459 if (permission_info.type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { |
454 scoped_ptr<base::Value> mic_value(content_settings_->GetWebsiteSetting( | 460 scoped_ptr<base::Value> mic_value(content_settings_->GetWebsiteSetting( |
455 site_url_, site_url_, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, | 461 site_url_, |
456 "", &info)); | 462 site_url_, |
| 463 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
| 464 std::string(), |
| 465 &info)); |
457 ContentSetting mic_setting = | 466 ContentSetting mic_setting = |
458 content_settings::ValueToContentSetting(mic_value.get()); | 467 content_settings::ValueToContentSetting(mic_value.get()); |
459 | 468 |
460 scoped_ptr<base::Value> camera_value(content_settings_->GetWebsiteSetting( | 469 scoped_ptr<base::Value> camera_value(content_settings_->GetWebsiteSetting( |
461 site_url_, site_url_, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | 470 site_url_, |
462 "", &info)); | 471 site_url_, |
| 472 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, |
| 473 std::string(), |
| 474 &info)); |
463 ContentSetting camera_setting = | 475 ContentSetting camera_setting = |
464 content_settings::ValueToContentSetting(camera_value.get()); | 476 content_settings::ValueToContentSetting(camera_value.get()); |
465 | 477 |
466 if (mic_setting != camera_setting || mic_setting == CONTENT_SETTING_ASK) | 478 if (mic_setting != camera_setting || mic_setting == CONTENT_SETTING_ASK) |
467 permission_info.setting = CONTENT_SETTING_DEFAULT; | 479 permission_info.setting = CONTENT_SETTING_DEFAULT; |
468 else | 480 else |
469 permission_info.setting = mic_setting; | 481 permission_info.setting = mic_setting; |
470 } else { | 482 } else { |
471 scoped_ptr<Value> value(content_settings_->GetWebsiteSetting( | 483 scoped_ptr<Value> value(content_settings_->GetWebsiteSetting( |
472 site_url_, site_url_, permission_info.type, "", &info)); | 484 site_url_, site_url_, permission_info.type, std::string(), &info)); |
473 DCHECK(value.get()); | 485 DCHECK(value.get()); |
474 if (value->GetType() == Value::TYPE_INTEGER) { | 486 if (value->GetType() == Value::TYPE_INTEGER) { |
475 permission_info.setting = | 487 permission_info.setting = |
476 content_settings::ValueToContentSetting(value.get()); | 488 content_settings::ValueToContentSetting(value.get()); |
477 } else { | 489 } else { |
478 NOTREACHED(); | 490 NOTREACHED(); |
479 } | 491 } |
480 } | 492 } |
481 | 493 |
482 permission_info.source = info.source; | 494 permission_info.source = info.source; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 first_visit_text = l10n_util::GetStringFUTF16( | 574 first_visit_text = l10n_util::GetStringFUTF16( |
563 IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY, | 575 IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY, |
564 base::TimeFormatShortDate(first_visit)); | 576 base::TimeFormatShortDate(first_visit)); |
565 } else { | 577 } else { |
566 first_visit_text = l10n_util::GetStringUTF16( | 578 first_visit_text = l10n_util::GetStringUTF16( |
567 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY); | 579 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY); |
568 | 580 |
569 } | 581 } |
570 ui_->SetFirstVisit(first_visit_text); | 582 ui_->SetFirstVisit(first_visit_text); |
571 } | 583 } |
OLD | NEW |