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

Side by Side Diff: chrome/renderer/user_script_slave.cc

Issue 204022: ExtensionShelf now uses the BookmarkExtensionBackground, just like the Bookma... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/render_view.cc ('k') | webkit/api/public/WebFrame.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/user_script_slave.h" 5 #include "chrome/renderer/user_script_slave.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "base/histogram.h" 8 #include "base/histogram.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/perftimer.h" 10 #include "base/perftimer.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 UserScript* script = scripts_[i]; 123 UserScript* script = scripts_[i];
124 if (!script->MatchesUrl(frame->url())) 124 if (!script->MatchesUrl(frame->url()))
125 continue; // This frame doesn't match the script url pattern, skip it. 125 continue; // This frame doesn't match the script url pattern, skip it.
126 126
127 ++num_matched; 127 ++num_matched;
128 // CSS files are always injected on document start before js scripts. 128 // CSS files are always injected on document start before js scripts.
129 if (location == UserScript::DOCUMENT_START) { 129 if (location == UserScript::DOCUMENT_START) {
130 for (size_t j = 0; j < script->css_scripts().size(); ++j) { 130 for (size_t j = 0; j < script->css_scripts().size(); ++j) {
131 UserScript::File& file = script->css_scripts()[j]; 131 UserScript::File& file = script->css_scripts()[j];
132 frame->insertStyleText( 132 frame->insertStyleText(
133 WebString::fromUTF8(file.GetContent().as_string())); 133 WebString::fromUTF8(file.GetContent().as_string()), WebString());
134 } 134 }
135 } 135 }
136 if (script->run_location() == location) { 136 if (script->run_location() == location) {
137 for (size_t j = 0; j < script->js_scripts().size(); ++j) { 137 for (size_t j = 0; j < script->js_scripts().size(); ++j) {
138 UserScript::File &file = script->js_scripts()[j]; 138 UserScript::File &file = script->js_scripts()[j];
139 std::string content = file.GetContent().as_string(); 139 std::string content = file.GetContent().as_string();
140 140
141 // We add this dumb function wrapper for standalone user script to 141 // We add this dumb function wrapper for standalone user script to
142 // emulate what Greasemonkey does. 142 // emulate what Greasemonkey does.
143 if (script->is_standalone()) { 143 if (script->is_standalone()) {
(...skipping 29 matching lines...) Expand all
173 HISTOGRAM_TIMES("UserScripts:DocStart:Time", timer.Elapsed()); 173 HISTOGRAM_TIMES("UserScripts:DocStart:Time", timer.Elapsed());
174 } else { 174 } else {
175 HISTOGRAM_COUNTS_100("UserScripts:DocEnd:Count", num_matched); 175 HISTOGRAM_COUNTS_100("UserScripts:DocEnd:Count", num_matched);
176 HISTOGRAM_TIMES("UserScripts:DocEnd:Time", timer.Elapsed()); 176 HISTOGRAM_TIMES("UserScripts:DocEnd:Time", timer.Elapsed());
177 } 177 }
178 178
179 LOG(INFO) << "Injected " << num_matched << " user scripts into " << 179 LOG(INFO) << "Injected " << num_matched << " user scripts into " <<
180 frame->url().spec().data(); 180 frame->url().spec().data();
181 return true; 181 return true;
182 } 182 }
OLDNEW
« no previous file with comments | « chrome/renderer/render_view.cc ('k') | webkit/api/public/WebFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698