Commit 64eba5b3 authored by dbeam's avatar dbeam Committed by Commit bot

MD Downloads: add a use_vulcanize option to Chrome

use_vulcanize is on by default. This means that release, official,
and debug builds that don't need debug versions of webui pages will
get the fastest experience.

To turn off vulcanization for local development, set

  use_vulcanize=0

in GYP, or

  use_vulcanize = false

in GN.

To conditionally include files in .grd files, do:

  <if expr="use_vulcanize">

and in C++:

  #include "chrome/common/features.h"
  #if BUILDFLAG(USE_VULCANIZE)

Currently, only the new Material Design downloads page is vulcanized,
but there will soon be others.

R=groby@chromium.org,thakis@chromium.org
BUG=541455
TEST=smaller binary

Review URL: https://codereview.chromium.org/1494253003

Cr-Commit-Position: refs/heads/master@{#367226}
parent 576475cb
......@@ -25,8 +25,14 @@
</if>
<if expr="not is_android">
<structure name="IDR_DOWNLOADS_DOWNLOADS_HTML" file="resources\downloads\downloads.html" flattenhtml="true" allowexternalscript="true" type="chrome_html" />
<structure name="IDR_MD_DOWNLOADS_DOWNLOADS_HTML" file="resources\md_downloads\downloads.html" flattenhtml="true" allowexternalscript="true" type="chrome_html" />
<if expr="use_vulcanize">
<then>
<structure name="IDR_MD_DOWNLOADS_VULCANIZED_HTML" file="resources\md_downloads\vulcanized.html" flattenhtml="true" allowexternalscript="true" type="chrome_html" />
</then>
<else>
<structure name="IDR_MD_DOWNLOADS_DOWNLOADS_HTML" file="resources\md_downloads\downloads.html" flattenhtml="true" allowexternalscript="true" type="chrome_html" />
</else>
</if>
</if>
<if expr="enable_extensions">
<structure name="IDR_EXTENSIONS_HTML" file="resources\extensions\extensions.html" flattenhtml="true" type="chrome_html" />
......@@ -124,11 +130,15 @@
<include name="IDR_MD_DOWNLOADS_2X_INCOGNITO_MARKER_PNG" file="resources\md_downloads\2x\incognito_marker.png" type="BINDATA" />
<include name="IDR_MD_DOWNLOADS_1X_NO_DOWNLOADS_PNG" file="resources\md_downloads\1x\no_downloads.png" type="BINDATA" />
<include name="IDR_MD_DOWNLOADS_2X_NO_DOWNLOADS_PNG" file="resources\md_downloads\2x\no_downloads.png" type="BINDATA" />
<if expr="use_vulcanize">
<then>
<include name="IDR_MD_DOWNLOADS_CRISPER_JS" file="resources\md_downloads\crisper.js" flattenhtml="true" type="BINDATA" />
</then>
<else>
<include name="IDR_MD_DOWNLOADS_ACTION_SERVICE_HTML" file="resources\md_downloads\action_service.html" type="BINDATA" />
<include name="IDR_MD_DOWNLOADS_ACTION_SERVICE_JS" file="resources\md_downloads\action_service.js" type="BINDATA" />
<include name="IDR_MD_DOWNLOADS_CONSTANTS_HTML" file="resources\md_downloads\constants.html" type="BINDATA" />
<include name="IDR_MD_DOWNLOADS_CONSTANTS_JS" file="resources\md_downloads\constants.js" type="BINDATA" />
<include name="IDR_MD_DOWNLOADS_CRISPER_JS" file="resources\md_downloads\crisper.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_MD_DOWNLOADS_DOWNLOADS_JS" file="resources\md_downloads\downloads.js" type="BINDATA" />
<include name="IDR_MD_DOWNLOADS_I18N_SETUP_HTML" file="resources\md_downloads\i18n_setup.html" type="BINDATA" />
<include name="IDR_MD_DOWNLOADS_ITEM_CSS" file="resources\md_downloads\item.css" type="BINDATA" flattenhtml="true" />
......@@ -141,6 +151,8 @@
<include name="IDR_MD_DOWNLOADS_TOOLBAR_CSS" file="resources\md_downloads\toolbar.css" type="BINDATA" />
<include name="IDR_MD_DOWNLOADS_TOOLBAR_HTML" file="resources\md_downloads\toolbar.html" type="BINDATA" />
<include name="IDR_MD_DOWNLOADS_TOOLBAR_JS" file="resources\md_downloads\toolbar.js" type="BINDATA" />
</else>
</if>
</if>
<if expr="enable_extensions">
<include name="IDR_EXTENSION_COMMAND_LIST_JS" file="resources\extensions\extension_command_list.js" flattenhtml="true" type="BINDATA" />
......
......@@ -142,6 +142,7 @@ source_set("ui") {
".",
"//chrome")
deps += [
"//chrome/common:features",
"//components/copresence",
"//components/feedback/proto",
"//components/proximity_auth/webui",
......
......@@ -17,6 +17,7 @@
#include "chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.h"
#include "chrome/browser/ui/webui/theme_source.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/features.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
......@@ -102,14 +103,17 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
IDR_MD_DOWNLOADS_1X_NO_DOWNLOADS_PNG);
source->AddResourcePath("2x/no_downloads.png",
IDR_MD_DOWNLOADS_2X_NO_DOWNLOADS_PNG);
#if BUILDFLAG(USE_VULCANIZE)
source->AddResourcePath("crisper.js", IDR_MD_DOWNLOADS_CRISPER_JS);
source->SetDefaultResource(IDR_MD_DOWNLOADS_VULCANIZED_HTML);
#else
source->AddResourcePath("action_service.html",
IDR_MD_DOWNLOADS_ACTION_SERVICE_HTML);
source->AddResourcePath("action_service.js",
IDR_MD_DOWNLOADS_ACTION_SERVICE_JS);
source->AddResourcePath("constants.html", IDR_MD_DOWNLOADS_CONSTANTS_HTML);
source->AddResourcePath("constants.js", IDR_MD_DOWNLOADS_CONSTANTS_JS);
source->AddResourcePath("crisper.js", IDR_MD_DOWNLOADS_CRISPER_JS);
source->AddResourcePath("dev.html", IDR_MD_DOWNLOADS_DOWNLOADS_HTML);
source->AddResourcePath("downloads.js", IDR_MD_DOWNLOADS_DOWNLOADS_JS);
source->AddResourcePath("i18n_setup.html", IDR_MD_DOWNLOADS_I18N_SETUP_HTML);
source->AddResourcePath("item.css", IDR_MD_DOWNLOADS_ITEM_CSS);
......@@ -123,8 +127,9 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
source->AddResourcePath("toolbar.css", IDR_MD_DOWNLOADS_TOOLBAR_CSS);
source->AddResourcePath("toolbar.html", IDR_MD_DOWNLOADS_TOOLBAR_HTML);
source->AddResourcePath("toolbar.js", IDR_MD_DOWNLOADS_TOOLBAR_JS);
source->SetDefaultResource(IDR_MD_DOWNLOADS_DOWNLOADS_HTML);
#endif
source->SetDefaultResource(IDR_MD_DOWNLOADS_VULCANIZED_HTML);
source->SetJsonPath("strings.js");
return source;
......
......@@ -3327,6 +3327,7 @@
'../components/components.gyp:feedback_proto',
'../device/bluetooth/bluetooth.gyp:device_bluetooth',
'../third_party/libusb/libusb.gyp:libusb',
'chrome_features.gyp:chrome_common_features',
],
'sources': [
'<@(chrome_browser_ui_non_mobile_sources)',
......
......@@ -16,6 +16,7 @@
'buildflag_flags': [
'ENABLE_GOOGLE_NOW=<(enable_google_now)',
'ANDROID_JAVA_UI=<(android_java_ui)',
'USE_VULCANIZE=<(use_vulcanize)',
],
},
},
......
......@@ -21,17 +21,23 @@
'enable_google_now%': 1,
}]
],
# Use vulcanized HTML/CSS/JS resources to speed up WebUI (chrome://)
# pages. https://github.com/polymer/vulcanize
'use_vulcanize%': 1,
},
# Anything in the conditions needs to be copied to the outer scope to be
# accessible.
'enable_google_now%': '<(enable_google_now)',
'android_java_ui%': '<(android_java_ui)',
'use_vulcanize%': '<(use_vulcanize)',
# Grit defines based on the feature flags. These must be manually added to
# grit targets.
'chrome_grit_defines': [
'-D', 'enable_google_now=<(enable_google_now)',
'-D', 'use_vulcanize=<(use_vulcanize)',
]
},
}
......@@ -203,6 +203,11 @@
'variables': {
'grit_grd_file': 'browser/browser_resources.grd',
'grit_additional_defines': [
# TODO(dbeam): 'chrome_grit_defines' should just be appended to
# this list of 'grit_additional_defines' via the top of this file,
# but they're not for some reason. Maybe because they're in
# different scopes?
'<@(chrome_grit_defines)',
'-E', 'additional_modules_list_file=<(additional_modules_list_file)',
'-E', 'root_gen_dir=<(SHARED_INTERMEDIATE_DIR)',
],
......
......@@ -43,6 +43,7 @@ buildflag_header("features") {
flags = [
"ENABLE_GOOGLE_NOW=$enable_google_now",
"ANDROID_JAVA_UI=$android_java_ui",
"USE_VULCANIZE=$use_vulcanize",
]
}
......
......@@ -13,6 +13,13 @@ declare_args() {
# Default to true if compiling for android, but allow this being overriden
# through the environment.
android_java_ui = is_android
# Use vulcanized HTML/CSS/JS resources to speed up WebUI (chrome://)
# pages. https://github.com/polymer/vulcanize
use_vulcanize = true
}
chrome_grit_defines = [ "enable_google_now=$enable_google_now" ]
chrome_grit_defines = [
"enable_google_now=$enable_google_now",
"use_vulcanize=$use_vulcanize",
]
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