| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 std::string PathWithoutParams(const std::string& path) { | 38 std::string PathWithoutParams(const std::string& path) { |
| 39 return GURL(std::string("chrome-devtools://devtools/") + path) | 39 return GURL(std::string("chrome-devtools://devtools/") + path) |
| 40 .path().substr(1); | 40 .path().substr(1); |
| 41 } | 41 } |
| 42 | 42 |
| 43 const char kHttpNotFound[] = "HTTP/1.1 404 Not Found\n\n"; | 43 const char kHttpNotFound[] = "HTTP/1.1 404 Not Found\n\n"; |
| 44 | 44 |
| 45 #if BUILDFLAG(DEBUG_DEVTOOLS) | |
| 46 // Local frontend url provided by InspectUI. | |
| 47 const char kFallbackFrontendURL[] = | |
| 48 "chrome-devtools://devtools/bundled/inspector.html"; | |
| 49 #else | |
| 50 // URL causing the DevTools window to display a plain text warning. | |
| 51 const char kFallbackFrontendURL[] = | |
| 52 "data:text/plain,Cannot load DevTools frontend from an untrusted origin"; | |
| 53 #endif // BUILDFLAG(DEBUG_DEVTOOLS) | |
| 54 | |
| 55 | |
| 56 // DevToolsDataSource --------------------------------------------------------- | 45 // DevToolsDataSource --------------------------------------------------------- |
| 57 | 46 |
| 58 std::string GetMimeTypeForPath(const std::string& path) { | 47 std::string GetMimeTypeForPath(const std::string& path) { |
| 59 std::string filename = PathWithoutParams(path); | 48 std::string filename = PathWithoutParams(path); |
| 60 if (base::EndsWith(filename, ".html", base::CompareCase::INSENSITIVE_ASCII)) { | 49 if (base::EndsWith(filename, ".html", base::CompareCase::INSENSITIVE_ASCII)) { |
| 61 return "text/html"; | 50 return "text/html"; |
| 62 } else if (base::EndsWith(filename, ".css", | 51 } else if (base::EndsWith(filename, ".css", |
| 63 base::CompareCase::INSENSITIVE_ASCII)) { | 52 base::CompareCase::INSENSITIVE_ASCII)) { |
| 64 return "text/css"; | 53 return "text/css"; |
| 65 } else if (base::EndsWith(filename, ".js", | 54 } else if (base::EndsWith(filename, ".js", |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 } // namespace | 319 } // namespace |
| 331 | 320 |
| 332 // DevToolsUI ----------------------------------------------------------------- | 321 // DevToolsUI ----------------------------------------------------------------- |
| 333 | 322 |
| 334 // static | 323 // static |
| 335 GURL DevToolsUI::GetProxyURL(const std::string& frontend_url) { | 324 GURL DevToolsUI::GetProxyURL(const std::string& frontend_url) { |
| 336 GURL url(frontend_url); | 325 GURL url(frontend_url); |
| 337 if (url.scheme() == content::kChromeDevToolsScheme && | 326 if (url.scheme() == content::kChromeDevToolsScheme && |
| 338 url.host() == chrome::kChromeUIDevToolsHost) | 327 url.host() == chrome::kChromeUIDevToolsHost) |
| 339 return GURL(); | 328 return GURL(); |
| 340 | |
| 341 if (!url.is_valid() || url.host() != kRemoteFrontendDomain) | 329 if (!url.is_valid() || url.host() != kRemoteFrontendDomain) |
| 342 return GURL(kFallbackFrontendURL); | 330 return GURL(); |
| 343 return GURL(base::StringPrintf("%s://%s/%s/%s", | 331 return GURL(base::StringPrintf("%s://%s/%s/%s", |
| 344 content::kChromeDevToolsScheme, | 332 content::kChromeDevToolsScheme, |
| 345 chrome::kChromeUIDevToolsHost, | 333 chrome::kChromeUIDevToolsHost, |
| 346 chrome::kChromeUIDevToolsRemotePath, | 334 chrome::kChromeUIDevToolsRemotePath, |
| 347 url.path().substr(1).c_str())); | 335 url.path().substr(1).c_str())); |
| 348 } | 336 } |
| 349 | 337 |
| 350 // static | 338 // static |
| 351 GURL DevToolsUI::GetRemoteBaseURL() { | 339 GURL DevToolsUI::GetRemoteBaseURL() { |
| 352 return GURL(base::StringPrintf( | 340 return GURL(base::StringPrintf( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 367 if (!profile->IsOffTheRecord()) | 355 if (!profile->IsOffTheRecord()) |
| 368 return; | 356 return; |
| 369 GURL url = web_ui->GetWebContents()->GetVisibleURL(); | 357 GURL url = web_ui->GetWebContents()->GetVisibleURL(); |
| 370 GURL site = content::SiteInstance::GetSiteForURL(profile, url); | 358 GURL site = content::SiteInstance::GetSiteForURL(profile, url); |
| 371 content::BrowserContext::GetStoragePartitionForSite(profile, site)-> | 359 content::BrowserContext::GetStoragePartitionForSite(profile, site)-> |
| 372 GetFileSystemContext()->EnableTemporaryFileSystemInIncognito(); | 360 GetFileSystemContext()->EnableTemporaryFileSystemInIncognito(); |
| 373 } | 361 } |
| 374 | 362 |
| 375 DevToolsUI::~DevToolsUI() { | 363 DevToolsUI::~DevToolsUI() { |
| 376 } | 364 } |
| OLD | NEW |