| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/extensions/user_script_master.h" | 5 #include "chrome/browser/extensions/user_script_master.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 // Drop our self-reference. | 158 // Drop our self-reference. |
| 159 // Balances StartLoad(). | 159 // Balances StartLoad(). |
| 160 Release(); | 160 Release(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 static bool LoadScriptContent(UserScript::File* script_file) { | 163 static bool LoadScriptContent(UserScript::File* script_file) { |
| 164 std::string content; | 164 std::string content; |
| 165 const FilePath& path = ExtensionResource::GetFilePath( | 165 const FilePath& path = ExtensionResource::GetFilePath( |
| 166 script_file->extension_root(), script_file->relative_path()); | 166 script_file->extension_root(), script_file->relative_path()); |
| 167 if (path.empty() || !file_util::ReadFileToString(path, &content)) { | 167 if (path.empty()) { |
| 168 LOG(WARNING) << "Failed to get file path to " |
| 169 << script_file->relative_path().value() << " from " |
| 170 << script_file->extension_root().value(); |
| 171 return false; |
| 172 } |
| 173 if (!file_util::ReadFileToString(path, &content)) { |
| 168 LOG(WARNING) << "Failed to load user script file: " << path.value(); | 174 LOG(WARNING) << "Failed to load user script file: " << path.value(); |
| 169 return false; | 175 return false; |
| 170 } | 176 } |
| 171 | 177 |
| 172 // Remove BOM from the content. | 178 // Remove BOM from the content. |
| 173 std::string::size_type index = content.find(kUtf8ByteOrderMark); | 179 std::string::size_type index = content.find(kUtf8ByteOrderMark); |
| 174 if (index == 0) { | 180 if (index == 0) { |
| 175 script_file->set_content(content.substr(strlen(kUtf8ByteOrderMark))); | 181 script_file->set_content(content.substr(strlen(kUtf8ByteOrderMark))); |
| 176 } else { | 182 } else { |
| 177 script_file->set_content(content); | 183 script_file->set_content(content); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 if (!handle) | 380 if (!handle) |
| 375 return; | 381 return; |
| 376 | 382 |
| 377 base::SharedMemoryHandle handle_for_process; | 383 base::SharedMemoryHandle handle_for_process; |
| 378 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) | 384 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) |
| 379 return; // This can legitimately fail if the renderer asserts at startup. | 385 return; // This can legitimately fail if the renderer asserts at startup. |
| 380 | 386 |
| 381 if (base::SharedMemory::IsHandleValid(handle_for_process)) | 387 if (base::SharedMemory::IsHandleValid(handle_for_process)) |
| 382 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process)); | 388 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process)); |
| 383 } | 389 } |
| OLD | NEW |