| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/browser/web_ui_user_script_loader.h" | 5 #include "extensions/browser/web_ui_user_script_loader.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "content/public/browser/browser_context.h" | 9 #include "content/public/browser/browser_context.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 int render_view_id) { | 109 int render_view_id) { |
| 110 for (extensions::UserScript::File& file : *script_files) { | 110 for (extensions::UserScript::File& file : *script_files) { |
| 111 if (file.GetContent().empty()) { | 111 if (file.GetContent().empty()) { |
| 112 // The WebUIUserScriptLoader owns these WebUIURLFetchers. Once the | 112 // The WebUIUserScriptLoader owns these WebUIURLFetchers. Once the |
| 113 // loader is destroyed, all the fetchers will be destroyed. Therefore, | 113 // loader is destroyed, all the fetchers will be destroyed. Therefore, |
| 114 // we are sure it is safe to use base::Unretained(this) here. | 114 // we are sure it is safe to use base::Unretained(this) here. |
| 115 scoped_ptr<WebUIURLFetcher> fetcher(new WebUIURLFetcher( | 115 scoped_ptr<WebUIURLFetcher> fetcher(new WebUIURLFetcher( |
| 116 browser_context, render_process_id, render_view_id, file.url(), | 116 browser_context, render_process_id, render_view_id, file.url(), |
| 117 base::Bind(&WebUIUserScriptLoader::OnSingleWebUIURLFetchComplete, | 117 base::Bind(&WebUIUserScriptLoader::OnSingleWebUIURLFetchComplete, |
| 118 base::Unretained(this), &file))); | 118 base::Unretained(this), &file))); |
| 119 fetchers_.push_back(fetcher.release()); | 119 fetchers_.push_back(fetcher.Pass()); |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 void WebUIUserScriptLoader::OnSingleWebUIURLFetchComplete( | 124 void WebUIUserScriptLoader::OnSingleWebUIURLFetchComplete( |
| 125 extensions::UserScript::File* script_file, | 125 extensions::UserScript::File* script_file, |
| 126 bool success, | 126 bool success, |
| 127 const std::string& data) { | 127 const std::string& data) { |
| 128 if (success) { | 128 if (success) { |
| 129 // Remove BOM from the content. | 129 // Remove BOM from the content. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 void WebUIUserScriptLoader::OnWebUIURLFetchComplete() { | 145 void WebUIUserScriptLoader::OnWebUIURLFetchComplete() { |
| 146 content::BrowserThread::PostTask( | 146 content::BrowserThread::PostTask( |
| 147 content::BrowserThread::FILE, FROM_HERE, | 147 content::BrowserThread::FILE, FROM_HERE, |
| 148 base::Bind(&SerializeOnFileThread, base::Passed(&user_scripts_cache_), | 148 base::Bind(&SerializeOnFileThread, base::Passed(&user_scripts_cache_), |
| 149 scripts_loaded_callback_)); | 149 scripts_loaded_callback_)); |
| 150 scripts_loaded_callback_.Reset(); | 150 scripts_loaded_callback_.Reset(); |
| 151 } | 151 } |
| OLD | NEW |