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

Unified Diff: extensions/renderer/user_script_injector.cc

Issue 2258183003: Make GreasemonkeyApiJsString truly singleton. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments + sync Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/user_script_injector.cc
diff --git a/extensions/renderer/user_script_injector.cc b/extensions/renderer/user_script_injector.cc
index 9b431dbae4e6573742e8391580ba413995179b30..da0c760e54425c7c329438150ed892501b18c6d5 100644
--- a/extensions/renderer/user_script_injector.cc
+++ b/extensions/renderer/user_script_injector.cc
@@ -65,19 +65,21 @@ struct GreasemonkeyApiJsString {
blink::WebScriptSource GetSource() const;
private:
- std::string source_;
+ blink::WebString source_;
};
// The below constructor, monstrous as it is, just makes a WebScriptSource from
// the GreasemonkeyApiJs resource.
-GreasemonkeyApiJsString::GreasemonkeyApiJsString()
- : source_(ResourceBundle::GetSharedInstance()
- .GetRawDataResource(IDR_GREASEMONKEY_API_JS)
- .as_string()) {
+GreasemonkeyApiJsString::GreasemonkeyApiJsString() {
+ base::StringPiece source_piece =
+ ResourceBundle::GetSharedInstance().GetRawDataResource(
+ IDR_GREASEMONKEY_API_JS);
+ source_ =
+ blink::WebString::fromUTF8(source_piece.data(), source_piece.length());
}
blink::WebScriptSource GreasemonkeyApiJsString::GetSource() const {
- return blink::WebScriptSource(blink::WebString::fromUTF8(source_));
+ return blink::WebScriptSource(source_);
}
base::LazyInstance<GreasemonkeyApiJsString> g_greasemonkey_api =
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698