Commit e672e080 authored by Rachel Carpenter's avatar Rachel Carpenter Committed by Commit Bot

Translate the app name for Get Help.

To use SetManifestRequestFilter, need to move it to chromeos/components
to avoid circular dependencies. This affects os_settings that was also
using the function.

Also adds the strings that will be used for additional search queries.

Bug: b/149720483
Change-Id: Id1fe34dbb6a463963522bd256d0ccfa3366d1e05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2062116Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Commit-Queue: Rachel Carpenter <carpenterr@google.com>
Cr-Commit-Position: refs/heads/master@{#744414}
parent ca7c6fde
...@@ -24,5 +24,5 @@ class HelpAppIntegrationTest : public SystemWebAppIntegrationTest { ...@@ -24,5 +24,5 @@ class HelpAppIntegrationTest : public SystemWebAppIntegrationTest {
IN_PROC_BROWSER_TEST_F(HelpAppIntegrationTest, HelpAppV2) { IN_PROC_BROWSER_TEST_F(HelpAppIntegrationTest, HelpAppV2) {
const GURL url(chromeos::kChromeUIHelpAppURL); const GURL url(chromeos::kChromeUIHelpAppURL);
EXPECT_NO_FATAL_FAILURE( EXPECT_NO_FATAL_FAILURE(
ExpectSystemWebAppValid(web_app::SystemAppType::HELP, url, "Help App")); ExpectSystemWebAppValid(web_app::SystemAppType::HELP, url, "Discover"));
} }
...@@ -2053,6 +2053,7 @@ jumbo_static_library("ui") { ...@@ -2053,6 +2053,7 @@ jumbo_static_library("ui") {
"//chromeos/components/multidevice/logging", "//chromeos/components/multidevice/logging",
"//chromeos/components/proximity_auth", "//chromeos/components/proximity_auth",
"//chromeos/components/tether", "//chromeos/components/tether",
"//chromeos/components/web_applications",
"//chromeos/constants", "//chromeos/constants",
"//chromeos/cryptohome", "//chromeos/cryptohome",
"//chromeos/dbus", "//chromeos/dbus",
......
...@@ -11,11 +11,7 @@ ...@@ -11,11 +11,7 @@
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ref_counted_memory.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/strings/string16.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/apps/app_service/app_launch_params.h" #include "chrome/browser/apps/app_service/app_launch_params.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
...@@ -35,12 +31,7 @@ ...@@ -35,12 +31,7 @@
#include "chrome/browser/web_launch/web_launch_files_helper.h" #include "chrome/browser/web_launch/web_launch_files_helper.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h" #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui_data_source.h"
#include "third_party/blink/public/common/features.h" #include "third_party/blink/public/common/features.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/template_expressions.h"
#include "ui/base/window_open_disposition.h" #include "ui/base/window_open_disposition.h"
#include "ui/display/types/display_constants.h" #include "ui/display/types/display_constants.h"
...@@ -234,33 +225,4 @@ gfx::Size GetSystemWebAppMinimumWindowSize(Browser* browser) { ...@@ -234,33 +225,4 @@ gfx::Size GetSystemWebAppMinimumWindowSize(Browser* browser) {
app_controller->GetAppId()); app_controller->GetAppId());
} }
void SetManifestRequestFilter(content::WebUIDataSource* source,
int manifest_idr,
int name_ids) {
ui::TemplateReplacements replacements;
base::string16 name = l10n_util::GetStringUTF16(name_ids);
base::ReplaceChars(name, base::ASCIIToUTF16("\""), base::ASCIIToUTF16("\\\""),
&name);
replacements["name"] = base::UTF16ToUTF8(name);
scoped_refptr<base::RefCountedMemory> bytes =
ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
manifest_idr);
base::StringPiece content(reinterpret_cast<const char*>(bytes->front()),
bytes->size());
std::string response = ui::ReplaceTemplateExpressions(content, replacements);
source->SetRequestFilter(
base::BindRepeating(
[](const std::string& path) { return path == "manifest.json"; }),
base::BindRepeating(
[](const std::string& response, const std::string& path,
content::WebUIDataSource::GotDataCallback callback) {
std::string response_copy = response;
std::move(callback).Run(
base::RefCountedString::TakeString(&response_copy));
},
std::move(response)));
}
} // namespace web_app } // namespace web_app
...@@ -16,10 +16,6 @@ ...@@ -16,10 +16,6 @@
class Browser; class Browser;
class Profile; class Profile;
namespace content {
class WebUIDataSource;
}
namespace web_app { namespace web_app {
// Returns the system app type for the given App ID. // Returns the system app type for the given App ID.
...@@ -61,13 +57,6 @@ bool IsSystemWebApp(Browser* browser); ...@@ -61,13 +57,6 @@ bool IsSystemWebApp(Browser* browser);
// the app does not specify a minimum size. // the app does not specify a minimum size.
gfx::Size GetSystemWebAppMinimumWindowSize(Browser* browser); gfx::Size GetSystemWebAppMinimumWindowSize(Browser* browser);
// Calls |source->SetRequestFilter()| to set up respones to requests for
// "manifest.json" while replacing $i18nRaw{name} in the contents indiciated by
// |manifest_idr| with the name from |name_ids|.
void SetManifestRequestFilter(content::WebUIDataSource* source,
int manifest_idr,
int name_ids);
} // namespace web_app } // namespace web_app
#endif // CHROME_BROWSER_UI_WEB_APPLICATIONS_SYSTEM_WEB_APP_UI_UTILS_H_ #endif // CHROME_BROWSER_UI_WEB_APPLICATIONS_SYSTEM_WEB_APP_UI_UTILS_H_
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/ui_features.h" #include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/web_applications/system_web_app_ui_utils.h"
#include "chrome/browser/ui/webui/app_management/app_management.mojom.h" #include "chrome/browser/ui/webui/app_management/app_management.mojom.h"
#include "chrome/browser/ui/webui/app_management/app_management_page_handler.h" #include "chrome/browser/ui/webui/app_management/app_management_page_handler.h"
#include "chrome/browser/ui/webui/chromeos/smb_shares/smb_handler.h" #include "chrome/browser/ui/webui/chromeos/smb_shares/smb_handler.h"
...@@ -90,6 +89,7 @@ ...@@ -90,6 +89,7 @@
#include "chrome/grit/os_settings_resources_map.h" #include "chrome/grit/os_settings_resources_map.h"
#include "chromeos/components/account_manager/account_manager.h" #include "chromeos/components/account_manager/account_manager.h"
#include "chromeos/components/account_manager/account_manager_factory.h" #include "chromeos/components/account_manager/account_manager_factory.h"
#include "chromeos/components/web_applications/manifest_request_filter.h"
#include "chromeos/constants/chromeos_features.h" #include "chromeos/constants/chromeos_features.h"
#include "chromeos/constants/chromeos_pref_names.h" #include "chromeos/constants/chromeos_pref_names.h"
#include "chromeos/login/auth/password_visibility_utils.h" #include "chromeos/login/auth/password_visibility_utils.h"
......
...@@ -269,6 +269,17 @@ Try tapping the mic to ask me anything. ...@@ -269,6 +269,17 @@ Try tapping the mic to ask me anything.
<message name="IDS_IME_SERVICE_DISPLAY_NAME" desc="The display name (in the system task manager, etc) of the service process providing the input methods."> <message name="IDS_IME_SERVICE_DISPLAY_NAME" desc="The display name (in the system task manager, etc) of the service process providing the input methods.">
Chrome OS Input Method Service Chrome OS Input Method Service
</message> </message>
<!-- Help App -->
<message name="IDS_HELP_APP_DISCOVER" desc="Name of the discover app in the app shelf. This app is to help users 'discover' new content and ways to use their device.">
Discover
</message>
<message name="IDS_HELP_APP_OFFERS" desc="Name of a tab in the Help app that offers users discounts or freebies, 'offers'.">
Offers
</message>
<message name="IDS_HELP_APP_PERKS" desc="Name of a tab in the Help app that offers users additional perks like apps or drive storage space.">
Perks
</message>
</messages> </messages>
</release> </release>
</grit> </grit>
...@@ -24,9 +24,11 @@ static_library("help_app_ui") { ...@@ -24,9 +24,11 @@ static_library("help_app_ui") {
deps = [ deps = [
":mojo_bindings", ":mojo_bindings",
":mojo_bindings_js", ":mojo_bindings_js",
"//chromeos/components/web_applications",
"//chromeos/constants", "//chromeos/constants",
"//chromeos/resources:help_app_bundle_resources", "//chromeos/resources:help_app_bundle_resources",
"//chromeos/resources:help_app_resources", "//chromeos/resources:help_app_resources",
"//chromeos/strings",
"//chromeos/system", "//chromeos/system",
"//content/public/browser", "//content/public/browser",
"//content/public/common", "//content/public/common",
......
include_rules = [ include_rules = [
# Do not add chrome here (use a delegate instead). # Do not add chrome here (use a delegate instead).
"+chromeos/components/web_applications",
"+chromeos/grit/chromeos_help_app_resources.h", "+chromeos/grit/chromeos_help_app_resources.h",
"+chromeos/strings/grit/chromeos_strings.h",
"+content/public/browser", "+content/public/browser",
"+content/public/common", "+content/public/common",
"+ui/resources/grit/webui_resources.h", "+ui/resources/grit/webui_resources.h",
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
#include "chromeos/components/help_app_ui/help_app_page_handler.h" #include "chromeos/components/help_app_ui/help_app_page_handler.h"
#include "chromeos/components/help_app_ui/help_app_untrusted_ui.h" #include "chromeos/components/help_app_ui/help_app_untrusted_ui.h"
#include "chromeos/components/help_app_ui/url_constants.h" #include "chromeos/components/help_app_ui/url_constants.h"
#include "chromeos/components/web_applications/manifest_request_filter.h"
#include "chromeos/grit/chromeos_help_app_resources.h" #include "chromeos/grit/chromeos_help_app_resources.h"
#include "chromeos/strings/grit/chromeos_strings.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_data_source.h"
...@@ -25,12 +27,13 @@ content::WebUIDataSource* CreateHostDataSource() { ...@@ -25,12 +27,13 @@ content::WebUIDataSource* CreateHostDataSource() {
// actual app content. // actual app content.
source->SetDefaultResource(IDR_HELP_APP_HOST_INDEX_HTML); source->SetDefaultResource(IDR_HELP_APP_HOST_INDEX_HTML);
source->AddResourcePath("pwa.html", IDR_HELP_APP_PWA_HTML); source->AddResourcePath("pwa.html", IDR_HELP_APP_PWA_HTML);
source->AddResourcePath("manifest.json", IDR_HELP_APP_MANIFEST);
source->AddResourcePath("app_icon_192.png", IDR_HELP_APP_ICON_192); source->AddResourcePath("app_icon_192.png", IDR_HELP_APP_ICON_192);
source->AddResourcePath("app_icon_512.png", IDR_HELP_APP_ICON_512); source->AddResourcePath("app_icon_512.png", IDR_HELP_APP_ICON_512);
source->AddResourcePath("browser_proxy.js", IDR_HELP_APP_BROWSER_PROXY_JS); source->AddResourcePath("browser_proxy.js", IDR_HELP_APP_BROWSER_PROXY_JS);
source->AddResourcePath("help_app.mojom-lite.js", source->AddResourcePath("help_app.mojom-lite.js",
IDR_HELP_APP_HELP_APP_MOJOM_JS); IDR_HELP_APP_HELP_APP_MOJOM_JS);
web_app::SetManifestRequestFilter(source, IDR_HELP_APP_MANIFEST,
IDS_HELP_APP_DISCOVER);
return source; return source;
} }
} // namespace } // namespace
......
{ {
"name": "Help App", "name": "$i18nRaw{name}",
"short_name": "Help App", "short_name": "$i18nRaw{name}",
"start_url": "/", "start_url": "/",
"display": "standalone", "display": "standalone",
"theme_color": "#ffffff", "theme_color": "#ffffff",
......
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
assert(is_chromeos, "These utils are Chrome OS only")
static_library("web_applications") {
sources = [
"manifest_request_filter.cc",
"manifest_request_filter.h",
]
deps = [
"//base",
"//base:i18n",
"//content/public/browser",
"//ui/base",
]
}
include_rules = [
"+content/public/browser",
"+ui/base",
]
file://chrome/browser/web_applications/OWNERS
# COMPONENT: Platform>Apps>SystemWebApps
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/components/web_applications/manifest_request_filter.h"
#include <string>
#include "base/bind.h"
#include "base/memory/ref_counted_memory.h"
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "content/public/browser/web_ui_data_source.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/template_expressions.h"
namespace web_app {
void SetManifestRequestFilter(content::WebUIDataSource* source,
int manifest_idr,
int name_ids) {
ui::TemplateReplacements replacements;
base::string16 name = l10n_util::GetStringUTF16(name_ids);
base::ReplaceChars(name, base::ASCIIToUTF16("\""), base::ASCIIToUTF16("\\\""),
&name);
replacements["name"] = base::UTF16ToUTF8(name);
scoped_refptr<base::RefCountedMemory> bytes =
ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
manifest_idr);
base::StringPiece content(reinterpret_cast<const char*>(bytes->front()),
bytes->size());
std::string response = ui::ReplaceTemplateExpressions(content, replacements);
source->SetRequestFilter(
base::BindRepeating(
[](const std::string& path) { return path == "manifest.json"; }),
base::BindRepeating(
[](const std::string& response, const std::string& path,
content::WebUIDataSource::GotDataCallback callback) {
std::string response_copy = response;
std::move(callback).Run(
base::RefCountedString::TakeString(&response_copy));
},
std::move(response)));
}
} // namespace web_app
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_COMPONENTS_WEB_APPLICATIONS_MANIFEST_REQUEST_FILTER_H_
#define CHROMEOS_COMPONENTS_WEB_APPLICATIONS_MANIFEST_REQUEST_FILTER_H_
namespace content {
class WebUIDataSource;
}
namespace web_app {
// Calls |source->SetRequestFilter()| to set up respones to requests for
// "manifest.json" while replacing $i18nRaw{name} in the contents indicated by
// |manifest_idr| with the name from |name_ids|.
void SetManifestRequestFilter(content::WebUIDataSource* source,
int manifest_idr,
int name_ids);
} // namespace web_app
#endif // CHROMEOS_COMPONENTS_WEB_APPLICATIONS_MANIFEST_REQUEST_FILTER_H_
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