| OLD | NEW |
| 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/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/histogram.h" | 9 #include "base/histogram.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 182 } |
| 183 } | 183 } |
| 184 if (script->run_location() == location) { | 184 if (script->run_location() == location) { |
| 185 num_scripts += script->js_scripts().size(); | 185 num_scripts += script->js_scripts().size(); |
| 186 for (size_t j = 0; j < script->js_scripts().size(); ++j) { | 186 for (size_t j = 0; j < script->js_scripts().size(); ++j) { |
| 187 UserScript::File &file = script->js_scripts()[j]; | 187 UserScript::File &file = script->js_scripts()[j]; |
| 188 std::string content = file.GetContent().as_string(); | 188 std::string content = file.GetContent().as_string(); |
| 189 | 189 |
| 190 // We add this dumb function wrapper for standalone user script to | 190 // We add this dumb function wrapper for standalone user script to |
| 191 // emulate what Greasemonkey does. | 191 // emulate what Greasemonkey does. |
| 192 if (script->is_standalone()) { | 192 if (script->is_standalone() || script->emulate_greasemonkey()) { |
| 193 content.insert(0, kUserScriptHead); | 193 content.insert(0, kUserScriptHead); |
| 194 content += kUserScriptTail; | 194 content += kUserScriptTail; |
| 195 } | 195 } |
| 196 sources.push_back( | 196 sources.push_back( |
| 197 WebScriptSource(WebString::fromUTF8(content), file.url())); | 197 WebScriptSource(WebString::fromUTF8(content), file.url())); |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 | 200 |
| 201 if (!sources.empty()) { | 201 if (!sources.empty()) { |
| 202 int isolated_world_id = 0; | 202 int isolated_world_id = 0; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 if (num_scripts) | 238 if (num_scripts) |
| 239 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); | 239 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); |
| 240 } else { | 240 } else { |
| 241 NOTREACHED(); | 241 NOTREACHED(); |
| 242 } | 242 } |
| 243 | 243 |
| 244 LOG(INFO) << "Injected " << num_scripts << " scripts and " << num_css << | 244 LOG(INFO) << "Injected " << num_scripts << " scripts and " << num_css << |
| 245 "css files into " << frame->url().spec().data(); | 245 "css files into " << frame->url().spec().data(); |
| 246 return true; | 246 return true; |
| 247 } | 247 } |
| OLD | NEW |