| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser_about_handler.h" | 5 #include "chrome/browser/browser_about_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 path == kStringsJsPath || | 1431 path == kStringsJsPath || |
| 1432 path == kVersionJsPath || | 1432 path == kVersionJsPath || |
| 1433 path == kMemoryJsPath) { | 1433 path == kMemoryJsPath) { |
| 1434 return "application/javascript"; | 1434 return "application/javascript"; |
| 1435 } | 1435 } |
| 1436 return "text/html"; | 1436 return "text/html"; |
| 1437 } | 1437 } |
| 1438 | 1438 |
| 1439 // ----------------------------------------------------------------------------- | 1439 // ----------------------------------------------------------------------------- |
| 1440 | 1440 |
| 1441 void InitializeAboutDataSource(const std::string& name, Profile* profile) { | 1441 void InitializeAboutDataSource(const std::string& name, |
| 1442 content::BrowserContext* browser_context) { |
| 1443 Profile* profile = static_cast<Profile*>(browser_context); |
| 1442 ChromeURLDataManager* manager = profile->GetChromeURLDataManager(); | 1444 ChromeURLDataManager* manager = profile->GetChromeURLDataManager(); |
| 1443 for (size_t i = 0; i < arraysize(kAboutSourceNames); i++) { | 1445 for (size_t i = 0; i < arraysize(kAboutSourceNames); i++) { |
| 1444 if (name == kAboutSourceNames[i]) { | 1446 if (name == kAboutSourceNames[i]) { |
| 1445 manager->AddDataSource(new AboutSource(name, profile)); | 1447 manager->AddDataSource(new AboutSource(name, profile)); |
| 1446 return; | 1448 return; |
| 1447 } | 1449 } |
| 1448 } | 1450 } |
| 1449 } | 1451 } |
| 1450 | 1452 |
| 1451 bool WillHandleBrowserAboutURL(GURL* url, Profile* profile) { | 1453 bool WillHandleBrowserAboutURL(GURL* url, |
| 1454 content::BrowserContext* browser_context) { |
| 1452 // TODO(msw): Eliminate "about:*" constants and literals from code and tests, | 1455 // TODO(msw): Eliminate "about:*" constants and literals from code and tests, |
| 1453 // then hopefully we can remove this forced fixup. | 1456 // then hopefully we can remove this forced fixup. |
| 1454 *url = URLFixerUpper::FixupURL(url->possibly_invalid_spec(), std::string()); | 1457 *url = URLFixerUpper::FixupURL(url->possibly_invalid_spec(), std::string()); |
| 1455 | 1458 |
| 1456 // Check that about: URLs are fixed up to chrome: by URLFixerUpper::FixupURL. | 1459 // Check that about: URLs are fixed up to chrome: by URLFixerUpper::FixupURL. |
| 1457 DCHECK((*url == GURL(chrome::kAboutBlankURL)) || | 1460 DCHECK((*url == GURL(chrome::kAboutBlankURL)) || |
| 1458 !url->SchemeIs(chrome::kAboutScheme)); | 1461 !url->SchemeIs(chrome::kAboutScheme)); |
| 1459 | 1462 |
| 1460 // Only handle chrome://foo/, URLFixerUpper::FixupURL translates about:foo. | 1463 // Only handle chrome://foo/, URLFixerUpper::FixupURL translates about:foo. |
| 1461 // TAB_CONTENTS_WEB handles about:blank, which frames are allowed to access. | 1464 // TAB_CONTENTS_WEB handles about:blank, which frames are allowed to access. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1492 0, content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, new GpuMsg_Clean()); | 1495 0, content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, new GpuMsg_Clean()); |
| 1493 } else if (host == chrome::kChromeUIGpuCrashHost) { | 1496 } else if (host == chrome::kChromeUIGpuCrashHost) { |
| 1494 GpuProcessHost::SendOnIO( | 1497 GpuProcessHost::SendOnIO( |
| 1495 0, content::CAUSE_FOR_GPU_LAUNCH_ABOUT_GPUCRASH, new GpuMsg_Crash()); | 1498 0, content::CAUSE_FOR_GPU_LAUNCH_ABOUT_GPUCRASH, new GpuMsg_Crash()); |
| 1496 } else if (host == chrome::kChromeUIGpuHangHost) { | 1499 } else if (host == chrome::kChromeUIGpuHangHost) { |
| 1497 GpuProcessHost::SendOnIO( | 1500 GpuProcessHost::SendOnIO( |
| 1498 0, content::CAUSE_FOR_GPU_LAUNCH_ABOUT_GPUHANG, new GpuMsg_Hang()); | 1501 0, content::CAUSE_FOR_GPU_LAUNCH_ABOUT_GPUHANG, new GpuMsg_Hang()); |
| 1499 } | 1502 } |
| 1500 | 1503 |
| 1501 // Initialize any potentially corresponding AboutSource handler. | 1504 // Initialize any potentially corresponding AboutSource handler. |
| 1502 InitializeAboutDataSource(host, profile); | 1505 InitializeAboutDataSource(host, browser_context); |
| 1503 return true; | 1506 return true; |
| 1504 } | 1507 } |
| 1505 | 1508 |
| 1506 bool HandleNonNavigationAboutURL(const GURL& url) { | 1509 bool HandleNonNavigationAboutURL(const GURL& url) { |
| 1507 // chrome://ipc/ is currently buggy, so we disable it for official builds. | 1510 // chrome://ipc/ is currently buggy, so we disable it for official builds. |
| 1508 #if !defined(OFFICIAL_BUILD) | 1511 #if !defined(OFFICIAL_BUILD) |
| 1509 | 1512 |
| 1510 #if (defined(OS_MACOSX) || defined(OS_WIN)) && defined(IPC_MESSAGE_LOG_ENABLED) | 1513 #if (defined(OS_MACOSX) || defined(OS_WIN)) && defined(IPC_MESSAGE_LOG_ENABLED) |
| 1511 if (LowerCaseEqualsASCII(url.spec(), chrome::kChromeUIIPCURL)) { | 1514 if (LowerCaseEqualsASCII(url.spec(), chrome::kChromeUIIPCURL)) { |
| 1512 // Run the dialog. This will re-use the existing one if it's already up. | 1515 // Run the dialog. This will re-use the existing one if it's already up. |
| 1513 browser::ShowAboutIPCDialog(); | 1516 browser::ShowAboutIPCDialog(); |
| 1514 return true; | 1517 return true; |
| 1515 } | 1518 } |
| 1516 #endif | 1519 #endif |
| 1517 | 1520 |
| 1518 #endif // OFFICIAL_BUILD | 1521 #endif // OFFICIAL_BUILD |
| 1519 | 1522 |
| 1520 return false; | 1523 return false; |
| 1521 } | 1524 } |
| 1522 | 1525 |
| 1523 std::vector<std::string> ChromePaths() { | 1526 std::vector<std::string> ChromePaths() { |
| 1524 std::vector<std::string> paths; | 1527 std::vector<std::string> paths; |
| 1525 paths.reserve(arraysize(kChromePaths)); | 1528 paths.reserve(arraysize(kChromePaths)); |
| 1526 for (size_t i = 0; i < arraysize(kChromePaths); i++) | 1529 for (size_t i = 0; i < arraysize(kChromePaths); i++) |
| 1527 paths.push_back(kChromePaths[i]); | 1530 paths.push_back(kChromePaths[i]); |
| 1528 return paths; | 1531 return paths; |
| 1529 } | 1532 } |
| OLD | NEW |