| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/devtools_ui.h" | 5 #include "chrome/browser/ui/webui/devtools_ui.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted_memory.h" | 7 #include "base/memory/ref_counted_memory.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 } | 136 } |
| 137 | 137 |
| 138 void DevToolsDataSource::StartDataRequest( | 138 void DevToolsDataSource::StartDataRequest( |
| 139 const std::string& path, | 139 const std::string& path, |
| 140 int render_process_id, | 140 int render_process_id, |
| 141 int render_frame_id, | 141 int render_frame_id, |
| 142 const content::URLDataSource::GotDataCallback& callback) { | 142 const content::URLDataSource::GotDataCallback& callback) { |
| 143 // Serve request from local bundle. | 143 // Serve request from local bundle. |
| 144 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath); | 144 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath); |
| 145 bundled_path_prefix += "/"; | 145 bundled_path_prefix += "/"; |
| 146 if (base::StartsWithASCII(path, bundled_path_prefix, false)) { | 146 if (base::StartsWith(path, bundled_path_prefix, |
| 147 base::CompareCase::INSENSITIVE_ASCII)) { |
| 147 StartBundledDataRequest(path.substr(bundled_path_prefix.length()), | 148 StartBundledDataRequest(path.substr(bundled_path_prefix.length()), |
| 148 render_process_id, render_frame_id, callback); | 149 render_process_id, render_frame_id, callback); |
| 149 return; | 150 return; |
| 150 } | 151 } |
| 151 | 152 |
| 152 // Serve request from remote location. | 153 // Serve request from remote location. |
| 153 std::string remote_path_prefix(chrome::kChromeUIDevToolsRemotePath); | 154 std::string remote_path_prefix(chrome::kChromeUIDevToolsRemotePath); |
| 154 remote_path_prefix += "/"; | 155 remote_path_prefix += "/"; |
| 155 if (base::StartsWithASCII(path, remote_path_prefix, false)) { | 156 if (base::StartsWith(path, remote_path_prefix, |
| 157 base::CompareCase::INSENSITIVE_ASCII)) { |
| 156 StartRemoteDataRequest(path.substr(remote_path_prefix.length()), | 158 StartRemoteDataRequest(path.substr(remote_path_prefix.length()), |
| 157 render_process_id, render_frame_id, callback); | 159 render_process_id, render_frame_id, callback); |
| 158 return; | 160 return; |
| 159 } | 161 } |
| 160 | 162 |
| 161 callback.Run(NULL); | 163 callback.Run(NULL); |
| 162 } | 164 } |
| 163 | 165 |
| 164 std::string DevToolsDataSource::GetMimeType(const std::string& path) const { | 166 std::string DevToolsDataSource::GetMimeType(const std::string& path) const { |
| 165 return GetMimeTypeForPath(path); | 167 return GetMimeTypeForPath(path); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 bindings_(web_ui->GetWebContents()) { | 257 bindings_(web_ui->GetWebContents()) { |
| 256 web_ui->SetBindings(0); | 258 web_ui->SetBindings(0); |
| 257 Profile* profile = Profile::FromWebUI(web_ui); | 259 Profile* profile = Profile::FromWebUI(web_ui); |
| 258 content::URLDataSource::Add( | 260 content::URLDataSource::Add( |
| 259 profile, | 261 profile, |
| 260 new DevToolsDataSource(profile->GetRequestContext())); | 262 new DevToolsDataSource(profile->GetRequestContext())); |
| 261 } | 263 } |
| 262 | 264 |
| 263 DevToolsUI::~DevToolsUI() { | 265 DevToolsUI::~DevToolsUI() { |
| 264 } | 266 } |
| OLD | NEW |