summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/dom_ui/chrome_url_data_manager.cc15
-rw-r--r--chrome/browser/dom_ui/shared_resources_data_source.cc88
-rw-r--r--chrome/browser/dom_ui/shared_resources_data_source.h33
-rw-r--r--chrome/browser/resources/shared_resources.grd78
-rw-r--r--chrome/chrome.gyp2
-rw-r--r--chrome/chrome_browser.gypi76
-rw-r--r--chrome/chrome_dll.gypi1
-rw-r--r--chrome/installer/mini_installer/chrome.release5
8 files changed, 208 insertions, 90 deletions
diff --git a/chrome/browser/dom_ui/chrome_url_data_manager.cc b/chrome/browser/dom_ui/chrome_url_data_manager.cc
index a011801..c5aad64 100644
--- a/chrome/browser/dom_ui/chrome_url_data_manager.cc
+++ b/chrome/browser/dom_ui/chrome_url_data_manager.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/appcache/view_appcache_internals_job_factory.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/dom_ui/shared_resources_data_source.h"
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/net/view_http_cache_job_factory.h"
#include "chrome/common/chrome_paths.h"
@@ -98,13 +99,7 @@ void RegisterURLRequestChromeJob() {
chrome::kChromeUIDevToolsHost, inspector_dir);
}
- // Set up the chrome://resources/ source.
- FilePath resources_dir;
- if (PathService::Get(chrome::DIR_SHARED_RESOURCES, &resources_dir)) {
- Singleton<ChromeURLDataManager>()->AddFileSource(
- chrome::kChromeUIResourcesHost, resources_dir);
- }
-
+ SharedResourcesDataSource::Register();
URLRequest::RegisterProtocolFactory(chrome::kChromeUIScheme,
&ChromeURLDataManager::Factory);
}
@@ -115,12 +110,6 @@ void UnregisterURLRequestChromeJob() {
Singleton<ChromeURLDataManager>()->RemoveFileSource(
chrome::kChromeUIDevToolsHost);
}
-
- FilePath resources_dir;
- if (PathService::Get(chrome::DIR_SHARED_RESOURCES, &resources_dir)) {
- Singleton<ChromeURLDataManager>()->RemoveFileSource(
- chrome::kChromeUIResourcesHost);
- }
}
// static
diff --git a/chrome/browser/dom_ui/shared_resources_data_source.cc b/chrome/browser/dom_ui/shared_resources_data_source.cc
new file mode 100644
index 0000000..d460cdd
--- /dev/null
+++ b/chrome/browser/dom_ui/shared_resources_data_source.cc
@@ -0,0 +1,88 @@
+// Copyright (c) 2010 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 "chrome/browser/dom_ui/shared_resources_data_source.h"
+
+#include "app/resource_bundle.h"
+#include "base/singleton.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
+#include "chrome/browser/io_thread.h"
+#include "chrome/common/url_constants.h"
+#include "grit/generated_resources.h"
+#include "grit/shared_resources.h"
+#include "grit/shared_resources_map.h"
+#include "grit/app_resources.h"
+#include "grit/theme_resources.h"
+#include "net/base/mime_util.h"
+
+namespace {
+
+int PathToIDR(const std::string& path) {
+ int idr = -1;
+ if (path == "images/bookmark_bar_folder_mac.png") {
+ idr = IDR_BOOKMARK_BAR_FOLDER;
+ } else if (path == "images/folder_closed.png") {
+ idr = IDR_FOLDER_CLOSED;
+ } else if (path == "images/folder_closed_rtl.png") {
+ idr = IDR_FOLDER_CLOSED_RTL;
+ } else if (path == "images/folder_open.png") {
+ idr = IDR_FOLDER_OPEN;
+ } else if (path == "images/folder_open_rtl.png") {
+ idr = IDR_FOLDER_OPEN_RTL;
+ } else {
+ // The name of the files in the grd list are prefixed with the following
+ // directory:
+ std::string key("shared/");
+ key += path;
+
+ for (size_t i = 0; i < kSharedResourcesSize; ++i) {
+ if (kSharedResources[i].name == key) {
+ idr = kSharedResources[i].value;
+ break;
+ }
+ }
+ }
+
+ return idr;
+}
+
+} // namespace
+
+// static
+void SharedResourcesDataSource::Register() {
+ SharedResourcesDataSource* source = new SharedResourcesDataSource();
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ Singleton<ChromeURLDataManager>::get(),
+ &ChromeURLDataManager::AddDataSource,
+ make_scoped_refptr(source)));
+}
+
+SharedResourcesDataSource::SharedResourcesDataSource()
+ : DataSource(chrome::kChromeUIResourcesHost, NULL) {
+}
+
+SharedResourcesDataSource::~SharedResourcesDataSource() {
+}
+
+void SharedResourcesDataSource::StartDataRequest(const std::string& path,
+ bool is_off_the_record,
+ int request_id) {
+ int idr = PathToIDR(path);
+ DCHECK_NE(-1, idr);
+ const ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ scoped_refptr<RefCountedStaticMemory> bytes(rb.LoadDataResourceBytes(idr));
+ SendResponse(request_id, bytes);
+}
+
+std::string SharedResourcesDataSource::GetMimeType(
+ const std::string& path) const {
+ std::string mime_type;
+ net::GetMimeTypeFromFile(FilePath().AppendASCII(path), &mime_type);
+ return mime_type;
+}
+
diff --git a/chrome/browser/dom_ui/shared_resources_data_source.h b/chrome/browser/dom_ui/shared_resources_data_source.h
new file mode 100644
index 0000000..0dfe83a
--- /dev/null
+++ b/chrome/browser/dom_ui/shared_resources_data_source.h
@@ -0,0 +1,33 @@
+// Copyright (c) 2010 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.
+
+#ifndef CHROME_BROWSER_DOM_UI_SHARED_RESOURCES_DATA_SOURCE_H_
+#define CHROME_BROWSER_DOM_UI_SHARED_RESOURCES_DATA_SOURCE_H_
+
+#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
+
+class GURL;
+class URLRequest;
+class URLRequestJob;
+
+// A DataSource for chrome://resources/ URLs.
+class SharedResourcesDataSource : public ChromeURLDataManager::DataSource {
+ public:
+ // Registers an instance of this data source with the ChromeUrlDataManager.
+ static void Register();
+
+ // Overridden from ChromeURLDataManager::DataSource:
+ virtual void StartDataRequest(const std::string& path,
+ bool is_off_the_record,
+ int request_id);
+ virtual std::string GetMimeType(const std::string&) const;
+
+ private:
+ SharedResourcesDataSource();
+ ~SharedResourcesDataSource();
+
+ DISALLOW_COPY_AND_ASSIGN(SharedResourcesDataSource);
+};
+
+#endif // CHROME_BROWSER_DOM_UI_SHARED_RESOURCES_DATA_SOURCE_H_
diff --git a/chrome/browser/resources/shared_resources.grd b/chrome/browser/resources/shared_resources.grd
new file mode 100644
index 0000000..371aad0
--- /dev/null
+++ b/chrome/browser/resources/shared_resources.grd
@@ -0,0 +1,78 @@
+<?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 -->
+<grit latest_public_release="0" current_release="1">
+ <outputs>
+ <output filename="grit/shared_resources.h" type="rc_header">
+ <emit emit_type='prepend'></emit>
+ </output>
+ <output filename="shared_resources.pak" type="data_package" />
+ <output filename="grit/shared_resources_map.h" type="resource_map_header" />
+ <output filename="grit/shared_resources_map.cc" type="resource_file_map_source" />
+ </outputs>
+ <release seq="1">
+ <includes>
+ <!-- shared/css/ -->
+ <include name="IDR_SHARED_CSS_BUTTON"
+ file="shared/css/button.css" type="BINDATA" />
+ <include name="IDR_SHARED_CSS_LIST"
+ file="shared/css/list.css" type="BINDATA" />
+ <include name="IDR_SHARED_CSS_MENU"
+ file="shared/css/menu.css" type="BINDATA" />
+ <include name="IDR_SHARED_CSS_TREE"
+ file="shared/css/tree.css" type="BINDATA" />
+ <include name="IDR_SHARED_CSS_TREE_JS"
+ file="shared/css/tree.css.js" type="BINDATA" />
+
+ <!-- shared/js/ -->
+ <include name="IDR_SHARED_JS_CLASS_LIST"
+ file="shared/js/class_list.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_CR"
+ file="shared/js/cr.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_I18N_TEMPLATE"
+ file="shared/js/i18n_template.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_LOCAL_STRINGS"
+ file="shared/js/local_strings.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_PARSE_HTML_SUBSET"
+ file="shared/js/parse_html_subset.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_UTIL"
+ file="shared/js/util.js" type="BINDATA" />
+
+ <!-- shared/js/cr -->
+ <include name="IDR_SHARED_JS_CR_EVENT_TARGET"
+ file="shared/js/cr/event_target.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_CR_LINK_CONTROLLER"
+ file="shared/js/cr/link_controller.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_CR_PROMISE"
+ file="shared/js/cr/promise.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_CR_UI"
+ file="shared/js/cr/ui.js" type="BINDATA" />
+
+ <!-- shared/js/cr/ui -->
+ <include name="IDR_SHARED_JS_CR_UI_ARRAY_DATA_MODEL"
+ file="shared/js/cr/ui/array_data_model.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_CR_UI_COMMAND"
+ file="shared/js/cr/ui/command.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_CR_UI_CONTEXT_MENU_HANDLER"
+ file="shared/js/cr/ui/context_menu_handler.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_CR_UI_LIST_ITEM"
+ file="shared/js/cr/ui/list_item.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_CR_UI_LIST"
+ file="shared/js/cr/ui/list.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_CR_UI_LIST_SELECTION_MODEL"
+ file="shared/js/cr/ui/list_selection_model.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_CR_UI_MENU_BUTTON"
+ file="shared/js/cr/ui/menu_button.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_CR_UI_MENU_ITEM"
+ file="shared/js/cr/ui/menu_item.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_CR_UI_MENU"
+ file="shared/js/cr/ui/menu.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_CR_UI_POSITION_UTIL"
+ file="shared/js/cr/ui/position_util.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_CR_UI_SPLITTER"
+ file="shared/js/cr/ui/splitter.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_CR_UI_TREE"
+ file="shared/js/cr/ui/tree.js" type="BINDATA" />
+ </includes>
+ </release>
+</grit>
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 3505c4d..0a59914 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -61,6 +61,7 @@
# it easier for us to reference them internally.
'browser/resources/bookmark_manager_resources.grd',
'browser/resources/net_internals_resources.grd',
+ 'browser/resources/shared_resources.grd'
],
'grit_info_cmd': ['python', '../tools/grit/grit_info.py'],
'grit_cmd': ['python', '../tools/grit/grit.py'],
@@ -1510,6 +1511,7 @@
'pak_inputs': [
'<(grit_out_dir)/bookmark_manager_resources.pak',
'<(grit_out_dir)/net_internals_resources.pak',
+ '<(grit_out_dir)/shared_resources.pak',
],
},
'inputs': [
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index e649a27..a1bca3c 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -16,7 +16,6 @@
'chrome_strings',
'chrome_version_info',
'component_extensions',
- 'domui_shared_resources',
'platform_locale_settings',
'profile_import',
'browser/sync/protocol/sync_proto.gyp:sync_proto_cpp',
@@ -1031,6 +1030,8 @@
'browser/dom_ui/plugins_ui.h',
'browser/dom_ui/remoting_ui.cc',
'browser/dom_ui/remoting_ui.h',
+ 'browser/dom_ui/shared_resources_data_source.cc',
+ 'browser/dom_ui/shared_resources_data_source.h',
'browser/dom_ui/shown_sections_handler.cc',
'browser/dom_ui/shown_sections_handler.h',
'browser/dom_ui/slideshow_ui.cc',
@@ -2707,8 +2708,9 @@
# 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',
+ '<(grit_out_dir)/grit/shared_resources_map.cc',
+ '<(grit_out_dir)/grit/theme_resources_map.cc',
],
'conditions': [
['javascript_engine=="v8"', {
@@ -3402,76 +3404,6 @@
],
},
{
- 'target_name': 'domui_shared_resources',
- 'type': 'none',
- 'msvs_guid': '7BB23C84-71AA-4320-9EE1-9EBCDB04C964',
- # TODO(arv): Once the msvs port supports it, change this to recursively
- # copy the entire directory instead of listing the files.
- # TODO(arv): We also need to allow filters so we do not copy the test
- # files. Tony said that another option would be to run a python script
- # here instead.
- # http://code.google.com/p/gyp/issues/detail?id=143.
- 'copies': [
- {
- 'destination': '<(PRODUCT_DIR)/resources/shared/css',
- 'files': [
- 'browser/resources/shared/css/button.css',
- 'browser/resources/shared/css/list.css',
- 'browser/resources/shared/css/menu.css',
- 'browser/resources/shared/css/tree.css',
- 'browser/resources/shared/css/tree.css.js',
- ]
- },
- {
- 'destination': '<(PRODUCT_DIR)/resources/shared/images',
- 'files': [
- '../app/resources/folder_closed.png',
- '../app/resources/folder_closed_rtl.png',
- '../app/resources/folder_open.png',
- '../app/resources/folder_open_rtl.png',
- 'app/theme/bookmark_bar_folder_mac.png',
- ]
- },
- {
- 'destination': '<(PRODUCT_DIR)/resources/shared/js',
- 'files': [
- 'browser/resources/shared/js/class_list.js',
- 'browser/resources/shared/js/cr.js',
- 'browser/resources/shared/js/i18n_template.js',
- 'browser/resources/shared/js/local_strings.js',
- 'browser/resources/shared/js/parse_html_subset.js',
- 'browser/resources/shared/js/util.js',
- ]
- },
- {
- 'destination': '<(PRODUCT_DIR)/resources/shared/js/cr',
- 'files': [
- 'browser/resources/shared/js/cr/event_target.js',
- 'browser/resources/shared/js/cr/link_controller.js',
- 'browser/resources/shared/js/cr/promise.js',
- 'browser/resources/shared/js/cr/ui.js',
- ]
- },
- {
- 'destination': '<(PRODUCT_DIR)/resources/shared/js/cr/ui',
- 'files': [
- 'browser/resources/shared/js/cr/ui/array_data_model.js',
- 'browser/resources/shared/js/cr/ui/command.js',
- 'browser/resources/shared/js/cr/ui/context_menu_handler.js',
- 'browser/resources/shared/js/cr/ui/list.js',
- 'browser/resources/shared/js/cr/ui/list_item.js',
- 'browser/resources/shared/js/cr/ui/list_selection_model.js',
- 'browser/resources/shared/js/cr/ui/menu.js',
- 'browser/resources/shared/js/cr/ui/menu_button.js',
- 'browser/resources/shared/js/cr/ui/menu_item.js',
- 'browser/resources/shared/js/cr/ui/position_util.js',
- 'browser/resources/shared/js/cr/ui/splitter.js',
- 'browser/resources/shared/js/cr/ui/tree.js',
- ]
- },
- ]
- },
- {
'target_name': 'component_extensions',
'type': 'none',
'msvs_guid': '50B52703-525F-404C-BFE2-C46D3375D73E',
diff --git a/chrome/chrome_dll.gypi b/chrome/chrome_dll.gypi
index 622971c0..50594f1 100644
--- a/chrome/chrome_dll.gypi
+++ b/chrome/chrome_dll.gypi
@@ -381,6 +381,7 @@
'pak_inputs': [
'<(grit_out_dir)/bookmark_manager_resources.pak',
'<(grit_out_dir)/net_internals_resources.pak',
+ '<(grit_out_dir)/shared_resources.pak',
],
},
'inputs': [
diff --git a/chrome/installer/mini_installer/chrome.release b/chrome/installer/mini_installer/chrome.release
index cf5f782..2877457 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\shared\css\*.*: %(VersionDir)s\Resources\shared\css
-Resources\shared\images\*.*: %(VersionDir)s\Resources\shared\images
-Resources\shared\js\*.*: %(VersionDir)s\Resources\shared\js
-Resources\shared\js\cr\*.*: %(VersionDir)s\Resources\shared\js\cr
-Resources\shared\js\cr\ui\*.*: %(VersionDir)s\Resources\shared\js\cr\ui
Resources\Inspector\*.*: %(VersionDir)s\Resources\Inspector
Resources\Inspector\Images\*.*: %(VersionDir)s\Resources\Inspector\Images
Resources\gmail_app\*.*: %(VersionDir)s\Resources\gmail_app