| 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/common/extensions/manifest_handlers/automation.h" | 5 #include "chrome/common/extensions/manifest_handlers/automation.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/common/extensions/api/manifest_types.h" | 8 #include "chrome/common/extensions/api/manifest_types.h" |
| 9 #include "chrome/grit/generated_resources.h" | 9 #include "chrome/grit/generated_resources.h" |
| 10 #include "extensions/common/error_utils.h" | 10 #include "extensions/common/error_utils.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 return GetMessages().size() > 0; | 78 return GetMessages().size() > 0; |
| 79 } | 79 } |
| 80 | 80 |
| 81 PermissionMessages AutomationManifestPermission::GetMessages() const { | 81 PermissionMessages AutomationManifestPermission::GetMessages() const { |
| 82 PermissionMessages messages; | 82 PermissionMessages messages; |
| 83 if (automation_info_->desktop) { | 83 if (automation_info_->desktop) { |
| 84 messages.push_back(PermissionMessage( | 84 messages.push_back(PermissionMessage( |
| 85 PermissionMessage::kFullAccess, | 85 PermissionMessage::kFullAccess, |
| 86 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS))); | 86 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS))); |
| 87 } else if (automation_info_->matches.MatchesAllURLs()) { | 87 } else if (automation_info_->matches.MatchesAllURLs()) { |
| 88 messages.push_back(PermissionMessage( | 88 if (automation_info_->interact) { |
| 89 PermissionMessage::kHostsAll, | 89 messages.push_back(PermissionMessage( |
| 90 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_ALL_HOSTS))); | 90 PermissionMessage::kHostsAll, |
| 91 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_ALL_HOSTS))); |
| 92 } else { |
| 93 messages.push_back(PermissionMessage( |
| 94 PermissionMessage::kHostsAllReadOnly, |
| 95 l10n_util::GetStringUTF16( |
| 96 IDS_EXTENSION_PROMPT_WARNING_ALL_HOSTS_READ_ONLY))); |
| 97 } |
| 91 } else { | 98 } else { |
| 92 URLPatternSet regular_hosts; | 99 URLPatternSet regular_hosts; |
| 93 std::set<PermissionMessage> message_set; | 100 std::set<PermissionMessage> message_set; |
| 94 ExtensionsClient::Get()->FilterHostPermissions( | 101 ExtensionsClient::Get()->FilterHostPermissions( |
| 95 automation_info_->matches, ®ular_hosts, &message_set); | 102 automation_info_->matches, ®ular_hosts, &message_set); |
| 96 messages.insert(messages.end(), message_set.begin(), message_set.end()); | 103 messages.insert(messages.end(), message_set.begin(), message_set.end()); |
| 97 | 104 |
| 98 std::set<std::string> hosts = | 105 std::set<std::string> hosts = |
| 99 permission_message_util::GetDistinctHosts(regular_hosts, true, true); | 106 permission_message_util::GetDistinctHosts(regular_hosts, true, true); |
| 100 if (!hosts.empty()) | 107 if (!hosts.empty()) { |
| 101 messages.push_back(permission_message_util::CreateFromHostList(hosts)); | 108 messages.push_back(permission_message_util::CreateFromHostList( |
| 109 hosts, |
| 110 automation_info_->interact ? permission_message_util::kReadWrite |
| 111 : permission_message_util::kReadOnly)); |
| 112 } |
| 102 } | 113 } |
| 103 | 114 |
| 104 return messages; | 115 return messages; |
| 105 } | 116 } |
| 106 | 117 |
| 107 bool AutomationManifestPermission::FromValue(const base::Value* value) { | 118 bool AutomationManifestPermission::FromValue(const base::Value* value) { |
| 108 base::string16 error; | 119 base::string16 error; |
| 109 automation_info_.reset(AutomationInfo::FromValue(*value, | 120 automation_info_.reset(AutomationInfo::FromValue(*value, |
| 110 NULL /* install_warnings */, | 121 NULL /* install_warnings */, |
| 111 &error).release()); | 122 &error).release()); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 AutomationInfo::AutomationInfo(bool desktop, | 323 AutomationInfo::AutomationInfo(bool desktop, |
| 313 const URLPatternSet matches, | 324 const URLPatternSet matches, |
| 314 bool interact) | 325 bool interact) |
| 315 : desktop(desktop), matches(matches), interact(interact) { | 326 : desktop(desktop), matches(matches), interact(interact) { |
| 316 } | 327 } |
| 317 | 328 |
| 318 AutomationInfo::~AutomationInfo() { | 329 AutomationInfo::~AutomationInfo() { |
| 319 } | 330 } |
| 320 | 331 |
| 321 } // namespace extensions | 332 } // namespace extensions |
| OLD | NEW |