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

Side by Side Diff: chrome/common/extensions/manifest_handlers/automation.cc

Issue 410023002: Show read-only messages for non-interact non-desktop Automation extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: re-rebase Created 6 years, 5 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
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/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
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, &regular_hosts, &message_set); 105 automation_info_->matches, &regular_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, !automation_info_->interact));
113 }
105 } 114 }
106 115
107 return messages; 116 return messages;
108 } 117 }
109 118
110 bool AutomationManifestPermission::FromValue(const base::Value* value) { 119 bool AutomationManifestPermission::FromValue(const base::Value* value) {
111 base::string16 error; 120 base::string16 error;
112 automation_info_.reset(AutomationInfo::FromValue(*value, 121 automation_info_.reset(AutomationInfo::FromValue(*value,
113 NULL /* install_warnings */, 122 NULL /* install_warnings */,
114 &error).release()); 123 &error).release());
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 AutomationInfo::AutomationInfo(bool desktop, 324 AutomationInfo::AutomationInfo(bool desktop,
316 const URLPatternSet matches, 325 const URLPatternSet matches,
317 bool interact) 326 bool interact)
318 : desktop(desktop), matches(matches), interact(interact) { 327 : desktop(desktop), matches(matches), interact(interact) {
319 } 328 }
320 329
321 AutomationInfo::~AutomationInfo() { 330 AutomationInfo::~AutomationInfo() {
322 } 331 }
323 332
324 } // namespace extensions 333 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698