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

Side by Side Diff: chrome/browser/ui/webui/options/website_settings_handler.cc

Issue 504773004: Add Cookie permission to Website Settings single side view. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments addressed. 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
« no previous file with comments | « chrome/browser/resources/options/website_settings_edit_site.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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,
34 CONTENT_SETTINGS_TYPE_MEDIASTREAM}; 34 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
35 CONTENT_SETTINGS_TYPE_MEDIASTREAM,
36 CONTENT_SETTINGS_TYPE_COOKIES};
35 const size_t kValidTypesLength = arraysize(kValidTypes); 37 const size_t kValidTypesLength = arraysize(kValidTypes);
36 } // namespace 38 } // namespace
37 39
38 namespace options { 40 namespace options {
39 41
40 WebsiteSettingsHandler::WebsiteSettingsHandler() 42 WebsiteSettingsHandler::WebsiteSettingsHandler()
41 : observer_(this), weak_ptr_factory_(this) { 43 : observer_(this), weak_ptr_factory_(this) {
42 } 44 }
43 45
44 WebsiteSettingsHandler::~WebsiteSettingsHandler() { 46 WebsiteSettingsHandler::~WebsiteSettingsHandler() {
45 } 47 }
46 48
47 void WebsiteSettingsHandler::GetLocalizedValues( 49 void WebsiteSettingsHandler::GetLocalizedValues(
48 base::DictionaryValue* localized_strings) { 50 base::DictionaryValue* localized_strings) {
49 DCHECK(localized_strings); 51 DCHECK(localized_strings);
50 52
51 static OptionsStringResource resources[] = { 53 static OptionsStringResource resources[] = {
52 {"websitesOptionsPageTabTitle", IDS_WEBSITE_SETTINGS_TITLE}, 54 {"websitesOptionsPageTabTitle", IDS_WEBSITE_SETTINGS_TITLE},
53 {"websitesSettingsEditPage", IDS_WEBSITE_SETTINGS_EDIT_TITLE}, 55 {"websitesSettingsEditPage", IDS_WEBSITE_SETTINGS_EDIT_TITLE},
54 {"websitesManage", IDS_WEBSITE_SETTINGS_MANAGE}, 56 {"websitesManage", IDS_WEBSITE_SETTINGS_MANAGE},
55 {"websitesSearch", IDS_WEBSITE_SETTINGS_SEARCH_ORIGINS}, 57 {"websitesSearch", IDS_WEBSITE_SETTINGS_SEARCH_ORIGINS},
56 {"websitesLabelGeolocation", IDS_WEBSITE_SETTINGS_TYPE_LOCATION}, 58 {"websitesLabelGeolocation", IDS_WEBSITE_SETTINGS_TYPE_LOCATION},
57 {"websitesLabelMediaStream", IDS_WEBSITE_SETTINGS_TYPE_MEDIASTREAM}, 59 {"websitesLabelMediaStream", IDS_WEBSITE_SETTINGS_TYPE_MEDIASTREAM},
58 {"websitesLabelNotifications", IDS_WEBSITE_SETTINGS_TYPE_NOTIFICATIONS}, 60 {"websitesLabelNotifications", IDS_WEBSITE_SETTINGS_TYPE_NOTIFICATIONS},
59 {"websitesLabelStorage", IDS_WEBSITE_SETTINGS_TYPE_STORAGE}, 61 {"websitesLabelStorage", IDS_WEBSITE_SETTINGS_TYPE_STORAGE},
62 {"websitesCookiesDescription", IDS_WEBSITE_SETTINGS_COOKIES_DESCRIPTION},
60 {"websitesLocationDescription", 63 {"websitesLocationDescription",
61 IDS_WEBSITE_SETTINGS_LOCATION_DESCRIPTION}, 64 IDS_WEBSITE_SETTINGS_LOCATION_DESCRIPTION},
62 {"websitesMediastreamDescription", 65 {"websitesMediastreamDescription",
63 IDS_WEBSITE_SETTINGS_MEDIASTREAM_DESCRIPTION}, 66 IDS_WEBSITE_SETTINGS_MEDIASTREAM_DESCRIPTION},
64 {"websitesNotificationsDescription", 67 {"websitesNotificationsDescription",
65 IDS_WEBSITE_SETTINGS_NOTIFICATIONS_DESCRIPTION}, 68 IDS_WEBSITE_SETTINGS_NOTIFICATIONS_DESCRIPTION},
66 {"websitesButtonClear", IDS_WEBSITE_SETTINGS_STORAGE_CLEAR_BUTTON}, 69 {"websitesButtonClear", IDS_WEBSITE_SETTINGS_STORAGE_CLEAR_BUTTON},
67 }; 70 };
68 71
69 RegisterStrings(localized_strings, resources, arraysize(resources)); 72 RegisterStrings(localized_strings, resources, arraysize(resources));
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 map->GetDefaultContentSetting(settings_type, NULL); 304 map->GetDefaultContentSetting(settings_type, NULL);
302 305
303 // Users are not allowed to be the source of the "ask" setting. It is an 306 // 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. 307 // ephemeral setting which is removed once the question is asked.
305 if (setting == CONTENT_SETTING_ASK && setting == default_value) 308 if (setting == CONTENT_SETTING_ASK && setting == default_value)
306 setting = CONTENT_SETTING_DEFAULT; 309 setting = CONTENT_SETTING_DEFAULT;
307 310
308 ContentSettingsPattern primary_pattern; 311 ContentSettingsPattern primary_pattern;
309 ContentSettingsPattern secondary_pattern; 312 ContentSettingsPattern secondary_pattern;
310 switch (settings_type) { 313 switch (settings_type) {
314 case CONTENT_SETTINGS_TYPE_COOKIES:
315 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_);
316 secondary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_);
317 break;
311 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: 318 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
312 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); 319 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_);
313 secondary_pattern = ContentSettingsPattern::Wildcard(); 320 secondary_pattern = ContentSettingsPattern::Wildcard();
314 break; 321 break;
315 case CONTENT_SETTINGS_TYPE_GEOLOCATION: 322 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
316 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); 323 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_);
317 secondary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); 324 secondary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_);
318 break; 325 break;
319 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: 326 case CONTENT_SETTINGS_TYPE_MEDIASTREAM:
320 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); 327 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 map->GetDefaultContentSetting(permission_type, NULL); 389 map->GetDefaultContentSetting(permission_type, NULL);
383 if (default_value != CONTENT_SETTING_ALLOW && 390 if (default_value != CONTENT_SETTING_ALLOW &&
384 default_value != CONTENT_SETTING_BLOCK) { 391 default_value != CONTENT_SETTING_BLOCK) {
385 options->AppendString( 392 options->AppendString(
386 content_settings::ContentSettingToString(default_value)); 393 content_settings::ContentSettingToString(default_value));
387 } 394 }
388 options->AppendString( 395 options->AppendString(
389 content_settings::ContentSettingToString(CONTENT_SETTING_ALLOW)); 396 content_settings::ContentSettingToString(CONTENT_SETTING_ALLOW));
390 options->AppendString( 397 options->AppendString(
391 content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK)); 398 content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK));
399 if (permission_type == CONTENT_SETTINGS_TYPE_COOKIES) {
400 options->AppendString(content_settings::ContentSettingToString(
401 CONTENT_SETTING_SESSION_ONLY));
402 }
392 403
393 ContentSetting permission; 404 ContentSetting permission;
394 content_settings::SettingInfo info; 405 content_settings::SettingInfo info;
395 if (permission_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { 406 if (permission_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) {
396 scoped_ptr<base::Value> mic_value( 407 scoped_ptr<base::Value> mic_value(
397 map->GetWebsiteSetting(site_url, 408 map->GetWebsiteSetting(site_url,
398 site_url, 409 site_url,
399 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, 410 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
400 std::string(), 411 std::string(),
401 &info)); 412 &info));
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 510
500 // Load a new BrowsingDataLocalStorageHelper to update. 511 // Load a new BrowsingDataLocalStorageHelper to update.
501 local_storage_ = new BrowsingDataLocalStorageHelper(profile); 512 local_storage_ = new BrowsingDataLocalStorageHelper(profile);
502 513
503 local_storage_->StartFetching( 514 local_storage_->StartFetching(
504 base::Bind(&WebsiteSettingsHandler::OnLocalStorageFetched, 515 base::Bind(&WebsiteSettingsHandler::OnLocalStorageFetched,
505 weak_ptr_factory_.GetWeakPtr())); 516 weak_ptr_factory_.GetWeakPtr()));
506 } 517 }
507 518
508 } // namespace options 519 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/website_settings_edit_site.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698