OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/renderer/user_script_set.h" | 5 #include "extensions/renderer/user_script_set.h" |
6 | 6 |
7 #include "content/public/common/url_constants.h" | 7 #include "content/public/common/url_constants.h" |
8 #include "content/public/renderer/render_thread.h" | 8 #include "content/public/renderer/render_thread.h" |
9 #include "extensions/common/extension.h" | 9 #include "extensions/common/extension.h" |
10 #include "extensions/common/extension_set.h" | 10 #include "extensions/common/extension_set.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 scripts_.clear(); | 115 scripts_.clear(); |
116 scripts_.reserve(num_scripts); | 116 scripts_.reserve(num_scripts); |
117 for (uint64 i = 0; i < num_scripts; ++i) { | 117 for (uint64 i = 0; i < num_scripts; ++i) { |
118 scoped_ptr<UserScript> script(new UserScript()); | 118 scoped_ptr<UserScript> script(new UserScript()); |
119 script->Unpickle(pickle, &iter); | 119 script->Unpickle(pickle, &iter); |
120 | 120 |
121 // Note that this is a pointer into shared memory. We don't own it. It gets | 121 // Note that this is a pointer into shared memory. We don't own it. It gets |
122 // cleared up when the last renderer or browser process drops their | 122 // cleared up when the last renderer or browser process drops their |
123 // reference to the shared memory. | 123 // reference to the shared memory. |
124 for (size_t j = 0; j < script->js_scripts().size(); ++j) { | 124 for (size_t j = 0; j < script->js_scripts().size(); ++j) { |
125 const char* body = NULL; | 125 const char* body = nullptr; |
126 int body_length = 0; | 126 int body_length = 0; |
127 CHECK(pickle.ReadData(&iter, &body, &body_length)); | 127 CHECK(pickle.ReadData(&iter, &body, &body_length)); |
128 script->js_scripts()[j].set_external_content( | 128 script->js_scripts()[j].set_external_content( |
129 base::StringPiece(body, body_length)); | 129 base::StringPiece(body, body_length)); |
130 } | 130 } |
131 for (size_t j = 0; j < script->css_scripts().size(); ++j) { | 131 for (size_t j = 0; j < script->css_scripts().size(); ++j) { |
132 const char* body = NULL; | 132 const char* body = nullptr; |
133 int body_length = 0; | 133 int body_length = 0; |
134 CHECK(pickle.ReadData(&iter, &body, &body_length)); | 134 CHECK(pickle.ReadData(&iter, &body, &body_length)); |
135 script->css_scripts()[j].set_external_content( | 135 script->css_scripts()[j].set_external_content( |
136 base::StringPiece(body, body_length)); | 136 base::StringPiece(body, body_length)); |
137 } | 137 } |
138 | 138 |
139 if (only_inject_incognito && !script->is_incognito_enabled()) | 139 if (only_inject_incognito && !script->is_incognito_enabled()) |
140 continue; // This script shouldn't run in an incognito tab. | 140 continue; // This script shouldn't run in an incognito tab. |
141 | 141 |
142 scripts_.push_back(script.release()); | 142 scripts_.push_back(script.release()); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 injector.Pass(), | 210 injector.Pass(), |
211 web_frame, | 211 web_frame, |
212 extension->id(), | 212 extension->id(), |
213 run_location, | 213 run_location, |
214 tab_id)); | 214 tab_id)); |
215 } | 215 } |
216 return injection.Pass(); | 216 return injection.Pass(); |
217 } | 217 } |
218 | 218 |
219 } // namespace extensions | 219 } // namespace extensions |
OLD | NEW |