summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-24 01:26:40 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-24 01:26:40 +0000
commit3573b43d8178c8c9b4c4efc937e3ca3342bdae11 (patch)
tree7c7305894803d864aa33d4a13dd3289cc360aaf5
parent270d97d0e083743053613360b6342d6a9d199071 (diff)
downloadchromium_src-3573b43d8178c8c9b4c4efc937e3ca3342bdae11.zip
chromium_src-3573b43d8178c8c9b4c4efc937e3ca3342bdae11.tar.gz
chromium_src-3573b43d8178c8c9b4c4efc937e3ca3342bdae11.tar.bz2
Move the bookmark manager into resources.pak.
This allows for the bookmark manager to work after upgrading in the background on Linux. BUG=42770 TEST=Bookmark manager still works Review URL: http://codereview.chromium.org/2814009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50683 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--app/resource_bundle.h2
-rw-r--r--app/resource_bundle_posix.cc2
-rw-r--r--app/resource_bundle_win.cc2
-rw-r--r--chrome/browser/extensions/extension_protocols.cc71
-rw-r--r--chrome/browser/resources/bookmark_manager_resources.grd32
-rw-r--r--chrome/browser/resources/net_internals_resources.grd2
-rw-r--r--chrome/chrome.gyp2
-rw-r--r--chrome/chrome_browser.gypi39
-rw-r--r--chrome/chrome_dll.gypi2
-rw-r--r--chrome/installer/mini_installer/chrome.release5
-rw-r--r--chrome/installer/mini_installer/chrome_frame.release2
11 files changed, 111 insertions, 50 deletions
diff --git a/app/resource_bundle.h b/app/resource_bundle.h
index 1d328a3..e2ec86c 100644
--- a/app/resource_bundle.h
+++ b/app/resource_bundle.h
@@ -105,7 +105,7 @@ class ResourceBundle {
RefCountedStaticMemory* LoadDataResourceBytes(int resource_id) const;
// Return the contents of a resource in a StringPiece given the resource id.
- base::StringPiece GetRawDataResource(int resource_id);
+ base::StringPiece GetRawDataResource(int resource_id) const;
// Get a localized string given a message id. Returns an empty
// string if the message_id is not found.
diff --git a/app/resource_bundle_posix.cc b/app/resource_bundle_posix.cc
index f8d5333..cdd9ee2 100644
--- a/app/resource_bundle_posix.cc
+++ b/app/resource_bundle_posix.cc
@@ -50,7 +50,7 @@ RefCountedStaticMemory* ResourceBundle::LoadResourceBytes(
return module->GetStaticMemory(resource_id);
}
-base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) {
+base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) const {
DCHECK(resources_data_);
base::StringPiece data;
if (!resources_data_->GetStringPiece(resource_id, &data)) {
diff --git a/app/resource_bundle_win.cc b/app/resource_bundle_win.cc
index 38040dd..498cec6 100644
--- a/app/resource_bundle_win.cc
+++ b/app/resource_bundle_win.cc
@@ -102,7 +102,7 @@ HICON ResourceBundle::LoadThemeIcon(int icon_id) {
return ::LoadIcon(resources_data_, MAKEINTRESOURCE(icon_id));
}
-base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) {
+base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) const {
void* data_ptr;
size_t data_size;
if (base::GetDataResourceFromModule(_AtlBaseModule.GetModuleInstance(),
diff --git a/chrome/browser/extensions/extension_protocols.cc b/chrome/browser/extensions/extension_protocols.cc
index 02964fa..2a740f1 100644
--- a/chrome/browser/extensions/extension_protocols.cc
+++ b/chrome/browser/extensions/extension_protocols.cc
@@ -4,18 +4,67 @@
#include "chrome/browser/extensions/extension_protocols.h"
+#include <algorithm>
+
+#include "app/resource_bundle.h"
+#include "base/file_path.h"
+#include "base/logging.h"
+#include "base/message_loop.h"
+#include "base/path_service.h"
#include "base/string_util.h"
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
+#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_file_util.h"
#include "chrome/common/extensions/extension_resource.h"
#include "chrome/common/url_constants.h"
#include "googleurl/src/url_util.h"
+#include "grit/bookmark_manager_resources_map.h"
+#include "net/base/mime_util.h"
#include "net/base/net_errors.h"
-#include "net/url_request/url_request_file_job.h"
#include "net/url_request/url_request_error_job.h"
+#include "net/url_request/url_request_file_job.h"
+#include "net/url_request/url_request_simple_job.h"
+
+namespace {
+
+class URLRequestResourceBundleJob : public URLRequestSimpleJob {
+ public:
+ explicit URLRequestResourceBundleJob(URLRequest* request,
+ const FilePath& filename, int resource_id)
+ : URLRequestSimpleJob(request),
+ filename_(filename),
+ resource_id_(resource_id) { }
+
+ // URLRequestSimpleJob method.
+ virtual bool GetData(std::string* mime_type,
+ std::string* charset,
+ std::string* data) const {
+ const ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ *data = rb.GetRawDataResource(resource_id_).as_string();
+ bool result = net::GetMimeTypeFromFile(filename_, mime_type);
+ if (StartsWithASCII(*mime_type, "text/", false)) {
+ // All of our HTML files should be UTF-8 and for other resource types
+ // (like images), charset doesn't matter.
+ DCHECK(IsStringUTF8(*data));
+ *charset = "utf-8";
+ }
+ return result;
+ }
+
+ private:
+ virtual ~URLRequestResourceBundleJob() { }
+
+ // We need the filename of the resource to determine the mime type.
+ FilePath filename_;
+
+ // The resource bundle id to load.
+ int resource_id_;
+};
+
+} // namespace
// Factory registered with URLRequest to create URLRequestJobs for extension://
// URLs.
@@ -41,6 +90,26 @@ static URLRequestJob* CreateExtensionURLRequestJob(URLRequest* request,
return NULL;
}
+ FilePath resources_path;
+ if (PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_path) &&
+ directory_path.DirName() == resources_path.RemoveExtension()) {
+ FilePath relative_path = directory_path.BaseName().Append(
+ extension_file_util::ExtensionURLToRelativeFilePath(request->url()));
+
+ // TODO(tc): Make a map of FilePath -> resource ids so we don't have to
+ // covert to FilePaths all the time. This will be more useful as we add
+ // more resources.
+ for (size_t i = 0; i < kBookmarkManagerResourcesSize; ++i) {
+ FilePath bm_resource_path =
+ FilePath().AppendASCII(kBookmarkManagerResources[i].name);
+ if (relative_path == bm_resource_path) {
+ return new URLRequestResourceBundleJob(request, relative_path,
+ kBookmarkManagerResources[i].value);
+ }
+ }
+ }
+ // TODO(tc): Move all of these files into resources.pak so we don't break
+ // when updating on Linux.
ExtensionResource resource(directory_path,
extension_file_util::ExtensionURLToRelativeFilePath(request->url()));
diff --git a/chrome/browser/resources/bookmark_manager_resources.grd b/chrome/browser/resources/bookmark_manager_resources.grd
new file mode 100644
index 0000000..8a54565
--- /dev/null
+++ b/chrome/browser/resources/bookmark_manager_resources.grd
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- This comment is only here because changes to resources are not picked up
+without changes to the corresponding grd file. -->
+<grit latest_public_release="0" current_release="1">
+ <outputs>
+ <output filename="grit/bookmark_manager_resources.h" type="rc_header">
+ <emit emit_type='prepend'></emit>
+ </output>
+ <output filename="bookmark_manager_resources.pak" type="data_package" />
+ <output filename="grit/bookmark_manager_resources_map.h" type="resource_map_header" />
+ <output filename="grit/bookmark_manager_resources_map.cc" type="resource_file_map_source" />
+ </outputs>
+ <release seq="1">
+ <includes>
+ <include name="IDR_BOOKMARK_MANAGER_TREE_ITERATOR_TEST" file="bookmark_manager/js/bmm/tree_iterator_test.html" type="BINDATA" />
+ <include name="IDR_BOOKMARK_MANAGER_BOOKMARK_TREE" file="bookmark_manager/js/bmm/bookmark_tree.js" type="BINDATA" />
+ <include name="IDR_BOOKMARK_MANAGER_TREE_ITERATOR" file="bookmark_manager/js/bmm/tree_iterator.js" type="BINDATA" />
+ <include name="IDR_BOOKMARK_MANAGER_BOOKMARK_LIST" file="bookmark_manager/js/bmm/bookmark_list.js" type="BINDATA" />
+ <include name="IDR_BOOKMARK_MANAGER_BMM_TEST" file="bookmark_manager/js/bmm_test.html" type="BINDATA" />
+ <include name="IDR_BOOKMARK_MANAGER_BMM_JS" file="bookmark_manager/js/bmm.js" type="BINDATA" />
+ <include name="IDR_BOOKMARK_MANAGER_MANIFEST_JSON" file="bookmark_manager/manifest.json" type="BINDATA" />
+ <include name="IDR_BOOKMARK_MANAGER_BMM_CSS" file="bookmark_manager/css/bmm.css" type="BINDATA" />
+ <include name="IDR_BOOKMARK_MANAGER_BMM_CSS_JS" file="bookmark_manager/css/bmm.css.js" type="BINDATA" />
+ <include name="IDR_BOOKMARK_MANAGER_MAIN" file="bookmark_manager/main.html" type="BINDATA" />
+ <include name="IDR_BOOKMARK_MANAGER_BOOKMARKS_SECTION_32" file="bookmark_manager/images/bookmarks_section_32.png" type="BINDATA" />
+ <include name="IDR_BOOKMARK_MANAGER_BOOKMARKS_SECTION" file="bookmark_manager/images/bookmarks_section.png" type="BINDATA" />
+ <include name="IDR_BOOKMARK_MANAGER_BOOKMARK_MANAGER_SEARCH" file="bookmark_manager/images/bookmark_manager_search.png" type="BINDATA" />
+ <include name="IDR_BOOKMARK_MANAGER_BOOKMARKS_FAVICON" file="bookmark_manager/images/bookmarks_favicon.png" type="BINDATA" />
+ <include name="IDR_BOOKMARK_MANAGER_BOOKMARK_MANAGER_RECENT" file="bookmark_manager/images/bookmark_manager_recent.png" type="BINDATA" />
+ </includes>
+ </release>
+</grit>
diff --git a/chrome/browser/resources/net_internals_resources.grd b/chrome/browser/resources/net_internals_resources.grd
index a6f6da3..2ed151a 100644
--- a/chrome/browser/resources/net_internals_resources.grd
+++ b/chrome/browser/resources/net_internals_resources.grd
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This comment is only here because changes to resources are not picked up
-without changes to the corresponding grd file. paaaae -->
+without changes to the corresponding grd file. -->
<grit latest_public_release="0" current_release="1">
<outputs>
<output filename="grit/net_internals_resources.h" type="rc_header">
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 934d22f..3505c4d 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -59,6 +59,7 @@
# These resources end up in resources.pak because they are resources
# used by internal pages. Putting them in a spearate pak file makes
# it easier for us to reference them internally.
+ 'browser/resources/bookmark_manager_resources.grd',
'browser/resources/net_internals_resources.grd',
],
'grit_info_cmd': ['python', '../tools/grit/grit_info.py'],
@@ -1507,6 +1508,7 @@
'action_name': 'repack_resources',
'variables': {
'pak_inputs': [
+ '<(grit_out_dir)/bookmark_manager_resources.pak',
'<(grit_out_dir)/net_internals_resources.pak',
],
},
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index b13864a..e649a27 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2706,6 +2706,7 @@
'browser/zygote_main_linux.cc',
# These files are generated by GRIT.
+ '<(grit_out_dir)/grit/bookmark_manager_resources_map.cc',
'<(grit_out_dir)/grit/theme_resources_map.cc',
'<(grit_out_dir)/grit/net_internals_resources_map.cc',
],
@@ -3479,44 +3480,6 @@
# http://code.google.com/p/gyp/issues/detail?id=143.
'copies': [
{
- 'destination': '<(PRODUCT_DIR)/resources/bookmark_manager',
- 'files': [
- 'browser/resources/bookmark_manager/main.html',
- 'browser/resources/bookmark_manager/manifest.json',
- ]
- },
- {
- 'destination': '<(PRODUCT_DIR)/resources/bookmark_manager/css',
- 'files': [
- 'browser/resources/bookmark_manager/css/bmm.css',
- 'browser/resources/bookmark_manager/css/bmm.css.js',
- ]
- },
- {
- 'destination': '<(PRODUCT_DIR)/resources/bookmark_manager/js',
- 'files': [
- 'browser/resources/bookmark_manager/js/bmm.js',
- ]
- },
- {
- 'destination': '<(PRODUCT_DIR)/resources/bookmark_manager/js/bmm',
- 'files': [
- 'browser/resources/bookmark_manager/js/bmm/bookmark_list.js',
- 'browser/resources/bookmark_manager/js/bmm/bookmark_tree.js',
- 'browser/resources/bookmark_manager/js/bmm/tree_iterator.js',
- ]
- },
- {
- 'destination': '<(PRODUCT_DIR)/resources/bookmark_manager/images',
- 'files': [
- 'browser/resources/bookmark_manager/images/bookmark_manager_recent.png',
- 'browser/resources/bookmark_manager/images/bookmark_manager_search.png',
- 'browser/resources/bookmark_manager/images/bookmarks_favicon.png',
- 'browser/resources/bookmark_manager/images/bookmarks_section.png',
- 'browser/resources/bookmark_manager/images/bookmarks_section_32.png',
- ]
- },
- {
'destination': '<(PRODUCT_DIR)/resources/gmail_app',
'files': [
'browser/resources/gmail_app/manifest.json',
diff --git a/chrome/chrome_dll.gypi b/chrome/chrome_dll.gypi
index 16c9e2a..96ba2fa 100644
--- a/chrome/chrome_dll.gypi
+++ b/chrome/chrome_dll.gypi
@@ -378,6 +378,7 @@
'action_name': 'repack_resources',
'variables': {
'pak_inputs': [
+ '<(grit_out_dir)/bookmark_manager_resources.pak',
'<(grit_out_dir)/net_internals_resources.pak',
],
},
@@ -439,7 +440,6 @@
'destination': '<(PRODUCT_DIR)/$(CONTENTS_FOLDER_PATH)/Resources',
'files': [
'<(PRODUCT_DIR)/resources/inspector/',
- '<(PRODUCT_DIR)/resources/bookmark_manager/',
'<(PRODUCT_DIR)/resources/shared/',
'<(PRODUCT_DIR)/resources/gmail_app/',
'<(PRODUCT_DIR)/resources/calendar_app/',
diff --git a/chrome/installer/mini_installer/chrome.release b/chrome/installer/mini_installer/chrome.release
index 7ceeeee..cf5f782 100644
--- a/chrome/installer/mini_installer/chrome.release
+++ b/chrome/installer/mini_installer/chrome.release
@@ -38,11 +38,6 @@ icudt42.dll: %(VersionDir)s\
gears.dll: %(VersionDir)s\
resources.pak: %(VersionDir)s\
locales\*.dll: %(VersionDir)s\Locales
-Resources\bookmark_manager\*.*: %(VersionDir)s\Resources\bookmark_manager
-Resources\bookmark_manager\css\*.*: %(VersionDir)s\Resources\bookmark_manager\css
-Resources\bookmark_manager\images\*.*: %(VersionDir)s\Resources\bookmark_manager\images
-Resources\bookmark_manager\js\*.*: %(VersionDir)s\Resources\bookmark_manager\js
-Resources\bookmark_manager\js\bmm\*.*: %(VersionDir)s\Resources\bookmark_manager\js\bmm
Resources\shared\css\*.*: %(VersionDir)s\Resources\shared\css
Resources\shared\images\*.*: %(VersionDir)s\Resources\shared\images
Resources\shared\js\*.*: %(VersionDir)s\Resources\shared\js
diff --git a/chrome/installer/mini_installer/chrome_frame.release b/chrome/installer/mini_installer/chrome_frame.release
index 1e5fce3..cfddf3e 100644
--- a/chrome/installer/mini_installer/chrome_frame.release
+++ b/chrome/installer/mini_installer/chrome_frame.release
@@ -36,7 +36,7 @@ nacl64.exe: %(VersionDir)s\
nacl64.dll: %(VersionDir)s\
icudt42.dll: %(VersionDir)s\
gears.dll: %(VersionDir)s\
-Themes\default.dll: %(VersionDir)s\Themes
+resources.pak: %(VersionDir)s\
locales\*.dll: %(VersionDir)s\Locales
Resources\Inspector\*.*: %(VersionDir)s\Resources\Inspector
Resources\Inspector\Images\*.*: %(VersionDir)s\Resources\Inspector\Images