Commit 98ebb971 authored by Robert Sesek's avatar Robert Sesek Committed by Commit Bot

[Mac] Add a permission reason string for protected resource acceses.

In Mojave, apps should provide a reason string that will be shown in the
OS-mediated permission prompt for protected resources (e.g., camera,
microphone, location). This adds the reason string and places it in the
InfoPlist.strings files.

Bug: 850175
Change-Id: I1b5c250aa50a2b4086e95c34521a82fae2405ea1
Reviewed-on: https://chromium-review.googlesource.com/1135114Reviewed-by: default avatarLeonard Grey <lgrey@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574951}
parent 52eead94
...@@ -1100,6 +1100,12 @@ Please check your email at <ph name="ACCOUNT_EMAIL">$2<ex>jane.doe@example.com</ ...@@ -1100,6 +1100,12 @@ Please check your email at <ph name="ACCOUNT_EMAIL">$2<ex>jane.doe@example.com</
</message> </message>
</if> </if>
<if expr="is_macosx">
<message name="IDS_RUNTIME_PERMISSION_OS_REASON_TEXT" desc="Text provided to the macOS permission dialog, explaining why Chrome needs to access a protected resource (e.g., camera, microphone).">
Once Chromium has access, websites will be able to ask you for access.
</message>
</if>
<!-- OOM intervention message --> <!-- OOM intervention message -->
<if expr="is_android"> <if expr="is_android">
<message name="IDS_NEAR_OOM_INTERVENTION_MESSAGE" desc="The message stating that the browser intervened to stop the page using too much memory."> <message name="IDS_NEAR_OOM_INTERVENTION_MESSAGE" desc="The message stating that the browser intervened to stop the page using too much memory.">
......
...@@ -1118,6 +1118,12 @@ Please check your email at <ph name="ACCOUNT_EMAIL">$2<ex>jane.doe@example.com</ ...@@ -1118,6 +1118,12 @@ Please check your email at <ph name="ACCOUNT_EMAIL">$2<ex>jane.doe@example.com</
</message> </message>
</if> </if>
<if expr="is_macosx">
<message name="IDS_RUNTIME_PERMISSION_OS_REASON_TEXT" desc="Text provided to the macOS permission dialog, explaining why Chrome needs to access a protected resource (e.g., camera, microphone).">
Once Chrome has access, websites will be able to ask you for access.
</message>
</if>
<!-- OOM intervention message --> <!-- OOM intervention message -->
<if expr="is_android"> <if expr="is_android">
<message name="IDS_NEAR_OOM_INTERVENTION_MESSAGE" desc="The message stating that the browser intervened to stop the page using too much memory."> <message name="IDS_NEAR_OOM_INTERVENTION_MESSAGE" desc="The message stating that the browser intervened to stop the page using too much memory.">
......
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
#include "base/i18n/icu_util.h" #include "base/i18n/icu_util.h"
#include "base/i18n/message_formatter.h" #include "base/i18n/message_formatter.h"
#include "base/mac/scoped_nsautorelease_pool.h" #include "base/mac/scoped_nsautorelease_pool.h"
#include "base/mac/scoped_nsobject.h"
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/grit/chromium_strings.h" #include "chrome/grit/chromium_strings.h"
...@@ -245,7 +245,7 @@ int main(int argc, char* const argv[]) { ...@@ -245,7 +245,7 @@ int main(int argc, char* const argv[]) {
short_name_id_str = "IDS_SHORT_HELPER_NAME"; short_name_id_str = "IDS_SHORT_HELPER_NAME";
} }
// Fetch the strings // Fetch the strings.
NSString* name = NSString* name =
LoadStringFromDataPack(branded_data_pack.get(), cur_lang, LoadStringFromDataPack(branded_data_pack.get(), cur_lang,
name_id, name_id_str); name_id, name_id_str);
...@@ -261,22 +261,34 @@ int main(int argc, char* const argv[]) { ...@@ -261,22 +261,34 @@ int main(int argc, char* const argv[]) {
base::i18n::MessageFormatter::FormatWithNumberedArgs( base::i18n::MessageFormatter::FormatWithNumberedArgs(
base::SysNSStringToUTF16(copyright_format), base::Time::Now())); base::SysNSStringToUTF16(copyright_format), base::Time::Now()));
NSString* permission_reason =
LoadStringFromDataPack(branded_data_pack.get(), cur_lang,
IDS_RUNTIME_PERMISSION_OS_REASON_TEXT,
"IDS_RUNTIME_PERMISSION_OS_REASON_TEXT");
// For now, assume this is ok for all languages. If we need to, this could // For now, assume this is ok for all languages. If we need to, this could
// be moved into generated_resources.grd and fetched. // be moved into generated_resources.grd and fetched.
NSString *get_info = [NSString stringWithFormat:@"%@ %@, %@", NSString* get_info = [NSString
name, version_string, copyright]; stringWithFormat:@"%@ %@, %@", name, version_string, copyright];
// Generate the InfoPlist.strings file contents // Generate the InfoPlist.strings file contents.
NSString* strings_file_contents_string = NSDictionary<NSString*, NSString*>* infoplist_strings = @{
[NSString stringWithFormat: @"CFBundleDisplayName" : name,
@"CFBundleDisplayName = \"%@\";\n" @"CFBundleGetInfoString" : get_info,
@"CFBundleGetInfoString = \"%@\";\n" @"CFBundleName" : short_name,
@"CFBundleName = \"%@\";\n" @"NSHumanReadableCopyright" : copyright,
@"NSHumanReadableCopyright = \"%@\";\n", @"NSLocationUsageDescription" : permission_reason,
EscapeForStringsFileValue(name), @"NSMicrophoneUsageDescription" : permission_reason,
EscapeForStringsFileValue(get_info), @"NSCameraUsageDescription" : permission_reason,
EscapeForStringsFileValue(short_name), @"NSBluetoothPeripheralUsageDescription" : permission_reason,
EscapeForStringsFileValue(copyright)]; };
base::scoped_nsobject<NSMutableString> strings_file_contents_string(
[[NSMutableString alloc] init]);
for (NSString* key in infoplist_strings) {
[strings_file_contents_string
appendFormat:@"%@ = \"%@\";\n", key,
EscapeForStringsFileValue(infoplist_strings[key])];
}
// We set up Xcode projects expecting strings files to be UTF8, so make // We set up Xcode projects expecting strings files to be UTF8, so make
// sure we write the data in that form. When Xcode copies them it will // sure we write the data in that form. When Xcode copies them it will
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment