Commit 2a565a3b authored by dpapad's avatar dpapad Committed by Chromium LUCI CQ

Serve chrome://apps from a regular WebUIDataSource.

Previously because of the long history of this page (which at some
point served as the NTP, aka NTP4) it was served by a custom class
which delegated logic to NTPResourceCache. There is no good reason to
use the NTPResourceCache for chrome://apps anymore, AFAIK.

Using a WebUIDataSource makes a lot of things simpler, like registering
resources, localized strings, load time data, and many more.

This is in preparation of possibly migrating chrome://apps to JS modules
(TBD). Regardless, moving away from NTPResourceCache is a positive step.

Bug: 1168053
Change-Id: If82d634c8d7e699dc1c906517c23c40bfaa0b6b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2629855Reviewed-by: default avatarEsmael Elmoslimany <aee@chromium.org>
Commit-Queue: dpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846035}
parent 90f41215
......@@ -16,6 +16,8 @@
<link id="themecss" rel="stylesheet">
<script src="../../../../ui/webui/resources/js/assert.js"></script>
<script src="../../../../ui/webui/resources/js/util.js"></script>
<script src="../../../../ui/webui/resources/js/load_time_data.js"></script>
<script src="chrome://apps/strings.js"></script>
<script>
// Until themes can clear the cache, force-reload the theme stylesheet.
$('themecss').href = 'chrome://theme/css/new_tab_theme.css?' + Date.now();
......
......@@ -7,32 +7,47 @@
#include <memory>
#include <string>
#include "base/memory/ref_counted_memory.h"
#include "base/metrics/histogram_macros.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/apps/app_info_dialog.h"
#include "chrome/browser/ui/webui/app_launcher_login_handler.h"
#include "chrome/browser/ui/webui/metrics_handler.h"
#include "chrome/browser/ui/webui/ntp/app_icon_webui_handler.h"
#include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
#include "chrome/browser/ui/webui/ntp/app_resource_cache_factory.h"
#include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h"
#include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h"
#include "chrome/browser/ui/webui/theme_handler.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "components/bookmarks/common/bookmark_pref_names.h"
#include "components/google/core/common/google_util.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension_urls.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/webui/web_ui_util.h"
#include "ui/gfx/animation/animation.h"
using content::BrowserThread;
#if defined(OS_MAC)
#include "chrome/browser/platform_util.h"
#endif
///////////////////////////////////////////////////////////////////////////////
// AppLauncherPageUI
......@@ -61,14 +76,120 @@ AppLauncherPageUI::AppLauncherPageUI(content::WebUI* web_ui)
// earlier.
web_ui->AddMessageHandler(std::make_unique<ThemeHandler>());
content::URLDataSource::Add(
/*content::URLDataSource::Add(
GetProfile(),
std::make_unique<HTMLSource>(GetProfile()->GetOriginalProfile()));
std::make_unique<HTMLSource>(GetProfile()->GetOriginalProfile()));*/
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIAppLauncherPageHost);
content::WebUIDataSource::Add(GetProfile(), source);
source->SetDefaultResource(IDR_NEW_TAB_4_HTML);
source->UseStringsJs();
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"title", IDS_NEW_TAB_TITLE},
{"webStoreTitle", IDS_EXTENSION_WEB_STORE_TITLE},
{"webStoreTitleShort", IDS_EXTENSION_WEB_STORE_TITLE_SHORT},
{"attributionintro", IDS_NEW_TAB_ATTRIBUTION_INTRO},
{"appuninstall", IDS_EXTENSIONS_UNINSTALL},
{"appoptions", IDS_NEW_TAB_APP_OPTIONS},
{"appdetails", IDS_NEW_TAB_APP_DETAILS},
{"appinfodialog", IDS_APP_CONTEXT_MENU_SHOW_INFO},
{"appcreateshortcut", IDS_NEW_TAB_APP_CREATE_SHORTCUT},
{"appinstalllocally", IDS_NEW_TAB_APP_INSTALL_LOCALLY},
{"appDefaultPageName", IDS_APP_DEFAULT_PAGE_NAME},
{"applaunchtypepinned", IDS_APP_CONTEXT_MENU_OPEN_PINNED},
{"applaunchtyperegular", IDS_APP_CONTEXT_MENU_OPEN_REGULAR},
{"applaunchtypewindow", IDS_APP_CONTEXT_MENU_OPEN_WINDOW},
{"applaunchtypefullscreen", IDS_APP_CONTEXT_MENU_OPEN_FULLSCREEN},
{"syncpromotext", IDS_SYNC_START_SYNC_BUTTON_LABEL},
{"syncLinkText", IDS_SYNC_ADVANCED_OPTIONS},
{"learnMore", IDS_LEARN_MORE},
{"appInstallHintText", IDS_NEW_TAB_APP_INSTALL_HINT_LABEL},
{"learn_more", IDS_LEARN_MORE},
{"tile_grid_screenreader_accessible_description",
IDS_NEW_TAB_TILE_GRID_ACCESSIBLE_DESCRIPTION},
{"page_switcher_change_title", IDS_NEW_TAB_PAGE_SWITCHER_CHANGE_TITLE},
{"page_switcher_same_title", IDS_NEW_TAB_PAGE_SWITCHER_SAME_TITLE},
{"runonoslogin", IDS_APP_CONTEXT_MENU_RUN_ON_OS_LOGIN},
};
AddLocalizedStringsBulk(source, kLocalizedStrings);
PrefService* prefs = GetProfile()->GetPrefs();
source->AddString(
"bookmarkbarattached",
prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar) ? "true" : "false");
source->AddBoolean("shouldShowSyncLogin",
AppLauncherLoginHandler::ShouldShow(GetProfile()));
const std::string& app_locale = g_browser_process->GetApplicationLocale();
source->AddString("webStoreLink",
google_util::AppendGoogleLocaleParam(
extension_urls::GetWebstoreLaunchURL(), app_locale)
.spec());
bool is_swipe_tracking_from_scroll_events_enabled = false;
#if defined(OS_MAC)
// On Mac OS X 10.7+, horizontal scrolling can be treated as a back or
// forward gesture. Pass through a flag that indicates whether or not that
// feature is enabled.
is_swipe_tracking_from_scroll_events_enabled =
platform_util::IsSwipeTrackingFromScrollEventsEnabled();
#endif
source->AddBoolean("isSwipeTrackingFromScrollEventsEnabled",
is_swipe_tracking_from_scroll_events_enabled);
source->AddBoolean("showWebStoreIcon",
!prefs->GetBoolean(prefs::kHideWebStoreIcon));
pref_change_registrar_.Init(prefs);
pref_change_registrar_.Add(
prefs::kHideWebStoreIcon,
base::BindRepeating(&AppLauncherPageUI::OnHideWebStoreIconChanged,
base::Unretained(this)));
source->AddBoolean("canShowAppInfoDialog", CanPlatformShowAppInfoDialog());
AppLauncherHandler::RegisterLoadTimeData(GetProfile(), source);
// Control fade and resize animations.
source->AddBoolean("anim", gfx::Animation::ShouldRenderRichAnimation());
source->AddBoolean(
"isUserSignedIn",
IdentityManagerFactory::GetForProfile(GetProfile())->HasPrimaryAccount());
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ScriptSrc,
"script-src chrome://resources 'self' 'unsafe-eval' "
"'unsafe-inline';");
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::StyleSrc,
"style-src 'self' chrome://resources chrome://theme "
"'unsafe-inline';");
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ImgSrc,
"img-src chrome://extension-icon chrome://app-icon chrome://theme "
"chrome://resources data:;");
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::TrustedTypes,
"trusted-types apps-page-js cr-ui-bubble-js-static "
"parse-html-subset;");
}
AppLauncherPageUI::~AppLauncherPageUI() {
}
void AppLauncherPageUI::OnHideWebStoreIconChanged() {
std::unique_ptr<base::DictionaryValue> update(new base::DictionaryValue);
PrefService* prefs = GetProfile()->GetPrefs();
update->SetBoolean("showWebStoreIcon",
!prefs->GetBoolean(prefs::kHideWebStoreIcon));
content::WebUIDataSource::Update(
GetProfile(), chrome::kChromeUIAppLauncherPageHost, std::move(update));
}
// static
base::RefCountedMemory* AppLauncherPageUI::GetFaviconResourceBytes(
ui::ScaleFactor scale_factor) {
......@@ -92,70 +213,3 @@ bool AppLauncherPageUI::OverrideHandleWebUIMessage(
Profile* AppLauncherPageUI::GetProfile() const {
return Profile::FromWebUI(web_ui());
}
///////////////////////////////////////////////////////////////////////////////
// HTMLSource
AppLauncherPageUI::HTMLSource::HTMLSource(Profile* profile)
: profile_(profile) {
}
std::string AppLauncherPageUI::HTMLSource::GetSource() {
return chrome::kChromeUIAppLauncherPageHost;
}
void AppLauncherPageUI::HTMLSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
content::URLDataSource::GotDataCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
NTPResourceCache* resource = AppResourceCacheFactory::GetForProfile(profile_);
content::WebContents* web_contents = wc_getter.Run();
content::RenderProcessHost* render_host =
web_contents ? web_contents->GetMainFrame()->GetProcess() : nullptr;
NTPResourceCache::WindowType win_type = NTPResourceCache::GetWindowType(
profile_, render_host);
scoped_refptr<base::RefCountedMemory> html_bytes(
resource->GetNewTabHTML(win_type));
std::move(callback).Run(html_bytes.get());
}
std::string AppLauncherPageUI::HTMLSource::GetMimeType(
const std::string& resource) {
return "text/html";
}
bool AppLauncherPageUI::HTMLSource::ShouldReplaceExistingSource() {
return false;
}
bool AppLauncherPageUI::HTMLSource::AllowCaching() {
// Should not be cached to reflect dynamically-generated contents that may
// depend on user profiles.
return false;
}
std::string AppLauncherPageUI::HTMLSource::GetContentSecurityPolicy(
network::mojom::CSPDirectiveName directive) {
if (directive == network::mojom::CSPDirectiveName::ScriptSrc) {
// 'unsafe-inline' is added to script-src.
return "script-src chrome://resources 'self' 'unsafe-eval' "
"'unsafe-inline';";
} else if (directive == network::mojom::CSPDirectiveName::StyleSrc) {
return "style-src 'self' chrome://resources chrome://theme "
"'unsafe-inline';";
} else if (directive == network::mojom::CSPDirectiveName::ImgSrc) {
return "img-src chrome://extension-icon chrome://app-icon chrome://theme "
"chrome://resources data:;";
} else if (directive == network::mojom::CSPDirectiveName::TrustedTypes) {
return "trusted-types apps-page-js cr-ui-bubble-js-static "
"parse-html-subset;";
}
return content::URLDataSource::GetContentSecurityPolicy(directive);
}
AppLauncherPageUI::HTMLSource::~HTMLSource() = default;
......@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_APP_LAUNCHER_PAGE_UI_H_
#include "base/macros.h"
#include "content/public/browser/url_data_source.h"
#include "components/prefs/pref_change_registrar.h"
#include "content/public/browser/web_ui_controller.h"
#include "ui/base/layout.h"
......@@ -31,32 +31,10 @@ class AppLauncherPageUI : public content::WebUIController {
const base::ListValue& args) override;
private:
class HTMLSource : public content::URLDataSource {
public:
explicit HTMLSource(Profile* profile);
~HTMLSource() override;
// content::URLDataSource implementation.
std::string GetSource() override;
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
content::URLDataSource::GotDataCallback callback) override;
std::string GetMimeType(const std::string&) override;
bool ShouldReplaceExistingSource() override;
bool AllowCaching() override;
std::string GetContentSecurityPolicy(
network::mojom::CSPDirectiveName directive) override;
private:
// Pointer back to the original profile.
Profile* profile_;
DISALLOW_COPY_AND_ASSIGN(HTMLSource);
};
void OnHideWebStoreIconChanged();
Profile* GetProfile() const;
PrefChangeRegistrar pref_change_registrar_;
DISALLOW_COPY_AND_ASSIGN(AppLauncherPageUI);
};
......
......@@ -404,11 +404,12 @@ void AppLauncherHandler::CreateExtensionInfo(const Extension* extension,
}
// static
void AppLauncherHandler::GetLocalizedValues(Profile* profile,
base::DictionaryValue* values) {
void AppLauncherHandler::RegisterLoadTimeData(
Profile* profile,
content::WebUIDataSource* source) {
PrefService* prefs = profile->GetPrefs();
int shown_page = prefs->GetInteger(prefs::kNtpShownPage);
values->SetInteger("shown_page_index", shown_page & INDEX_MASK);
source->AddInteger("shown_page_index", shown_page & INDEX_MASK);
}
// static
......
......@@ -25,6 +25,7 @@
#include "components/sync/model/string_ordinal.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/browser/web_ui_message_handler.h"
#include "extensions/browser/extension_registry_observer.h"
#include "extensions/common/extension.h"
......@@ -69,8 +70,8 @@ class AppLauncherHandler
base::DictionaryValue* value);
// Registers values (strings etc.) for the page.
static void GetLocalizedValues(Profile* profile,
base::DictionaryValue* values);
static void RegisterLoadTimeData(Profile* profile,
content::WebUIDataSource* source);
// Register per-profile preferences.
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
......
......@@ -21,12 +21,10 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/signin_util.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/apps/app_info_dialog.h"
#include "chrome/browser/ui/cookie_controls/cookie_controls_service.h"
#include "chrome/browser/ui/cookie_controls/cookie_controls_service_factory.h"
#include "chrome/browser/ui/layout_constants.h"
......@@ -43,16 +41,13 @@
#include "components/bookmarks/common/bookmark_pref_names.h"
#include "components/content_settings/core/common/cookie_controls_enforcement.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/google/core/common/google_util.h"
#include "components/policy/core/common/policy_service.h"
#include "components/policy/policy_constants.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_process_host.h"
#include "extensions/common/extension_urls.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/template_expressions.h"
......@@ -60,7 +55,6 @@
#include "ui/base/webui/jstemplate_builder.h"
#include "ui/base/webui/web_ui_util.h"
#include "ui/chromeos/devicetype_utils.h"
#include "ui/gfx/animation/animation.h"
#include "ui/gfx/color_utils.h"
#include "ui/native_theme/native_theme.h"
......@@ -69,10 +63,6 @@
#include "chromeos/strings/grit/chromeos_strings.h"
#endif
#if defined(OS_MAC)
#include "chrome/browser/platform_util.h"
#endif
using content::BrowserThread;
namespace {
......@@ -175,7 +165,6 @@ NTPResourceCache::NTPResourceCache(Profile* profile)
profile_pref_change_registrar_.Add(bookmarks::prefs::kShowBookmarkBar,
callback);
profile_pref_change_registrar_.Add(prefs::kNtpShownPage, callback);
profile_pref_change_registrar_.Add(prefs::kHideWebStoreIcon, callback);
profile_pref_change_registrar_.Add(prefs::kCookieControlsMode, callback);
theme_observation_.Observe(ui::NativeTheme::GetInstanceForNativeUi());
......@@ -191,18 +180,6 @@ NTPResourceCache::NTPResourceCache(Profile* profile)
NTPResourceCache::~NTPResourceCache() = default;
bool NTPResourceCache::NewTabHTMLNeedsRefresh() {
#if defined(OS_MAC)
// Invalidate if the current value is different from the cached value.
bool is_enabled = platform_util::IsSwipeTrackingFromScrollEventsEnabled();
if (is_enabled != is_swipe_tracking_from_scroll_events_enabled_) {
is_swipe_tracking_from_scroll_events_enabled_ = is_enabled;
return true;
}
#endif
return false;
}
NTPResourceCache::WindowType NTPResourceCache::GetWindowType(
Profile* profile, content::RenderProcessHost* render_host) {
if (profile->IsGuestSession() || profile->IsEphemeralGuestProfile()) {
......@@ -240,18 +217,10 @@ base::RefCountedMemory* NTPResourceCache::GetNewTabHTML(WindowType win_type) {
return GetNewTabGuestHTML();
}
if (win_type == INCOGNITO) {
DCHECK(win_type == INCOGNITO);
if (!new_tab_incognito_html_)
CreateNewTabIncognitoHTML();
return new_tab_incognito_html_.get();
}
// Refresh the cached HTML if necessary.
// NOTE: NewTabHTMLNeedsRefresh() must be called every time the new tab
// HTML is fetched, because it needs to initialize cached values.
if (NewTabHTMLNeedsRefresh() || !new_tab_html_)
CreateNewTabHTML();
return new_tab_html_.get();
}
base::RefCountedMemory* NTPResourceCache::GetNewTabCSS(WindowType win_type) {
......@@ -483,125 +452,6 @@ scoped_refptr<base::RefCountedString> NTPResourceCache::CreateNewTabGuestHTML(
return base::RefCountedString::TakeString(&full_html);
}
// TODO(alancutter): Consider moving this utility function up somewhere where it
// can be shared with bookmarks_ui.cc.
// Ampersands are used by menus to determine which characters to use as shortcut
// keys. This functionality is not implemented for NTP.
static base::string16 GetLocalizedString(int message_id) {
base::string16 result = l10n_util::GetStringUTF16(message_id);
base::Erase(result, '&');
return result;
}
void NTPResourceCache::CreateNewTabHTML() {
// TODO(estade): these strings should be defined in their relevant handlers
// (in GetLocalizedValues) and should have more legible names.
// Show the profile name in the title and most visited labels if the current
// profile is not the default.
PrefService* prefs = profile_->GetPrefs();
base::DictionaryValue load_time_data;
load_time_data.SetString(
"bookmarkbarattached",
prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar) ? "true" : "false");
load_time_data.SetString("title", GetLocalizedString(IDS_NEW_TAB_TITLE));
load_time_data.SetString("webStoreTitle",
GetLocalizedString(IDS_EXTENSION_WEB_STORE_TITLE));
load_time_data.SetString(
"webStoreTitleShort",
GetLocalizedString(IDS_EXTENSION_WEB_STORE_TITLE_SHORT));
load_time_data.SetString("attributionintro",
GetLocalizedString(IDS_NEW_TAB_ATTRIBUTION_INTRO));
load_time_data.SetString("appuninstall",
GetLocalizedString(IDS_EXTENSIONS_UNINSTALL));
load_time_data.SetString("appoptions",
GetLocalizedString(IDS_NEW_TAB_APP_OPTIONS));
load_time_data.SetString("appdetails",
GetLocalizedString(IDS_NEW_TAB_APP_DETAILS));
load_time_data.SetString("appinfodialog",
GetLocalizedString(IDS_APP_CONTEXT_MENU_SHOW_INFO));
load_time_data.SetString("appcreateshortcut",
GetLocalizedString(IDS_NEW_TAB_APP_CREATE_SHORTCUT));
load_time_data.SetString("appinstalllocally",
GetLocalizedString(IDS_NEW_TAB_APP_INSTALL_LOCALLY));
load_time_data.SetString("appDefaultPageName",
GetLocalizedString(IDS_APP_DEFAULT_PAGE_NAME));
load_time_data.SetString(
"applaunchtypepinned",
GetLocalizedString(IDS_APP_CONTEXT_MENU_OPEN_PINNED));
load_time_data.SetString(
"applaunchtyperegular",
GetLocalizedString(IDS_APP_CONTEXT_MENU_OPEN_REGULAR));
load_time_data.SetString(
"applaunchtypewindow",
GetLocalizedString(IDS_APP_CONTEXT_MENU_OPEN_WINDOW));
load_time_data.SetString(
"applaunchtypefullscreen",
GetLocalizedString(IDS_APP_CONTEXT_MENU_OPEN_FULLSCREEN));
load_time_data.SetString(
"syncpromotext", GetLocalizedString(IDS_SYNC_START_SYNC_BUTTON_LABEL));
load_time_data.SetString("syncLinkText",
GetLocalizedString(IDS_SYNC_ADVANCED_OPTIONS));
load_time_data.SetBoolean("shouldShowSyncLogin",
AppLauncherLoginHandler::ShouldShow(profile_));
load_time_data.SetString("learnMore", GetLocalizedString(IDS_LEARN_MORE));
const std::string& app_locale = g_browser_process->GetApplicationLocale();
load_time_data.SetString(
"webStoreLink", google_util::AppendGoogleLocaleParam(
extension_urls::GetWebstoreLaunchURL(), app_locale)
.spec());
load_time_data.SetString(
"appInstallHintText",
GetLocalizedString(IDS_NEW_TAB_APP_INSTALL_HINT_LABEL));
load_time_data.SetString("learn_more", GetLocalizedString(IDS_LEARN_MORE));
load_time_data.SetString(
"tile_grid_screenreader_accessible_description",
GetLocalizedString(IDS_NEW_TAB_TILE_GRID_ACCESSIBLE_DESCRIPTION));
load_time_data.SetString(
"page_switcher_change_title",
GetLocalizedString(IDS_NEW_TAB_PAGE_SWITCHER_CHANGE_TITLE));
load_time_data.SetString(
"page_switcher_same_title",
GetLocalizedString(IDS_NEW_TAB_PAGE_SWITCHER_SAME_TITLE));
load_time_data.SetString(
"runonoslogin", GetLocalizedString(IDS_APP_CONTEXT_MENU_RUN_ON_OS_LOGIN));
// On Mac OS X 10.7+, horizontal scrolling can be treated as a back or
// forward gesture. Pass through a flag that indicates whether or not that
// feature is enabled.
load_time_data.SetBoolean("isSwipeTrackingFromScrollEventsEnabled",
is_swipe_tracking_from_scroll_events_enabled_);
load_time_data.SetBoolean("showWebStoreIcon",
!prefs->GetBoolean(prefs::kHideWebStoreIcon));
load_time_data.SetBoolean("canShowAppInfoDialog",
CanPlatformShowAppInfoDialog());
AppLauncherHandler::GetLocalizedValues(profile_, &load_time_data);
webui::SetLoadTimeDataDefaults(app_locale, &load_time_data);
// Control fade and resize animations.
load_time_data.SetBoolean("anim",
gfx::Animation::ShouldRenderRichAnimation());
load_time_data.SetBoolean(
"isUserSignedIn",
IdentityManagerFactory::GetForProfile(profile_)->HasPrimaryAccount());
// Load the new tab page template and localize it.
static const base::NoDestructor<scoped_refptr<base::RefCountedMemory>>
new_tab_html(
ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
IDR_NEW_TAB_4_HTML));
CHECK(*new_tab_html);
std::string full_html = webui::GetI18nTemplateHtml(
base::StringPiece(reinterpret_cast<const char*>((*new_tab_html)->front()),
(*new_tab_html)->size()),
&load_time_data);
new_tab_html_ = base::RefCountedString::TakeString(&full_html);
}
void NTPResourceCache::CreateNewTabIncognitoCSS() {
// Same theme is used by all off-the-record profiles, so just getting it from
// the first one.
......
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