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

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: 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 0b2184a18b58ec7ccf556edf24f11ec7f56a32b9..d036f6c633f029d632f049d73f5542c6d024ca23 100644
--- a/extensions/renderer/user_script_injector.cc
+++ b/extensions/renderer/user_script_injector.cc
@@ -65,19 +65,22 @@ struct GreasemonkeyApiJsString {
blink::WebScriptSource GetSource() const;
private:
- std::string source_;
+ // Data is owned by ResourceBundle.
Devlin 2016/08/20 01:58:36 Not quite true, right? fromUTF8() still performs a
lazyboy 2016/08/22 17:09:50 That's right. Removed the comment. fromUTF8() sti
+ 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