| 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* context) { |
| 1443 Profile* profile = static_cast<Profile*>(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, content::BrowserContext* context) { |
| 1452 // TODO(msw): Eliminate "about:*" constants and literals from code and tests, | 1454 // TODO(msw): Eliminate "about:*" constants and literals from code and tests, |
| 1453 // then hopefully we can remove this forced fixup. | 1455 // then hopefully we can remove this forced fixup. |
| 1454 *url = URLFixerUpper::FixupURL(url->possibly_invalid_spec(), std::string()); | 1456 *url = URLFixerUpper::FixupURL(url->possibly_invalid_spec(), std::string()); |
| 1455 | 1457 |
| 1456 // Check that about: URLs are fixed up to chrome: by URLFixerUpper::FixupURL. | 1458 // Check that about: URLs are fixed up to chrome: by URLFixerUpper::FixupURL. |
| 1457 DCHECK((*url == GURL(chrome::kAboutBlankURL)) || | 1459 DCHECK((*url == GURL(chrome::kAboutBlankURL)) || |
| 1458 !url->SchemeIs(chrome::kAboutScheme)); | 1460 !url->SchemeIs(chrome::kAboutScheme)); |
| 1459 | 1461 |
| 1460 // Only handle chrome://foo/, URLFixerUpper::FixupURL translates about:foo. | 1462 // Only handle chrome://foo/, URLFixerUpper::FixupURL translates about:foo. |
| 1461 // TAB_CONTENTS_WEB handles about:blank, which frames are allowed to access. | 1463 // 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()); | 1494 0, content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, new GpuMsg_Clean()); |
| 1493 } else if (host == chrome::kChromeUIGpuCrashHost) { | 1495 } else if (host == chrome::kChromeUIGpuCrashHost) { |
| 1494 GpuProcessHost::SendOnIO( | 1496 GpuProcessHost::SendOnIO( |
| 1495 0, content::CAUSE_FOR_GPU_LAUNCH_ABOUT_GPUCRASH, new GpuMsg_Crash()); | 1497 0, content::CAUSE_FOR_GPU_LAUNCH_ABOUT_GPUCRASH, new GpuMsg_Crash()); |
| 1496 } else if (host == chrome::kChromeUIGpuHangHost) { | 1498 } else if (host == chrome::kChromeUIGpuHangHost) { |
| 1497 GpuProcessHost::SendOnIO( | 1499 GpuProcessHost::SendOnIO( |
| 1498 0, content::CAUSE_FOR_GPU_LAUNCH_ABOUT_GPUHANG, new GpuMsg_Hang()); | 1500 0, content::CAUSE_FOR_GPU_LAUNCH_ABOUT_GPUHANG, new GpuMsg_Hang()); |
| 1499 } | 1501 } |
| 1500 | 1502 |
| 1501 // Initialize any potentially corresponding AboutSource handler. | 1503 // Initialize any potentially corresponding AboutSource handler. |
| 1502 InitializeAboutDataSource(host, profile); | 1504 InitializeAboutDataSource(host, context); |
| 1503 return true; | 1505 return true; |
| 1504 } | 1506 } |
| 1505 | 1507 |
| 1506 bool HandleNonNavigationAboutURL(const GURL& url) { | 1508 bool HandleNonNavigationAboutURL(const GURL& url) { |
| 1507 // chrome://ipc/ is currently buggy, so we disable it for official builds. | 1509 // chrome://ipc/ is currently buggy, so we disable it for official builds. |
| 1508 #if !defined(OFFICIAL_BUILD) | 1510 #if !defined(OFFICIAL_BUILD) |
| 1509 | 1511 |
| 1510 #if (defined(OS_MACOSX) || defined(OS_WIN)) && defined(IPC_MESSAGE_LOG_ENABLED) | 1512 #if (defined(OS_MACOSX) || defined(OS_WIN)) && defined(IPC_MESSAGE_LOG_ENABLED) |
| 1511 if (LowerCaseEqualsASCII(url.spec(), chrome::kChromeUIIPCURL)) { | 1513 if (LowerCaseEqualsASCII(url.spec(), chrome::kChromeUIIPCURL)) { |
| 1512 // Run the dialog. This will re-use the existing one if it's already up. | 1514 // Run the dialog. This will re-use the existing one if it's already up. |
| 1513 browser::ShowAboutIPCDialog(); | 1515 browser::ShowAboutIPCDialog(); |
| 1514 return true; | 1516 return true; |
| 1515 } | 1517 } |
| 1516 #endif | 1518 #endif |
| 1517 | 1519 |
| 1518 #endif // OFFICIAL_BUILD | 1520 #endif // OFFICIAL_BUILD |
| 1519 | 1521 |
| 1520 return false; | 1522 return false; |
| 1521 } | 1523 } |
| 1522 | 1524 |
| 1523 std::vector<std::string> ChromePaths() { | 1525 std::vector<std::string> ChromePaths() { |
| 1524 std::vector<std::string> paths; | 1526 std::vector<std::string> paths; |
| 1525 paths.reserve(arraysize(kChromePaths)); | 1527 paths.reserve(arraysize(kChromePaths)); |
| 1526 for (size_t i = 0; i < arraysize(kChromePaths); i++) | 1528 for (size_t i = 0; i < arraysize(kChromePaths); i++) |
| 1527 paths.push_back(kChromePaths[i]); | 1529 paths.push_back(kChromePaths[i]); |
| 1528 return paths; | 1530 return paths; |
| 1529 } | 1531 } |
| OLD | NEW |