diff --git a/appshell/resource.h b/appshell/browser/resource.h similarity index 69% rename from appshell/resource.h rename to appshell/browser/resource.h index fddad4ac7..d12366c23 100644 --- a/appshell/resource.h +++ b/appshell/browser/resource.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. @@ -10,7 +10,7 @@ #define IDC_STATIC -1 #define BINARY 256 - +#define IDC_MYICON 2 #define IDD_CEFCLIENT_DIALOG 102 #define IDS_APP_TITLE 103 #define IDD_ABOUTBOX 103 @@ -19,6 +19,7 @@ #define IDI_CEFCLIENT 107 #define IDI_SMALL 108 #define IDC_CEFCLIENT 109 +#define IDS_OSR_WIDGET_CLASS 110 #define IDR_MAINFRAME 128 #define IDC_NAV_BACK 200 #define IDC_NAV_FORWARD 201 @@ -90,39 +91,49 @@ #define IDB_RESTORE_HOVER_BUTTON_2_5X 358 #define IDB_RESTORE_PRESSED_BUTTON_2_5X 359 -#define IDS_BINDING 1000 -#define IDS_DIALOGS 1001 -#define IDS_LOGO 1002 -#define IDS_LOGOBALL 1003 -#define IDS_LOCALSTORAGE 1004 -#define IDS_XMLHTTPREQUEST 1005 -#define IDS_DOMACCESS 1006 -#define IDS_APPSHELL_EXTENSIONS 1007 - #define ID_WARN_CONSOLEMESSAGE 32000 #define ID_WARN_DOWNLOADCOMPLETE 32001 #define ID_WARN_DOWNLOADERROR 32002 -#define ID_TESTS_GETSOURCE 32760 -#define ID_TESTS_GETTEXT 32761 -#define ID_TESTS_POPUP 32762 -#define ID_TESTS_REQUEST 32763 -#define ID_TESTS_SCHEME_HANDLER 32764 -#define ID_TESTS_LOCALSTORAGE 32765 -#define ID_TESTS_ACCELERATED2DCANVAS 32766 -#define ID_TESTS_ACCELERATEDLAYERS 32767 -#define ID_TESTS_WEBGL 32768 -#define ID_TESTS_HTML5VIDEO 32769 -#define ID_TESTS_XMLHTTPREQUEST 32770 -#define ID_TESTS_DRAGDROP 32771 -#define ID_TESTS_GEOLOCATION 32772 -#define ID_TESTS_BINDING 32773 -#define ID_TESTS_DIALOGS 32774 -#define ID_TESTS_PLUGIN_INFO 32775 -#define ID_TESTS_DOM_ACCESS 32776 +#define ID_QUIT 32500 +#define ID_FIND 32501 +#define ID_TESTS_FIRST 32700 +#define ID_TESTS_GETSOURCE 32700 +#define ID_TESTS_GETTEXT 32701 +#define ID_TESTS_OTHER_TESTS 32702 +#define ID_TESTS_PLUGIN_INFO 32703 +#define ID_TESTS_WINDOW_NEW 32704 +#define ID_TESTS_WINDOW_POPUP 32705 +#define ID_TESTS_PRINT 32706 +#define ID_TESTS_REQUEST 32707 +#define ID_TESTS_TRACING_BEGIN 32708 +#define ID_TESTS_TRACING_END 32709 +#define ID_TESTS_ZOOM_IN 32710 +#define ID_TESTS_ZOOM_OUT 32711 +#define ID_TESTS_ZOOM_RESET 32712 +#define ID_TESTS_OSR_FPS 32713 +#define ID_TESTS_OSR_DSF 32714 +#define ID_TESTS_PRINT_TO_PDF 32715 +#define ID_TESTS_LAST 32715 + #define IDM_CLOSE 32777 -// Avoid files associated with MacOS -#define _X86_ +#define IDS_BINDING_HTML 1000 +#define IDS_DIALOGS_HTML 1001 +#define IDS_LOCALSTORAGE_HTML 1002 +#define IDS_LOGO_PNG 1003 +#define IDS_OSRTEST_HTML 1004 +#define IDS_OTHER_TESTS_HTML 1005 +#define IDS_PDF_HTML 1006 +#define IDS_PDF_PDF 1007 +#define IDS_PERFORMANCE_HTML 1008 +#define IDS_PERFORMANCE2_HTML 1009 +#define IDS_PREFERENCES_HTML 1010 +#define IDS_RESPONSE_FILTER_HTML 1011 +#define IDS_TRANSPARENCY_HTML 1012 +#define IDS_URLREQUEST_HTML 1013 +#define IDS_WINDOW_HTML 1014 +#define IDS_XMLHTTPREQUEST_HTML 1015 +#define IDS_APPSHELL_EXTENSIONS 1016 // Next default values for new objects // @@ -132,6 +143,6 @@ #define _APS_NEXT_RESOURCE_VALUE 130 #define _APS_NEXT_COMMAND_VALUE 32774 #define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 110 +#define _APS_NEXT_SYMED_VALUE 111 #endif #endif diff --git a/appshell/browser/resource_util.h b/appshell/browser/resource_util.h new file mode 100644 index 000000000..84149aca1 --- /dev/null +++ b/appshell/browser/resource_util.h @@ -0,0 +1,37 @@ +// Copyright (c) 2013 The Chromium Embedded Framework 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 CEF_TESTS_CEFCLIENT_BROWSER_RESOURCE_UTIL_H_ +#define CEF_TESTS_CEFCLIENT_BROWSER_RESOURCE_UTIL_H_ +#pragma once + +#include +#include "include/cef_stream.h" + +#if defined(OS_WIN) +#include "include/wrapper/cef_resource_manager.h" +#endif + +namespace client { + +#if defined(OS_POSIX) +// Returns the directory containing resource files. +bool GetResourceDir(std::string& dir); +#endif + +// Retrieve a resource as a string. +bool LoadBinaryResource(const char* resource_name, std::string& resource_data); + +// Retrieve a resource as a steam reader. +CefRefPtr GetBinaryResourceReader(const char* resource_name); + +#if defined(OS_WIN) +// Create a new provider for loading binary resources. +CefResourceManager::Provider* CreateBinaryResourceProvider( + const std::string& url_path); +#endif + +} // namespace client + +#endif // CEF_TESTS_CEFCLIENT_BROWSER_RESOURCE_UTIL_H_ diff --git a/appshell/browser/resource_util_linux.cc b/appshell/browser/resource_util_linux.cc new file mode 100644 index 000000000..b7bc4b043 --- /dev/null +++ b/appshell/browser/resource_util_linux.cc @@ -0,0 +1,35 @@ +// Copyright (c) 2013 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 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 "appshell/browser/resource_util.h" + +#include +#include +#include + +namespace client { + +bool GetResourceDir(std::string& dir) { + char buff[1024]; + + // Retrieve the executable path. + ssize_t len = readlink("/proc/self/exe", buff, sizeof(buff)-1); + if (len == -1) + return false; + + buff[len] = 0; + + // Remove the executable name from the path. + char* pos = strrchr(buff, '/'); + if (!pos) + return false; + + // Add "files" to the path. + strcpy(pos+1, "files"); // NOLINT(runtime/printf) + dir = std::string(buff); + return true; +} + +} // namespace client diff --git a/appshell/resource_util_mac.mm b/appshell/browser/resource_util_mac.mm similarity index 53% rename from appshell/resource_util_mac.mm rename to appshell/browser/resource_util_mac.mm index 182400698..08ab53921 100644 --- a/appshell/resource_util_mac.mm +++ b/appshell/browser/resource_util_mac.mm @@ -1,46 +1,51 @@ -// Copyright (c) 2011 The Chromium Embedded Framework Authors. +// Copyright (c) 2013 The Chromium Embedded Framework Authors. // Portions copyright (c) 2011 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 "appshell/browser/resource_util.h" + #import #include #include -#include "resource_util.h" -#include "include/cef_stream.h" + #include "include/base/cef_logging.h" +namespace client { + namespace { bool AmIBundled() { // Implementation adapted from Chromium's base/mac/foundation_util.mm ProcessSerialNumber psn = {0, kCurrentProcess}; - + FSRef fsref; OSStatus pbErr; if ((pbErr = GetProcessBundleLocation(&psn, &fsref)) != noErr) { - DCHECK(false); + NOTREACHED(); return false; } - + FSCatalogInfo info; OSErr fsErr; if ((fsErr = FSGetCatalogInfo(&fsref, kFSCatInfoNodeFlags, &info, NULL, NULL, NULL)) != noErr) { - DCHECK(false); + NOTREACHED(); return false; } - + return (info.nodeFlags & kFSNodeIsDirectoryMask); } +} // namespace + bool GetResourceDir(std::string& dir) { - // Implementation adapted from Chromium's base/base_path_mac.mm - if (AmIBundled()) { + // Implementation adapted from Chromium's base/base_path_mac.mm + if (AmIBundled()) { // Retrieve the executable directory. uint32_t pathSize = 0; _NSGetExecutablePath(NULL, &pathSize); - if (pathSize > 0) { + if (pathSize > 0) { dir.resize(pathSize); _NSGetExecutablePath(const_cast(dir.c_str()), &pathSize); } @@ -52,46 +57,9 @@ bool GetResourceDir(std::string& dir) { return true; } else { // TODO: Provide unbundled path - DCHECK(false); + NOTIMPLEMENTED(); return false; } } -bool ReadFileToString(const char* path, std::string& data) { - // Implementation adapted from base/file_util.cc - FILE* file = fopen(path, "rb"); - if (!file) - return false; - - char buf[1 << 16]; - size_t len; - while ((len = fread(buf, 1, sizeof(buf), file)) > 0) - data.append(buf, len); - fclose(file); - - return true; -} - -} // namespace - -bool LoadBinaryResource(const char* resource_name, std::string& resource_data) { - std::string path; - if (!GetResourceDir(path)) - return false; - - path.append("/"); - path.append(resource_name); - - return ReadFileToString(path.c_str(), resource_data); -} - -CefRefPtr GetBinaryResourceReader(const char* resource_name) { - std::string path; - if (!GetResourceDir(path)) - return NULL; - - path.append("/"); - path.append(resource_name); - - return CefStreamReader::CreateForFile(path); -} +} // namespace client diff --git a/appshell/browser/resource_util_posix.cc b/appshell/browser/resource_util_posix.cc new file mode 100644 index 000000000..5431bf744 --- /dev/null +++ b/appshell/browser/resource_util_posix.cc @@ -0,0 +1,64 @@ +// Copyright (c) 2013 The Chromium Embedded Framework 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 "appshell/browser/resource_util.h" + +#include + +namespace client { + +namespace { + +bool FileExists(const char* path) { + FILE* f = fopen(path, "rb"); + if (f) { + fclose(f); + return true; + } + return false; +} + +bool ReadFileToString(const char* path, std::string& data) { + // Implementation adapted from base/file_util.cc + FILE* file = fopen(path, "rb"); + if (!file) + return false; + + char buf[1 << 16]; + size_t len; + while ((len = fread(buf, 1, sizeof(buf), file)) > 0) + data.append(buf, len); + fclose(file); + + return true; +} + +} // namespace + +bool LoadBinaryResource(const char* resource_name, std::string& resource_data) { + std::string path; + if (!GetResourceDir(path)) + return false; + + path.append("/"); + path.append(resource_name); + + return ReadFileToString(path.c_str(), resource_data); +} + +CefRefPtr GetBinaryResourceReader(const char* resource_name) { + std::string path; + if (!GetResourceDir(path)) + return NULL; + + path.append("/"); + path.append(resource_name); + + if (!FileExists(path.c_str())) + return NULL; + + return CefStreamReader::CreateForFile(path); +} + +} // namespace client diff --git a/appshell/browser/resource_util_win.cc b/appshell/browser/resource_util_win.cc new file mode 100644 index 000000000..686e7b142 --- /dev/null +++ b/appshell/browser/resource_util_win.cc @@ -0,0 +1,147 @@ +// Copyright (c) 2013 The Chromium Embedded Framework 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 "appshell/browser/resource_util.h" + +#include "include/base/cef_logging.h" +#include "include/cef_stream.h" +#include "include/wrapper/cef_byte_read_handler.h" +#include "include/wrapper/cef_stream_resource_handler.h" +#include "appshell/browser/resource.h" + +namespace client { + +namespace { + +bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes) { + HINSTANCE hInst = GetModuleHandle(NULL); + HRSRC hRes = FindResource(hInst, MAKEINTRESOURCE(binaryId), + MAKEINTRESOURCE(256)); + if (hRes) { + HGLOBAL hGlob = LoadResource(hInst, hRes); + if (hGlob) { + dwSize = SizeofResource(hInst, hRes); + pBytes = (LPBYTE)LockResource(hGlob); + if (dwSize > 0 && pBytes) + return true; + } + } + + return false; +} + +int GetResourceId(const char* resource_name) { + // Map of resource labels to BINARY id values. + static struct _resource_map { + char* name; + int id; + } resource_map[] = { + {"binding.html", IDS_BINDING_HTML}, + {"dialogs.html", IDS_DIALOGS_HTML}, + {"localstorage.html", IDS_LOCALSTORAGE_HTML}, + {"logo.png", IDS_LOGO_PNG}, + {"osr_test.html", IDS_OSRTEST_HTML}, + {"other_tests.html", IDS_OTHER_TESTS_HTML}, + {"pdf.html", IDS_PDF_HTML}, + {"pdf.pdf", IDS_PDF_PDF}, + {"performance.html", IDS_PERFORMANCE_HTML}, + {"performance2.html", IDS_PERFORMANCE2_HTML}, + {"preferences.html", IDS_PREFERENCES_HTML}, + {"response_filter.html", IDS_RESPONSE_FILTER_HTML}, + {"transparency.html", IDS_TRANSPARENCY_HTML}, + {"urlrequest.html", IDS_URLREQUEST_HTML}, + {"window.html", IDS_WINDOW_HTML}, + {"xmlhttprequest.html", IDS_XMLHTTPREQUEST_HTML}, + }; + + for (int i = 0; i < sizeof(resource_map)/sizeof(_resource_map); ++i) { + if (!strcmp(resource_map[i].name, resource_name)) + return resource_map[i].id; + } + + return 0; +} + +// Provider of binary resources. +class BinaryResourceProvider : public CefResourceManager::Provider { + public: + explicit BinaryResourceProvider(const std::string& url_path) + : url_path_(url_path) { + DCHECK(!url_path.empty()); + } + + bool OnRequest(scoped_refptr request) OVERRIDE { + CEF_REQUIRE_IO_THREAD(); + + const std::string& url = request->url(); + if (url.find(url_path_) != 0L) { + // Not handled by this provider. + return false; + } + + CefRefPtr handler; + + const std::string& relative_path = url.substr(url_path_.length()); + if (!relative_path.empty()) { + CefRefPtr stream = + GetBinaryResourceReader(relative_path.data()); + if (stream.get()) { + handler = new CefStreamResourceHandler( + request->mime_type_resolver().Run(url), + stream); + } + } + + request->Continue(handler); + return true; + } + + private: + std::string url_path_; + + DISALLOW_COPY_AND_ASSIGN(BinaryResourceProvider); +}; + +} // namespace + +bool LoadBinaryResource(const char* resource_name, std::string& resource_data) { + int resource_id = GetResourceId(resource_name); + if (resource_id == 0) + return false; + + DWORD dwSize; + LPBYTE pBytes; + + if (LoadBinaryResource(resource_id, dwSize, pBytes)) { + resource_data = std::string(reinterpret_cast(pBytes), dwSize); + return true; + } + + NOTREACHED(); // The resource should be found. + return false; +} + +CefRefPtr GetBinaryResourceReader(const char* resource_name) { + int resource_id = GetResourceId(resource_name); + if (resource_id == 0) + return NULL; + + DWORD dwSize; + LPBYTE pBytes; + + if (LoadBinaryResource(resource_id, dwSize, pBytes)) { + return CefStreamReader::CreateForHandler( + new CefByteReadHandler(pBytes, dwSize, NULL)); + } + + NOTREACHED(); // The resource should be found. + return NULL; +} + +CefResourceManager::Provider* CreateBinaryResourceProvider( + const std::string& url_path) { + return new BinaryResourceProvider(url_path); +} + +} // namespace client diff --git a/appshell/cef_dark_window.cpp b/appshell/cef_dark_window.cpp index 65e7ec348..91e35d108 100644 --- a/appshell/cef_dark_window.cpp +++ b/appshell/cef_dark_window.cpp @@ -20,7 +20,7 @@ * DEALINGS IN THE SOFTWARE. */ #include "cef_dark_window.h" -#include "resource.h" +#include "appshell/browser/resource.h" #include #include #include diff --git a/appshell/cef_main_window.cpp b/appshell/cef_main_window.cpp index 51305c81d..6988be86b 100644 --- a/appshell/cef_main_window.cpp +++ b/appshell/cef_main_window.cpp @@ -23,7 +23,7 @@ #include "cef_main_window.h" #include "cef_registry.h" #include "client_handler.h" -#include "resource.h" +#include "appshell/browser/resource.h" #include "native_menu_model.h" #include "config.h" diff --git a/appshell/cef_popup_window.cpp b/appshell/cef_popup_window.cpp index 7165958f6..91fb816b4 100644 --- a/appshell/cef_popup_window.cpp +++ b/appshell/cef_popup_window.cpp @@ -23,7 +23,7 @@ #include "cef_popup_window.h" #include "cef_registry.h" #include "client_handler.h" -#include "resource.h" +#include "appshell/browser/resource.h" #include "native_menu_model.h" // Externals diff --git a/appshell/cefclient.rc b/appshell/cefclient.rc index 70c3d19d2..4d0696558 100644 --- a/appshell/cefclient.rc +++ b/appshell/cefclient.rc @@ -1,6 +1,6 @@ // Microsoft Visual C++ generated resource script. // -#include "resource.h" +#include "appshell/browser/resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// diff --git a/appshell/cefclient_mac.mm b/appshell/cefclient_mac.mm index 9bba3e48d..070188aee 100644 --- a/appshell/cefclient_mac.mm +++ b/appshell/cefclient_mac.mm @@ -14,7 +14,7 @@ #include "include/cef_frame.h" #include "include/cef_runnable.h" #include "client_handler.h" -#include "resource_util.h" +#include "appshell/browser/resource_util.h" #include "config.h" #include "appshell_extensions.h" #include "command_callbacks.h" diff --git a/appshell/cefclient_win.cpp b/appshell/cefclient_win.cpp index d18382622..2df5fe01b 100644 --- a/appshell/cefclient_win.cpp +++ b/appshell/cefclient_win.cpp @@ -16,7 +16,7 @@ #include "include/cef_runnable.h" #include "client_handler.h" #include "config.h" -#include "resource.h" +#include "appshell/browser/resource.h" #include "appshell/common/client_switches.h" #include "native_menu_model.h" #include "appshell_node_process.h" diff --git a/appshell/client_app_gtk.cpp b/appshell/client_app_gtk.cpp index a4173b903..fb1272267 100644 --- a/appshell/client_app_gtk.cpp +++ b/appshell/client_app_gtk.cpp @@ -22,7 +22,7 @@ */ #include "client_app.h" -#include "resource.h" +#include "appshell/browser/resource.h" #include "include/cef_base.h" #include "config.h" diff --git a/appshell/client_app_win.cpp b/appshell/client_app_win.cpp index f55a1fa33..d037f1b6d 100644 --- a/appshell/client_app_win.cpp +++ b/appshell/client_app_win.cpp @@ -22,7 +22,7 @@ */ #include "client_app.h" -#include "resource.h" +#include "appshell/browser/resource.h" #include "include/cef_base.h" #include "config.h" diff --git a/appshell/client_handler.cpp b/appshell/client_handler.cpp index a7b133bb0..f802fe65b 100644 --- a/appshell/client_handler.cpp +++ b/appshell/client_handler.cpp @@ -11,7 +11,7 @@ #include "include/wrapper/cef_stream_resource_handler.h" #include "include/wrapper/cef_helpers.h" #include "cefclient.h" -#include "resource_util.h" +#include "appshell/browser/resource_util.h" #include "appshell/appshell_extensions.h" #include "appshell/command_callbacks.h" diff --git a/appshell/client_handler_win.cpp b/appshell/client_handler_win.cpp index af66474d6..2fbb657f3 100644 --- a/appshell/client_handler_win.cpp +++ b/appshell/client_handler_win.cpp @@ -8,7 +8,7 @@ #include "include/cef_browser.h" #include "include/cef_frame.h" #include "include/wrapper/cef_helpers.h" -#include "resource.h" +#include "appshell/browser/resource.h" #include "native_menu_model.h" #include diff --git a/appshell/resource_util.h b/appshell/resource_util.h deleted file mode 100644 index 4de0f0d30..000000000 --- a/appshell/resource_util.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2009 The Chromium Embedded Framework 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 CEF_TESTS_CEFCLIENT_RESOURCE_UTIL_H_ -#define CEF_TESTS_CEFCLIENT_RESOURCE_UTIL_H_ -#pragma once - -#include "include/cef_base.h" - -class CefStreamReader; - -#if defined(OS_WIN) - -#include "resource.h" - -// Load a resource of type BINARY -bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes); -CefRefPtr GetBinaryResourceReader(int binaryId); - -#elif defined(OS_MACOSX) || defined(OS_POSIX) - -#include // NOLINT(build/include_order) - -// Load the resource with the specified name. -bool LoadBinaryResource(const char* resource_name, std::string& resource_data); - -#endif - -CefRefPtr GetBinaryResourceReader(const char* resource_name); - -#endif // CEF_TESTS_CEFCLIENT_RESOURCE_UTIL_H_ diff --git a/appshell/resource_util_linux.cpp b/appshell/resource_util_linux.cpp deleted file mode 100644 index 810c7531b..000000000 --- a/appshell/resource_util_linux.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2011 The Chromium Embedded Framework Authors. -// Portions copyright (c) 2011 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 "resource_util.h" -#include -#include -#include "include/cef_stream.h" - -bool GetResourceDir(std::string& dir) { - char buff[1024]; - - // Retrieve the executable path. - ssize_t len = readlink("/proc/self/exe", buff, sizeof(buff)-1); - if (len == -1) - return false; - - buff[len] = 0; - - // Remove the executable name from the path. - char* pos = strrchr(buff, '/'); - if (!pos) - return false; - - // Add "files" to the path. - strcpy(pos+1, "files"); // NOLINT(runtime/printf) - dir = std::string(buff); - return true; -} - -bool LoadBinaryResource(const char* resource_name, std::string& resource_data) { - std::string path; - if (!GetResourceDir(path)) - return false; - - path.append("/"); - path.append(resource_name); - - FILE* f = fopen(path.c_str(), "rb"); - if (!f) - return false; - - size_t bytes_read; - char buff[1024*8]; - - do { - bytes_read = fread(buff, 1, sizeof(buff)-1, f); - if (bytes_read > 0) - resource_data.append(buff, bytes_read); - } while (bytes_read > 0); - - fclose(f); - return true; -} - -CefRefPtr GetBinaryResourceReader(const char* resource_name) { - std::string path; - if (!GetResourceDir(path)) - return NULL; - - path.append("/"); - path.append(resource_name); - - return CefStreamReader::CreateForFile(path); -} diff --git a/appshell/resource_util_win.cpp b/appshell/resource_util_win.cpp deleted file mode 100644 index d05b86727..000000000 --- a/appshell/resource_util_win.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2008-2009 The Chromium Embedded Framework 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 "resource_util.h" -#include "include/cef_stream.h" -#include "include/wrapper/cef_byte_read_handler.h" -#include "include/base/cef_logging.h" - -#if defined(OS_WIN) - -bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes) { - extern HINSTANCE hInst; - HRSRC hRes = FindResource(hInst, MAKEINTRESOURCE(binaryId), - MAKEINTRESOURCE(256)); - if (hRes) { - HGLOBAL hGlob = LoadResource(hInst, hRes); - if (hGlob) { - dwSize = SizeofResource(hInst, hRes); - pBytes = (LPBYTE)LockResource(hGlob); - if (dwSize > 0 && pBytes) - return true; - } - } - - return false; -} - -CefRefPtr GetBinaryResourceReader(int binaryId) { - DWORD dwSize; - LPBYTE pBytes; - - if (LoadBinaryResource(binaryId, dwSize, pBytes)) { - return CefStreamReader::CreateForHandler( - new CefByteReadHandler(pBytes, dwSize, NULL)); - } - - DCHECK(FALSE); // The resource should be found. - return NULL; -} - -CefRefPtr GetBinaryResourceReader(const char* resource_name) { - // Map of resource labels to BINARY id values. - static struct _resource_map { - char* name; - int id; - } resource_map[] = { - {"binding.html", IDS_BINDING}, - {"dialogs.html", IDS_DIALOGS}, - {"domaccess.html", IDS_DOMACCESS}, - {"localstorage.html", IDS_LOCALSTORAGE}, - {"xmlhttprequest.html", IDS_XMLHTTPREQUEST}, - }; - - for (int i = 0; i < sizeof(resource_map)/sizeof(_resource_map); ++i) { - if (!strcmp(resource_map[i].name, resource_name)) - return GetBinaryResourceReader(resource_map[i].id); - } - - DCHECK(FALSE); // The resource should be found. - return NULL; -} - -#endif // OS_WIN diff --git a/appshell/version.rc b/appshell/version.rc index 6979e2385..185029a88 100644 --- a/appshell/version.rc +++ b/appshell/version.rc @@ -1,6 +1,6 @@ // Microsoft Visual C++ generated resource script. // -#include "resource.h" +#include "appshell/browser/resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// diff --git a/appshell_paths.gypi b/appshell_paths.gypi index a775217e0..4bfa36822 100755 --- a/appshell_paths.gypi +++ b/appshell_paths.gypi @@ -140,8 +140,12 @@ '<@(autogen_client_side)', ], 'appshell_sources_browser': [ + 'appshell/browser/resource.h', + 'appshell/browser/resource_util.h', ], 'appshell_sources_common': [ + 'appshell/common/client_switches.cc', + 'appshell/common/client_switches.h', 'appshell/appshell_extensions.cpp', 'appshell/appshell_extensions.h', 'appshell/appshell_extensions_platform.h', @@ -158,17 +162,15 @@ 'appshell/client_app_delegates.cpp', 'appshell/client_handler.cpp', 'appshell/client_handler.h', - 'appshell/common/client_switches.cc', - 'appshell/common/client_switches.h', 'appshell/native_menu_model.cpp', 'appshell/native_menu_model.h', - 'appshell/resource_util.h', ], 'appshell_sources_renderer': [ ], 'appshell_sources_resources': [ ], 'appshell_sources_win': [ + 'appshell/browser/resource_util_win.cc', 'appshell/appshell_extensions_win.cpp', 'appshell/appshell_node_process_win.cpp', 'appshell/cefclient.rc', @@ -176,9 +178,7 @@ 'appshell/cefclient_win.cpp', 'appshell/client_app_win.cpp', 'appshell/client_handler_win.cpp', - 'appshell/resource.h', 'appshell/res/appshell.ico', - 'appshell/resource_util_win.cpp', 'appshell/cef_buffered_dc.h', 'appshell/cef_dark_aero_window.cpp', 'appshell/cef_dark_aero_window.h', @@ -212,6 +212,8 @@ '<@(appshell_sources_resources)', ], 'appshell_sources_mac': [ + 'appshell/browser/resource_util_mac.mm', + 'appshell/browser/resource_util_posix.cc', 'appshell/client_colors_mac.h', 'appshell/TrafficLightButton.h', 'appshell/TrafficLightButton.mm', @@ -232,7 +234,6 @@ 'appshell/client_app_mac.mm', 'appshell/cefclient_mac.mm', 'appshell/client_handler_mac.mm', - 'appshell/resource_util_mac.mm', '<@(appshell_sources_browser)', '<@(appshell_sources_common)', ], @@ -256,7 +257,6 @@ 'appshell/client_app_mac.mm', 'appshell/client_handler_mac.mm', 'appshell/process_helper_mac.cpp', - 'appshell/resource_util_mac.mm', '<@(appshell_sources_common)', '<@(appshell_sources_renderer)', ], @@ -316,12 +316,13 @@ '<@(appshell_sources_resources)', ], 'appshell_sources_linux': [ + 'appshell/browser/resource_util_linux.cc', + 'appshell/browser/resource_util_posix.cc', 'appshell/appshell_extensions_gtk.cpp', 'appshell/appshell_node_process_linux.cpp', 'appshell/client_app_gtk.cpp', 'appshell/cefclient_gtk.cpp', 'appshell/client_handler_gtk.cpp', - 'appshell/resource_util_linux.cpp', '<@(appshell_sources_browser)', '<@(appshell_sources_common)', '<@(appshell_sources_renderer)',