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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #else | 42 #else |
43 // URL causing the DevTools window to display a plain text warning. | 43 // URL causing the DevTools window to display a plain text warning. |
44 const char kFallbackFrontendURL[] = | 44 const char kFallbackFrontendURL[] = |
45 "data:text/plain,Cannot load DevTools frontend from an untrusted origin"; | 45 "data:text/plain,Cannot load DevTools frontend from an untrusted origin"; |
46 #endif // defined(DEBUG_DEVTOOLS) | 46 #endif // defined(DEBUG_DEVTOOLS) |
47 | 47 |
48 // DevToolsDataSource --------------------------------------------------------- | 48 // DevToolsDataSource --------------------------------------------------------- |
49 | 49 |
50 std::string GetMimeTypeForPath(const std::string& path) { | 50 std::string GetMimeTypeForPath(const std::string& path) { |
51 std::string filename = PathWithoutParams(path); | 51 std::string filename = PathWithoutParams(path); |
52 if (base::EndsWith(filename, ".html", false)) { | 52 if (base::EndsWith(filename, ".html", base::CompareCase::INSENSITIVE_ASCII)) { |
53 return "text/html"; | 53 return "text/html"; |
54 } else if (base::EndsWith(filename, ".css", false)) { | 54 } else if (base::EndsWith(filename, ".css", |
| 55 base::CompareCase::INSENSITIVE_ASCII)) { |
55 return "text/css"; | 56 return "text/css"; |
56 } else if (base::EndsWith(filename, ".js", false)) { | 57 } else if (base::EndsWith(filename, ".js", |
| 58 base::CompareCase::INSENSITIVE_ASCII)) { |
57 return "application/javascript"; | 59 return "application/javascript"; |
58 } else if (base::EndsWith(filename, ".png", false)) { | 60 } else if (base::EndsWith(filename, ".png", |
| 61 base::CompareCase::INSENSITIVE_ASCII)) { |
59 return "image/png"; | 62 return "image/png"; |
60 } else if (base::EndsWith(filename, ".gif", false)) { | 63 } else if (base::EndsWith(filename, ".gif", |
| 64 base::CompareCase::INSENSITIVE_ASCII)) { |
61 return "image/gif"; | 65 return "image/gif"; |
62 } else if (base::EndsWith(filename, ".svg", false)) { | 66 } else if (base::EndsWith(filename, ".svg", |
| 67 base::CompareCase::INSENSITIVE_ASCII)) { |
63 return "image/svg+xml"; | 68 return "image/svg+xml"; |
64 } else if (base::EndsWith(filename, ".manifest", false)) { | 69 } else if (base::EndsWith(filename, ".manifest", |
| 70 base::CompareCase::INSENSITIVE_ASCII)) { |
65 return "text/cache-manifest"; | 71 return "text/cache-manifest"; |
66 } | 72 } |
67 return "text/html"; | 73 return "text/html"; |
68 } | 74 } |
69 | 75 |
70 // An URLDataSource implementation that handles chrome-devtools://devtools/ | 76 // An URLDataSource implementation that handles chrome-devtools://devtools/ |
71 // requests. Three types of requests could be handled based on the URL path: | 77 // requests. Three types of requests could be handled based on the URL path: |
72 // 1. /bundled/: bundled DevTools frontend is served. | 78 // 1. /bundled/: bundled DevTools frontend is served. |
73 // 2. /remote/: remote DevTools frontend is served from App Engine. | 79 // 2. /remote/: remote DevTools frontend is served from App Engine. |
74 class DevToolsDataSource : public content::URLDataSource, | 80 class DevToolsDataSource : public content::URLDataSource, |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 bindings_(web_ui->GetWebContents()) { | 263 bindings_(web_ui->GetWebContents()) { |
258 web_ui->SetBindings(0); | 264 web_ui->SetBindings(0); |
259 Profile* profile = Profile::FromWebUI(web_ui); | 265 Profile* profile = Profile::FromWebUI(web_ui); |
260 content::URLDataSource::Add( | 266 content::URLDataSource::Add( |
261 profile, | 267 profile, |
262 new DevToolsDataSource(profile->GetRequestContext())); | 268 new DevToolsDataSource(profile->GetRequestContext())); |
263 } | 269 } |
264 | 270 |
265 DevToolsUI::~DevToolsUI() { | 271 DevToolsUI::~DevToolsUI() { |
266 } | 272 } |
OLD | NEW |