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