| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/settings/site_settings_handler.h" | 5 #include "chrome/browser/ui/webui/settings/site_settings_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 8 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
| 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 base::Bind(&SiteSettingsHandler::HandleGetExceptionList, | 55 base::Bind(&SiteSettingsHandler::HandleGetExceptionList, |
| 56 base::Unretained(this))); | 56 base::Unretained(this))); |
| 57 web_ui()->RegisterMessageCallback( | 57 web_ui()->RegisterMessageCallback( |
| 58 "resetCategoryPermissionForOrigin", | 58 "resetCategoryPermissionForOrigin", |
| 59 base::Bind(&SiteSettingsHandler::HandleResetCategoryPermissionForOrigin, | 59 base::Bind(&SiteSettingsHandler::HandleResetCategoryPermissionForOrigin, |
| 60 base::Unretained(this))); | 60 base::Unretained(this))); |
| 61 web_ui()->RegisterMessageCallback( | 61 web_ui()->RegisterMessageCallback( |
| 62 "setCategoryPermissionForOrigin", | 62 "setCategoryPermissionForOrigin", |
| 63 base::Bind(&SiteSettingsHandler::HandleSetCategoryPermissionForOrigin, | 63 base::Bind(&SiteSettingsHandler::HandleSetCategoryPermissionForOrigin, |
| 64 base::Unretained(this))); | 64 base::Unretained(this))); |
| 65 web_ui()->RegisterMessageCallback( |
| 66 "isPatternValid", |
| 67 base::Bind(&SiteSettingsHandler::HandleIsPatternValid, |
| 68 base::Unretained(this))); |
| 65 } | 69 } |
| 66 | 70 |
| 67 void SiteSettingsHandler::OnGetUsageInfo( | 71 void SiteSettingsHandler::OnGetUsageInfo( |
| 68 const storage::UsageInfoEntries& entries) { | 72 const storage::UsageInfoEntries& entries) { |
| 69 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 73 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 70 | 74 |
| 71 for (const auto& entry : entries) { | 75 for (const auto& entry : entries) { |
| 72 if (entry.usage <= 0) continue; | 76 if (entry.usage <= 0) continue; |
| 73 if (entry.host == usage_host_) { | 77 if (entry.host == usage_host_) { |
| 74 web_ui()->CallJavascriptFunction( | 78 web_ui()->CallJavascriptFunction( |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 HostContentSettingsMap* map = | 254 HostContentSettingsMap* map = |
| 251 HostContentSettingsMapFactory::GetForProfile(profile_); | 255 HostContentSettingsMapFactory::GetForProfile(profile_); |
| 252 map->SetContentSettingCustomScope( | 256 map->SetContentSettingCustomScope( |
| 253 ContentSettingsPattern::FromString(primary_pattern), | 257 ContentSettingsPattern::FromString(primary_pattern), |
| 254 secondary_pattern.empty() ? | 258 secondary_pattern.empty() ? |
| 255 ContentSettingsPattern::Wildcard() : | 259 ContentSettingsPattern::Wildcard() : |
| 256 ContentSettingsPattern::FromString(secondary_pattern), | 260 ContentSettingsPattern::FromString(secondary_pattern), |
| 257 content_type, "", setting); | 261 content_type, "", setting); |
| 258 } | 262 } |
| 259 | 263 |
| 264 void SiteSettingsHandler::HandleIsPatternValid( |
| 265 const base::ListValue* args) { |
| 266 CHECK_EQ(2U, args->GetSize()); |
| 267 const base::Value* callback_id; |
| 268 CHECK(args->Get(0, &callback_id)); |
| 269 std::string pattern_string; |
| 270 CHECK(args->GetString(1, &pattern_string)); |
| 271 |
| 272 ContentSettingsPattern pattern = |
| 273 ContentSettingsPattern::FromString(pattern_string); |
| 274 ResolveJavascriptCallback( |
| 275 *callback_id, base::FundamentalValue(pattern.IsValid())); |
| 276 } |
| 277 |
| 260 } // namespace settings | 278 } // namespace settings |
| OLD | NEW |