OLD | NEW |
---|---|
1 // Copyright 2014 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/webui/options/website_settings_handler.h" | 5 #include "chrome/browser/ui/webui/options/website_settings_handler.h" |
6 | 6 |
7 #include "apps/app_window_registry.h" | 7 #include "apps/app_window_registry.h" |
8 #include "chrome/browser/content_settings/content_settings_utils.h" | 8 #include "chrome/browser/content_settings/content_settings_utils.h" |
9 #include "chrome/browser/content_settings/host_content_settings_map.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
23 #include "ui/base/l10n/time_format.h" | 23 #include "ui/base/l10n/time_format.h" |
24 #include "ui/base/text/bytes_formatting.h" | 24 #include "ui/base/text/bytes_formatting.h" |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 const int kHttpPort = 80; | 28 const int kHttpPort = 80; |
29 const int kHttpsPort = 443; | 29 const int kHttpsPort = 443; |
30 const char kPreferencesSource[] = "preference"; | 30 const char kPreferencesSource[] = "preference"; |
31 const char kStorage[] = "storage"; | 31 const char kStorage[] = "storage"; |
32 const ContentSettingsType kValidTypes[] = {CONTENT_SETTINGS_TYPE_GEOLOCATION, | 32 const ContentSettingsType kValidTypes[] = { |
33 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 33 CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
Bernhard Bauer
2014/08/26 08:12:27
Put each on an individual line.
Daniel Nishi
2014/08/26 17:26:50
Done.
| |
34 CONTENT_SETTINGS_TYPE_MEDIASTREAM}; | 34 CONTENT_SETTINGS_TYPE_MEDIASTREAM, CONTENT_SETTINGS_TYPE_COOKIES}; |
35 const size_t kValidTypesLength = arraysize(kValidTypes); | 35 const size_t kValidTypesLength = arraysize(kValidTypes); |
36 } // namespace | 36 } // namespace |
37 | 37 |
38 namespace options { | 38 namespace options { |
39 | 39 |
40 WebsiteSettingsHandler::WebsiteSettingsHandler() | 40 WebsiteSettingsHandler::WebsiteSettingsHandler() |
41 : observer_(this), weak_ptr_factory_(this) { | 41 : observer_(this), weak_ptr_factory_(this) { |
42 } | 42 } |
43 | 43 |
44 WebsiteSettingsHandler::~WebsiteSettingsHandler() { | 44 WebsiteSettingsHandler::~WebsiteSettingsHandler() { |
45 } | 45 } |
46 | 46 |
47 void WebsiteSettingsHandler::GetLocalizedValues( | 47 void WebsiteSettingsHandler::GetLocalizedValues( |
48 base::DictionaryValue* localized_strings) { | 48 base::DictionaryValue* localized_strings) { |
49 DCHECK(localized_strings); | 49 DCHECK(localized_strings); |
50 | 50 |
51 static OptionsStringResource resources[] = { | 51 static OptionsStringResource resources[] = { |
52 {"websitesOptionsPageTabTitle", IDS_WEBSITE_SETTINGS_TITLE}, | 52 {"websitesOptionsPageTabTitle", IDS_WEBSITE_SETTINGS_TITLE}, |
53 {"websitesSettingsEditPage", IDS_WEBSITE_SETTINGS_EDIT_TITLE}, | 53 {"websitesSettingsEditPage", IDS_WEBSITE_SETTINGS_EDIT_TITLE}, |
54 {"websitesManage", IDS_WEBSITE_SETTINGS_MANAGE}, | 54 {"websitesManage", IDS_WEBSITE_SETTINGS_MANAGE}, |
55 {"websitesSearch", IDS_WEBSITE_SETTINGS_SEARCH_ORIGINS}, | 55 {"websitesSearch", IDS_WEBSITE_SETTINGS_SEARCH_ORIGINS}, |
56 {"websitesLabelGeolocation", IDS_WEBSITE_SETTINGS_TYPE_LOCATION}, | 56 {"websitesLabelGeolocation", IDS_WEBSITE_SETTINGS_TYPE_LOCATION}, |
57 {"websitesLabelMediaStream", IDS_WEBSITE_SETTINGS_TYPE_MEDIASTREAM}, | 57 {"websitesLabelMediaStream", IDS_WEBSITE_SETTINGS_TYPE_MEDIASTREAM}, |
58 {"websitesLabelNotifications", IDS_WEBSITE_SETTINGS_TYPE_NOTIFICATIONS}, | 58 {"websitesLabelNotifications", IDS_WEBSITE_SETTINGS_TYPE_NOTIFICATIONS}, |
59 {"websitesLabelStorage", IDS_WEBSITE_SETTINGS_TYPE_STORAGE}, | 59 {"websitesLabelStorage", IDS_WEBSITE_SETTINGS_TYPE_STORAGE}, |
60 {"websitesCookiesDescription", IDS_WEBSITE_SETTINGS_COOKIES_DESCRIPTION}, | |
60 {"websitesLocationDescription", | 61 {"websitesLocationDescription", |
61 IDS_WEBSITE_SETTINGS_LOCATION_DESCRIPTION}, | 62 IDS_WEBSITE_SETTINGS_LOCATION_DESCRIPTION}, |
62 {"websitesMediastreamDescription", | 63 {"websitesMediastreamDescription", |
63 IDS_WEBSITE_SETTINGS_MEDIASTREAM_DESCRIPTION}, | 64 IDS_WEBSITE_SETTINGS_MEDIASTREAM_DESCRIPTION}, |
64 {"websitesNotificationsDescription", | 65 {"websitesNotificationsDescription", |
65 IDS_WEBSITE_SETTINGS_NOTIFICATIONS_DESCRIPTION}, | 66 IDS_WEBSITE_SETTINGS_NOTIFICATIONS_DESCRIPTION}, |
66 {"websitesButtonClear", IDS_WEBSITE_SETTINGS_STORAGE_CLEAR_BUTTON}, | 67 {"websitesButtonClear", IDS_WEBSITE_SETTINGS_STORAGE_CLEAR_BUTTON}, |
67 }; | 68 }; |
68 | 69 |
69 RegisterStrings(localized_strings, resources, arraysize(resources)); | 70 RegisterStrings(localized_strings, resources, arraysize(resources)); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
301 map->GetDefaultContentSetting(settings_type, NULL); | 302 map->GetDefaultContentSetting(settings_type, NULL); |
302 | 303 |
303 // Users are not allowed to be the source of the "ask" setting. It is an | 304 // Users are not allowed to be the source of the "ask" setting. It is an |
304 // ephemeral setting which is removed once the question is asked. | 305 // ephemeral setting which is removed once the question is asked. |
305 if (setting == CONTENT_SETTING_ASK && setting == default_value) | 306 if (setting == CONTENT_SETTING_ASK && setting == default_value) |
306 setting = CONTENT_SETTING_DEFAULT; | 307 setting = CONTENT_SETTING_DEFAULT; |
307 | 308 |
308 ContentSettingsPattern primary_pattern; | 309 ContentSettingsPattern primary_pattern; |
309 ContentSettingsPattern secondary_pattern; | 310 ContentSettingsPattern secondary_pattern; |
310 switch (settings_type) { | 311 switch (settings_type) { |
312 case CONTENT_SETTINGS_TYPE_COOKIES: | |
313 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); | |
314 secondary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); | |
315 break; | |
311 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 316 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
312 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); | 317 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); |
313 secondary_pattern = ContentSettingsPattern::Wildcard(); | 318 secondary_pattern = ContentSettingsPattern::Wildcard(); |
314 break; | 319 break; |
315 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | 320 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
316 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); | 321 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); |
317 secondary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); | 322 secondary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); |
318 break; | 323 break; |
319 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: | 324 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: |
320 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); | 325 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 map->GetDefaultContentSetting(permission_type, NULL); | 387 map->GetDefaultContentSetting(permission_type, NULL); |
383 if (default_value != CONTENT_SETTING_ALLOW && | 388 if (default_value != CONTENT_SETTING_ALLOW && |
384 default_value != CONTENT_SETTING_BLOCK) { | 389 default_value != CONTENT_SETTING_BLOCK) { |
385 options->AppendString( | 390 options->AppendString( |
386 content_settings::ContentSettingToString(default_value)); | 391 content_settings::ContentSettingToString(default_value)); |
387 } | 392 } |
388 options->AppendString( | 393 options->AppendString( |
389 content_settings::ContentSettingToString(CONTENT_SETTING_ALLOW)); | 394 content_settings::ContentSettingToString(CONTENT_SETTING_ALLOW)); |
390 options->AppendString( | 395 options->AppendString( |
391 content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK)); | 396 content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK)); |
397 if (permission_type == CONTENT_SETTINGS_TYPE_COOKIES) | |
Bernhard Bauer
2014/08/26 08:12:27
Wrap multiline bodies in braces.
Daniel Nishi
2014/08/26 17:26:50
Done.
| |
398 options->AppendString(content_settings::ContentSettingToString( | |
399 CONTENT_SETTING_SESSION_ONLY)); | |
392 | 400 |
393 ContentSetting permission; | 401 ContentSetting permission; |
394 content_settings::SettingInfo info; | 402 content_settings::SettingInfo info; |
395 if (permission_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { | 403 if (permission_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { |
396 scoped_ptr<base::Value> mic_value( | 404 scoped_ptr<base::Value> mic_value( |
397 map->GetWebsiteSetting(site_url, | 405 map->GetWebsiteSetting(site_url, |
398 site_url, | 406 site_url, |
399 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, | 407 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
400 std::string(), | 408 std::string(), |
401 &info)); | 409 &info)); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
499 | 507 |
500 // Load a new BrowsingDataLocalStorageHelper to update. | 508 // Load a new BrowsingDataLocalStorageHelper to update. |
501 local_storage_ = new BrowsingDataLocalStorageHelper(profile); | 509 local_storage_ = new BrowsingDataLocalStorageHelper(profile); |
502 | 510 |
503 local_storage_->StartFetching( | 511 local_storage_->StartFetching( |
504 base::Bind(&WebsiteSettingsHandler::OnLocalStorageFetched, | 512 base::Bind(&WebsiteSettingsHandler::OnLocalStorageFetched, |
505 weak_ptr_factory_.GetWeakPtr())); | 513 weak_ptr_factory_.GetWeakPtr())); |
506 } | 514 } |
507 | 515 |
508 } // namespace options | 516 } // namespace options |
OLD | NEW |