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

Unified Diff: chrome/browser/extensions/extension.cc

Issue 40042: Add trivial theming support in extensions.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months 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: chrome/browser/extensions/extension.cc
===================================================================
--- chrome/browser/extensions/extension.cc (revision 10888)
+++ chrome/browser/extensions/extension.cc (working copy)
@@ -9,6 +9,7 @@
#include "base/string_util.h"
#include "net/base/net_util.h"
#include "chrome/common/extensions/user_script.h"
+#include "chrome/common/resource_bundle.h"
#include "chrome/common/url_constants.h"
const char Extension::kManifestFilename[] = "manifest.json";
@@ -24,6 +25,7 @@
const wchar_t* Extension::kVersionKey = L"version";
const wchar_t* Extension::kZipHashKey = L"zip_hash";
const wchar_t* Extension::kPluginsDirKey = L"plugins_dir";
+const wchar_t* Extension::kThemeKey = L"theme";
const char* Extension::kRunAtDocumentStartValue = "document_start";
const char* Extension::kRunAtDocumentEndValue = "document_end";
@@ -71,6 +73,19 @@
const size_t Extension::kIdSize = 20; // SHA1 (160 bits) == 20 bytes
+Extension::Extension(const Extension& rhs) :
+ path_(rhs.path_),
+ extension_url_(rhs.extension_url_),
+ id_(rhs.id_),
+ version_(new Version(*rhs.version_)),
+ name_(rhs.name_),
+ description_(rhs.description_),
+ content_scripts_(rhs.content_scripts_),
+ plugins_dir_(rhs.plugins_dir_),
+ zip_hash_(rhs.zip_hash_),
+ theme_paths_(rhs.theme_paths_) {
+}
+
const std::string Extension::VersionString() const {
return version_->GetString();
}
@@ -87,6 +102,14 @@
return ret_val;
}
+FilePath Extension::GetThemeResourcePath(const int resource_id) {
+ std::wstring id = IntToWString(resource_id);
+ std::string path = theme_paths_[id];
+ if (path.size())
+ return path_.AppendASCII(path.c_str());
+ return FilePath();
+}
+
// static
FilePath Extension::GetResourcePath(const FilePath& extension_path,
const std::string& relative_path) {
@@ -237,6 +260,22 @@
plugins_dir_ = path_.AppendASCII(plugins_dir);
}
+ if (source.HasKey(kThemeKey)) {
+ DictionaryValue* dict_value;
+ if (source.GetDictionary(kThemeKey, &dict_value)) {
+ DictionaryValue::key_iterator iter = dict_value->begin_keys();
+ while (iter != dict_value->end_keys()) {
+ std::string val;
+ if (dict_value->GetString(*iter, &val)) {
+ std::wstring id = *iter;
+ theme_paths_[id] = val;
+ }
+ ++iter;
+ }
+ ResourceBundle::GetSharedInstance().SetThemeExtension(*this);
+ }
+ }
+
// Initialize content scripts (optional).
if (source.HasKey(kContentScriptsKey)) {
ListValue* list_value;

Powered by Google App Engine
This is Rietveld 408576698