diff options
author | dbeam <dbeam@chromium.org> | 2015-12-30 20:06:03 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-31 04:07:14 +0000 |
commit | 64eba5b39620df70320fd0d23e4ba85022670203 (patch) | |
tree | ef88cae1a80b835b6f27185c9cbbff89f10ae109 | |
parent | 576475cb86867d2e9bff10c81d11913e957e266f (diff) | |
download | chromium_src-64eba5b39620df70320fd0d23e4ba85022670203.zip chromium_src-64eba5b39620df70320fd0d23e4ba85022670203.tar.gz chromium_src-64eba5b39620df70320fd0d23e4ba85022670203.tar.bz2 |
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}
-rw-r--r-- | chrome/browser/browser_resources.grd | 50 | ||||
-rw-r--r-- | chrome/browser/ui/BUILD.gn | 1 | ||||
-rw-r--r-- | chrome/browser/ui/webui/md_downloads/md_downloads_ui.cc | 11 | ||||
-rw-r--r-- | chrome/chrome_browser_ui.gypi | 1 | ||||
-rw-r--r-- | chrome/chrome_features.gyp | 1 | ||||
-rw-r--r-- | chrome/chrome_features.gypi | 6 | ||||
-rw-r--r-- | chrome/chrome_resources.gyp | 5 | ||||
-rw-r--r-- | chrome/common/BUILD.gn | 1 | ||||
-rw-r--r-- | chrome/common/features.gni | 9 |
9 files changed, 62 insertions, 23 deletions
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index af4faff..e8608f3 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd @@ -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" /> - <structure name="IDR_MD_DOWNLOADS_VULCANIZED_HTML" file="resources\md_downloads\vulcanized.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,23 +130,29 @@ <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" /> - <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" /> - <include name="IDR_MD_DOWNLOADS_ITEM_HTML" file="resources\md_downloads\item.html" type="BINDATA" /> - <include name="IDR_MD_DOWNLOADS_ITEM_JS" file="resources\md_downloads\item.js" type="BINDATA" /> - <include name="IDR_MD_DOWNLOADS_MANAGER_CSS" file="resources\md_downloads\manager.css" type="BINDATA" flattenhtml="true" /> - <include name="IDR_MD_DOWNLOADS_MANAGER_HTML" file="resources\md_downloads\manager.html" type="BINDATA" /> - <include name="IDR_MD_DOWNLOADS_MANAGER_JS" file="resources\md_downloads\manager.js" type="BINDATA" /> - <include name="IDR_MD_DOWNLOADS_SHARED_STYLE_CSS" file="resources\md_downloads\shared_style.css" type="BINDATA" /> - <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" /> + <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_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" /> + <include name="IDR_MD_DOWNLOADS_ITEM_HTML" file="resources\md_downloads\item.html" type="BINDATA" /> + <include name="IDR_MD_DOWNLOADS_ITEM_JS" file="resources\md_downloads\item.js" type="BINDATA" /> + <include name="IDR_MD_DOWNLOADS_MANAGER_CSS" file="resources\md_downloads\manager.css" type="BINDATA" flattenhtml="true" /> + <include name="IDR_MD_DOWNLOADS_MANAGER_HTML" file="resources\md_downloads\manager.html" type="BINDATA" /> + <include name="IDR_MD_DOWNLOADS_MANAGER_JS" file="resources\md_downloads\manager.js" type="BINDATA" /> + <include name="IDR_MD_DOWNLOADS_SHARED_STYLE_CSS" file="resources\md_downloads\shared_style.css" type="BINDATA" /> + <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" /> diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index 9c3f368..cff9a19 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn @@ -142,6 +142,7 @@ source_set("ui") { ".", "//chrome") deps += [ + "//chrome/common:features", "//components/copresence", "//components/feedback/proto", "//components/proximity_auth/webui", diff --git a/chrome/browser/ui/webui/md_downloads/md_downloads_ui.cc b/chrome/browser/ui/webui/md_downloads/md_downloads_ui.cc index 95d3a4e..733f9c5 100644 --- a/chrome/browser/ui/webui/md_downloads/md_downloads_ui.cc +++ b/chrome/browser/ui/webui/md_downloads/md_downloads_ui.cc @@ -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; diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index c6d1b2f..1bb44e1 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -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)', diff --git a/chrome/chrome_features.gyp b/chrome/chrome_features.gyp index 6ff5d76..deb1b98 100644 --- a/chrome/chrome_features.gyp +++ b/chrome/chrome_features.gyp @@ -16,6 +16,7 @@ 'buildflag_flags': [ 'ENABLE_GOOGLE_NOW=<(enable_google_now)', 'ANDROID_JAVA_UI=<(android_java_ui)', + 'USE_VULCANIZE=<(use_vulcanize)', ], }, }, diff --git a/chrome/chrome_features.gypi b/chrome/chrome_features.gypi index 06488b1..1042f41 100644 --- a/chrome/chrome_features.gypi +++ b/chrome/chrome_features.gypi @@ -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)', ] }, } diff --git a/chrome/chrome_resources.gyp b/chrome/chrome_resources.gyp index 6d15442..3036b08 100644 --- a/chrome/chrome_resources.gyp +++ b/chrome/chrome_resources.gyp @@ -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)', ], diff --git a/chrome/common/BUILD.gn b/chrome/common/BUILD.gn index c990941..edd9bc0 100644 --- a/chrome/common/BUILD.gn +++ b/chrome/common/BUILD.gn @@ -43,6 +43,7 @@ buildflag_header("features") { flags = [ "ENABLE_GOOGLE_NOW=$enable_google_now", "ANDROID_JAVA_UI=$android_java_ui", + "USE_VULCANIZE=$use_vulcanize", ] } diff --git a/chrome/common/features.gni b/chrome/common/features.gni index 3188c6c..7095deb 100644 --- a/chrome/common/features.gni +++ b/chrome/common/features.gni @@ -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", +] |