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 "chrome/browser/extensions/user_script_loader.h" | 5 #include "chrome/browser/extensions/user_script_loader.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 LOG(WARNING) << "Failed to get file path to " | 77 LOG(WARNING) << "Failed to get file path to " |
78 << script_file->relative_path().value() << " from " | 78 << script_file->relative_path().value() << " from " |
79 << script_file->extension_root().value(); | 79 << script_file->extension_root().value(); |
80 return false; | 80 return false; |
81 } | 81 } |
82 } else { | 82 } else { |
83 if (!base::ReadFileToString(path, &content)) { | 83 if (!base::ReadFileToString(path, &content)) { |
84 LOG(WARNING) << "Failed to load user script file: " << path.value(); | 84 LOG(WARNING) << "Failed to load user script file: " << path.value(); |
85 return false; | 85 return false; |
86 } | 86 } |
87 if (verifier) { | 87 if (verifier.get()) { |
88 content::BrowserThread::PostTask(content::BrowserThread::IO, | 88 content::BrowserThread::PostTask(content::BrowserThread::IO, |
89 FROM_HERE, | 89 FROM_HERE, |
90 base::Bind(&VerifyContent, | 90 base::Bind(&VerifyContent, |
91 verifier, | 91 verifier, |
92 extension_id, | 92 extension_id, |
93 script_file->extension_root(), | 93 script_file->extension_root(), |
94 script_file->relative_path(), | 94 script_file->relative_path(), |
95 content)); | 95 content)); |
96 } | 96 } |
97 } | 97 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 /*read_only=*/true)); | 200 /*read_only=*/true)); |
201 } | 201 } |
202 | 202 |
203 void LoadScriptsOnFileThread(scoped_ptr<UserScriptList> user_scripts, | 203 void LoadScriptsOnFileThread(scoped_ptr<UserScriptList> user_scripts, |
204 const ExtensionsInfo& extensions_info, | 204 const ExtensionsInfo& extensions_info, |
205 const std::set<int>& added_script_ids, | 205 const std::set<int>& added_script_ids, |
206 scoped_refptr<ContentVerifier> verifier, | 206 scoped_refptr<ContentVerifier> verifier, |
207 LoadScriptsCallback callback) { | 207 LoadScriptsCallback callback) { |
208 DCHECK(user_scripts.get()); | 208 DCHECK(user_scripts.get()); |
209 LoadUserScripts( | 209 LoadUserScripts( |
210 user_scripts.get(), extensions_info, added_script_ids, verifier); | 210 user_scripts.get(), extensions_info, added_script_ids, verifier.get()); |
211 scoped_ptr<base::SharedMemory> memory = Serialize(*user_scripts); | 211 scoped_ptr<base::SharedMemory> memory = Serialize(*user_scripts); |
212 BrowserThread::PostTask( | 212 BrowserThread::PostTask( |
213 BrowserThread::UI, | 213 BrowserThread::UI, |
214 FROM_HERE, | 214 FROM_HERE, |
215 base::Bind(callback, base::Passed(&user_scripts), base::Passed(&memory))); | 215 base::Bind(callback, base::Passed(&user_scripts), base::Passed(&memory))); |
216 } | 216 } |
217 | 217 |
218 // Helper function to parse greasesmonkey headers | 218 // Helper function to parse greasesmonkey headers |
219 bool GetDeclarationValue(const base::StringPiece& line, | 219 bool GetDeclarationValue(const base::StringPiece& line, |
220 const base::StringPiece& prefix, | 220 const base::StringPiece& prefix, |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 // which leads to the above lookup failing. In this case, just continue. | 595 // which leads to the above lookup failing. In this case, just continue. |
596 if (!extension) | 596 if (!extension) |
597 continue; | 597 continue; |
598 extensions_info_[*it] = ExtensionSet::ExtensionPathAndDefaultLocale( | 598 extensions_info_[*it] = ExtensionSet::ExtensionPathAndDefaultLocale( |
599 extension->path(), LocaleInfo::GetDefaultLocale(extension)); | 599 extension->path(), LocaleInfo::GetDefaultLocale(extension)); |
600 } | 600 } |
601 } | 601 } |
602 } | 602 } |
603 | 603 |
604 } // namespace extensions | 604 } // namespace extensions |
OLD | NEW |