Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(968)

Unified Diff: mojo/services/html_viewer/blink_platform_impl.cc

Issue 827223002: [mojo] Make HTML viewer load the blink resources from the generated pak file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/services/html_viewer/blink_platform_impl.cc
diff --git a/mojo/services/html_viewer/blink_platform_impl.cc b/mojo/services/html_viewer/blink_platform_impl.cc
index d97a5098e1b8ba8a2d2aad6f7fbf5239d701feda..d7f8271fd61412f31863f732acf8a33a5f253406 100644
--- a/mojo/services/html_viewer/blink_platform_impl.cc
+++ b/mojo/services/html_viewer/blink_platform_impl.cc
@@ -6,11 +6,13 @@
#include <cmath>
+#include "base/path_service.h"
#include "base/rand_util.h"
#include "base/stl_util.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
+#include "blink/public/resources/grit/blink_resources.h"
#include "mojo/services/html_viewer/webthread_impl.h"
#include "net/base/data_url.h"
#include "net/base/mime_util.h"
@@ -25,6 +27,63 @@ const char kUserAgentString[] =
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/35.0.1916.153 Safari/537.36";
+struct DataResource {
+ const char* name;
+ int id;
+};
+
+const DataResource kDataResources[] = {
+ {"html.css", IDR_UASTYLE_HTML_CSS},
+ {"quirks.css", IDR_UASTYLE_QUIRKS_CSS},
+ {"view-source.css", IDR_UASTYLE_VIEW_SOURCE_CSS},
+ {"themeChromium.css", IDR_UASTYLE_THEME_CHROMIUM_CSS},
+#if defined(OS_ANDROID)
+ {"themeChromiumAndroid.css", IDR_UASTYLE_THEME_CHROMIUM_ANDROID_CSS},
+ {"mediaControlsAndroid.css", IDR_UASTYLE_MEDIA_CONTROLS_ANDROID_CSS},
+#endif
+#if !defined(OS_WIN)
jamesr 2015/01/05 23:54:40 we use linux on everything that's not windows?
+ {"themeChromiumLinux.css", IDR_UASTYLE_THEME_CHROMIUM_LINUX_CSS},
+#endif
+ {"themeChromiumSkia.css", IDR_UASTYLE_THEME_CHROMIUM_SKIA_CSS},
+ {"themeInputMultipleFields.css",
+ IDR_UASTYLE_THEME_INPUT_MULTIPLE_FIELDS_CSS},
+#if defined(OS_MACOSX)
+ {"themeMac.css", IDR_UASTYLE_THEME_MAC_CSS},
+#endif
+ {"themeWin.css", IDR_UASTYLE_THEME_WIN_CSS},
+ {"themeWinQuirks.css", IDR_UASTYLE_THEME_WIN_QUIRKS_CSS},
+ {"svg.css", IDR_UASTYLE_SVG_CSS},
+ {"navigationTransitions.css", IDR_UASTYLE_NAVIGATION_TRANSITIONS_CSS},
+ {"mathml.css", IDR_UASTYLE_MATHML_CSS},
+ {"mediaControls.css", IDR_UASTYLE_MEDIA_CONTROLS_CSS},
+ {"fullscreen.css", IDR_UASTYLE_FULLSCREEN_CSS},
+ {"xhtmlmp.css", IDR_UASTYLE_XHTMLMP_CSS},
+ {"viewportAndroid.css", IDR_UASTYLE_VIEWPORT_ANDROID_CSS},
+ {"InspectorOverlayPage.html", IDR_INSPECTOR_OVERLAY_PAGE_HTML},
+ {"InjectedScriptCanvasModuleSource.js",
+ IDR_INSPECTOR_INJECTED_SCRIPT_CANVAS_MODULE_SOURCE_JS},
+ {"InjectedScriptSource.js", IDR_INSPECTOR_INJECTED_SCRIPT_SOURCE_JS},
+ {"DebuggerScriptSource.js", IDR_INSPECTOR_DEBUGGER_SCRIPT_SOURCE_JS},
+ {"DocumentExecCommand.js", IDR_PRIVATE_SCRIPT_DOCUMENTEXECCOMMAND_JS},
+ {"DocumentXMLTreeViewer.css", IDR_PRIVATE_SCRIPT_DOCUMENTXMLTREEVIEWER_CSS},
+ {"DocumentXMLTreeViewer.js", IDR_PRIVATE_SCRIPT_DOCUMENTXMLTREEVIEWER_JS},
+ {"HTMLMarqueeElement.js", IDR_PRIVATE_SCRIPT_HTMLMARQUEEELEMENT_JS},
+ {"PluginPlaceholderElement.js",
+ IDR_PRIVATE_SCRIPT_PLUGINPLACEHOLDERELEMENT_JS},
+ {"PrivateScriptRunner.js", IDR_PRIVATE_SCRIPT_PRIVATESCRIPTRUNNER_JS},
+#ifdef IDR_PICKER_COMMON_JS
+ {"pickerCommon.js", IDR_PICKER_COMMON_JS},
+ {"pickerCommon.css", IDR_PICKER_COMMON_CSS},
+ {"calendarPicker.js", IDR_CALENDAR_PICKER_JS},
+ {"calendarPicker.css", IDR_CALENDAR_PICKER_CSS},
+ {"pickerButton.css", IDR_PICKER_BUTTON_CSS},
+ {"suggestionPicker.js", IDR_SUGGESTION_PICKER_JS},
+ {"suggestionPicker.css", IDR_SUGGESTION_PICKER_CSS},
+ {"colorSuggestionPicker.js", IDR_COLOR_SUGGESTION_PICKER_JS},
+ {"colorSuggestionPicker.css", IDR_COLOR_SUGGESTION_PICKER_CSS}
+#endif
+};
+
class WebWaitableEventImpl : public blink::WebWaitableEvent {
public:
WebWaitableEventImpl() : impl_(new base::WaitableEvent(false, false)) {}
@@ -50,7 +109,13 @@ BlinkPlatformImpl::BlinkPlatformImpl()
shared_timer_fire_time_(0.0),
shared_timer_fire_time_was_set_while_suspended_(false),
shared_timer_suspended_(0),
- current_thread_slot_(&DestroyCurrentThread) {
+ current_thread_slot_(&DestroyCurrentThread),
+ data_pack_(ui::SCALE_FACTOR_100P) {
+ base::FilePath blink_resources_pak_path;
+ PathService::Get(base::DIR_MODULE, &blink_resources_pak_path);
+ blink_resources_pak_path =
+ blink_resources_pak_path.Append(FILE_PATH_LITERAL("blink_resources.pak"));
+ data_pack_.LoadFromPath(blink_resources_pak_path);
}
BlinkPlatformImpl::~BlinkPlatformImpl() {
@@ -143,6 +208,18 @@ const unsigned char* BlinkPlatformImpl::getTraceCategoryEnabledFlag(
return buf;
}
+blink::WebData BlinkPlatformImpl::loadResource(const char* resource) {
+ for (size_t i = 0; i < arraysize(kDataResources); ++i) {
+ if (!strcmp(resource, kDataResources[i].name)) {
+ base::StringPiece resource;
+ data_pack_.GetStringPiece(kDataResources[i].id, &resource);
+ return blink::WebData(resource.data(), resource.size());
+ }
+ }
+ NOTREACHED() << "Requested resource is unavailable!";
+ return blink::WebData();
+}
+
blink::WebURLLoader* BlinkPlatformImpl::createURLLoader() {
return NULL;
}

Powered by Google App Engine
This is Rietveld 408576698