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

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

Issue 63056: TBR: Revert "Implement chromium.self in content scripts..." (Closed)
Patch Set: Created 11 years, 8 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
diff --git a/chrome/browser/extensions/extension.cc b/chrome/browser/extensions/extension.cc
index 1aeaeaab67229608fc479c79caf011ac1a3cb298..d8ab40379d0c0fde26f59ff8b724fc6bde4ea053 100644
--- a/chrome/browser/extensions/extension.cc
+++ b/chrome/browser/extensions/extension.cc
@@ -103,6 +103,21 @@ Extension::Extension(const Extension& rhs)
theme_paths_(rhs.theme_paths_) {
}
+const GURL& Extension::url() {
+ if (!extension_url_.is_valid())
+ extension_url_ = GURL(std::string(chrome::kExtensionScheme) +
+ chrome::kStandardSchemeSeparator + id_ + "/");
+
+ return extension_url_;
+}
+
+void Extension::set_id(const std::string& id) {
+ id_ = id;
+
+ // Reset url_ so that it gets reinitialized next time.
+ extension_url_ = GURL();
+}
+
const std::string Extension::VersionString() const {
return version_->GetString();
}
@@ -320,9 +335,10 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
return true;
}
-bool Extension::InitFromValue(const DictionaryValue& source, bool require_id,
+bool Extension::InitFromValue(const DictionaryValue& source,
std::string* error) {
- // Initialize id.
+ // Initialize id. The ID is not required here because we don't require IDs for
+ // extensions used with --load-extension.
if (source.HasKey(kIdKey)) {
if (!source.GetString(kIdKey, &id_)) {
*error = kInvalidIdError;
@@ -340,23 +356,8 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_id,
*error = kInvalidIdError;
return false;
}
- } else if (require_id) {
- *error = kInvalidIdError;
- return false;
- } else {
- // Generate a random ID
- static int counter = 0;
- id_ = StringPrintf("%x", counter);
- ++counter;
-
- // pad the string out to 40 chars with zeroes.
- id_.insert(0, 40 - id_.length(), '0');
}
- // Initialize the URL.
- extension_url_ = GURL(std::string(chrome::kExtensionScheme) +
- chrome::kStandardSchemeSeparator + id_ + "/");
-
// Initialize version.
std::string version_str;
if (!source.GetString(kVersionKey, &version_str)) {
@@ -456,7 +457,6 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_id,
UserScript script;
if (!LoadUserScriptHelper(content_script, i, error, &script))
return false; // Failed to parse script context definition
- script.set_extension_id(id());
content_scripts_.push_back(script);
}
}
« no previous file with comments | « chrome/browser/extensions/extension.h ('k') | chrome/browser/extensions/extension_content_script_inject_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698