Chromium Code Reviews| 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/site_settings_helper.h" | 5 #include "chrome/browser/ui/webui/site_settings_helper.h" |
| 6 | 6 |
| 7 #include <functional> | 7 #include <functional> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/permissions/chooser_context_base.h" | 12 #include "chrome/browser/permissions/chooser_context_base.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/usb/usb_chooser_context_factory.h" | 14 #include "chrome/browser/usb/usb_chooser_context_factory.h" |
| 15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 16 #include "components/content_settings/core/browser/host_content_settings_map.h" | 16 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 17 #include "components/prefs/pref_service.h" | 17 #include "components/prefs/pref_service.h" |
| 18 | 18 |
| 19 namespace site_settings { | 19 namespace site_settings { |
| 20 | 20 |
| 21 const char kAppName[] = "appName"; | |
| 22 const char kAppId[] = "appId"; | |
| 21 const char kSetting[] = "setting"; | 23 const char kSetting[] = "setting"; |
| 22 const char kOrigin[] = "origin"; | 24 const char kOrigin[] = "origin"; |
| 23 const char kPolicyProviderId[] = "policy"; | 25 const char kPolicyProviderId[] = "policy"; |
| 24 const char kSource[] = "source"; | 26 const char kSource[] = "source"; |
| 25 const char kIncognito[] = "incognito"; | 27 const char kIncognito[] = "incognito"; |
| 26 const char kEmbeddingOrigin[] = "embeddingOrigin"; | 28 const char kEmbeddingOrigin[] = "embeddingOrigin"; |
| 27 const char kPreferencesSource[] = "preference"; | 29 const char kPreferencesSource[] = "preference"; |
| 28 const char kObject[] = "object"; | 30 const char kObject[] = "object"; |
| 29 const char kObjectName[] = "objectName"; | 31 const char kObjectName[] = "objectName"; |
| 30 | 32 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 std::string ContentSettingsTypeToGroupName(ContentSettingsType type) { | 73 std::string ContentSettingsTypeToGroupName(ContentSettingsType type) { |
| 72 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) { | 74 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) { |
| 73 if (type == kContentSettingsTypeGroupNames[i].type) | 75 if (type == kContentSettingsTypeGroupNames[i].type) |
| 74 return kContentSettingsTypeGroupNames[i].name; | 76 return kContentSettingsTypeGroupNames[i].name; |
| 75 } | 77 } |
| 76 | 78 |
| 77 NOTREACHED() << type << " is not a recognized content settings type."; | 79 NOTREACHED() << type << " is not a recognized content settings type."; |
| 78 return std::string(); | 80 return std::string(); |
| 79 } | 81 } |
| 80 | 82 |
| 83 // Add an "Allow"-entry to the list of |exceptions| for a |url_pattern| from | |
| 84 // the web extent of a hosted |app|. | |
| 85 void AddExceptionForHostedApp(const std::string& url_pattern, | |
| 86 const extensions::Extension& app, base::ListValue* exceptions) { | |
| 87 std::unique_ptr<base::DictionaryValue> exception(new base::DictionaryValue()); | |
| 88 | |
| 89 std::string setting_string = | |
| 90 content_settings::ContentSettingToString(CONTENT_SETTING_ALLOW); | |
| 91 DCHECK(!setting_string.empty()); | |
| 92 | |
| 93 exception->SetString(site_settings::kSetting, setting_string); | |
| 94 exception->SetString(site_settings::kOrigin, url_pattern); | |
| 95 exception->SetString(site_settings::kEmbeddingOrigin, url_pattern); | |
| 96 exception->SetString(site_settings::kSource, "HostedApp"); | |
| 97 exception->SetBoolean(site_settings::kIncognito, false); | |
|
Finnur
2016/09/20 15:46:13
The changes in this file are purely code moving fr
| |
| 98 exception->SetString(kAppName, app.name()); | |
| 99 exception->SetString(kAppId, app.id()); | |
| 100 exceptions->Append(std::move(exception)); | |
| 101 } | |
| 102 | |
| 81 // Create a DictionaryValue* that will act as a data source for a single row | 103 // Create a DictionaryValue* that will act as a data source for a single row |
| 82 // in a HostContentSettingsMap-controlled exceptions table (e.g., cookies). | 104 // in a HostContentSettingsMap-controlled exceptions table (e.g., cookies). |
| 83 std::unique_ptr<base::DictionaryValue> GetExceptionForPage( | 105 std::unique_ptr<base::DictionaryValue> GetExceptionForPage( |
| 84 const ContentSettingsPattern& pattern, | 106 const ContentSettingsPattern& pattern, |
| 85 const ContentSettingsPattern& secondary_pattern, | 107 const ContentSettingsPattern& secondary_pattern, |
| 86 const ContentSetting& setting, | 108 const ContentSetting& setting, |
| 87 const std::string& provider_name, | 109 const std::string& provider_name, |
| 88 bool incognito) { | 110 bool incognito) { |
| 89 base::DictionaryValue* exception = new base::DictionaryValue(); | 111 base::DictionaryValue* exception = new base::DictionaryValue(); |
| 90 exception->SetString(kOrigin, pattern.ToString()); | 112 exception->SetString(kOrigin, pattern.ToString()); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 } | 384 } |
| 363 } | 385 } |
| 364 | 386 |
| 365 for (auto& one_provider_exceptions : all_provider_exceptions) { | 387 for (auto& one_provider_exceptions : all_provider_exceptions) { |
| 366 for (auto& exception : one_provider_exceptions) | 388 for (auto& exception : one_provider_exceptions) |
| 367 exceptions->Append(std::move(exception)); | 389 exceptions->Append(std::move(exception)); |
| 368 } | 390 } |
| 369 } | 391 } |
| 370 | 392 |
| 371 } // namespace site_settings | 393 } // namespace site_settings |
| OLD | NEW |