| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // "about:memory" on the new tab page or any other page where a process | 69 // "about:memory" on the new tab page or any other page where a process |
| 70 // transition would occur to the about URL will cause some confusion. | 70 // transition would occur to the about URL will cause some confusion. |
| 71 // | 71 // |
| 72 // The problem is that during the processing of the memory page, there are two | 72 // The problem is that during the processing of the memory page, there are two |
| 73 // processes active, the original and the destination one. This can create the | 73 // processes active, the original and the destination one. This can create the |
| 74 // impression that we're using more resources than we actually are. This | 74 // impression that we're using more resources than we actually are. This |
| 75 // redirect solves the problem by eliminating the process transition during the | 75 // redirect solves the problem by eliminating the process transition during the |
| 76 // time that about memory is being computed. | 76 // time that about memory is being computed. |
| 77 std::string GetAboutMemoryRedirectResponse() { | 77 std::string GetAboutMemoryRedirectResponse() { |
| 78 return "<meta http-equiv=\"refresh\" " | 78 return "<meta http-equiv=\"refresh\" " |
| 79 "content=\"0;chrome-ui://about/memory\">"; | 79 "content=\"0;chrome://about/memory\">"; |
| 80 } | 80 } |
| 81 | 81 |
| 82 class AboutSource : public ChromeURLDataManager::DataSource { | 82 class AboutSource : public ChromeURLDataManager::DataSource { |
| 83 public: | 83 public: |
| 84 // Creates our datasource. | 84 // Creates our datasource. |
| 85 AboutSource(); | 85 AboutSource(); |
| 86 virtual ~AboutSource(); | 86 virtual ~AboutSource(); |
| 87 | 87 |
| 88 // Called when the network layer has requested a resource underneath | 88 // Called when the network layer has requested a resource underneath |
| 89 // the path we registered. | 89 // the path we registered. |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 // There is currently no way to remove a data source. | 605 // There is currently no way to remove a data source. |
| 606 static bool initialized = false; | 606 static bool initialized = false; |
| 607 if (!initialized) { | 607 if (!initialized) { |
| 608 about_source = new AboutSource(); | 608 about_source = new AboutSource(); |
| 609 initialized = true; | 609 initialized = true; |
| 610 } | 610 } |
| 611 | 611 |
| 612 // Special case about:memory to go through a redirect before ending up on | 612 // Special case about:memory to go through a redirect before ending up on |
| 613 // the final page. See GetAboutMemoryRedirectResponse above for why. | 613 // the final page. See GetAboutMemoryRedirectResponse above for why. |
| 614 if (LowerCaseEqualsASCII(url->path(), kMemoryPath)) { | 614 if (LowerCaseEqualsASCII(url->path(), kMemoryPath)) { |
| 615 *url = GURL("chrome-ui://about/memory-redirect"); | 615 *url = GURL("chrome://about/memory-redirect"); |
| 616 return true; | 616 return true; |
| 617 } | 617 } |
| 618 | 618 |
| 619 // Rewrite the about URL to use chrome-ui. WebKit treats all about URLS the | 619 // Rewrite the about URL to use chrome:. WebKit treats all about URLS the |
| 620 // same (blank page), so if we want to display content, we need another | 620 // same (blank page), so if we want to display content, we need another |
| 621 // scheme. | 621 // scheme. |
| 622 std::string about_url = "chrome-ui://about/"; | 622 std::string about_url = "chrome://about/"; |
| 623 about_url.append(url->path()); | 623 about_url.append(url->path()); |
| 624 *url = GURL(about_url); | 624 *url = GURL(about_url); |
| 625 return true; | 625 return true; |
| 626 } | 626 } |
| 627 | 627 |
| 628 // This function gets called with the fixed-up chrome-ui URLs, so we have to | 628 // This function gets called with the fixed-up chrome: URLs, so we have to |
| 629 // compare against those instead of "about:blah". | 629 // compare against those instead of "about:blah". |
| 630 bool HandleNonNavigationAboutURL(const GURL& url) { | 630 bool HandleNonNavigationAboutURL(const GURL& url) { |
| 631 // About:network and IPC and currently buggy, so we disable it for official | 631 // About:network and IPC and currently buggy, so we disable it for official |
| 632 // builds. | 632 // builds. |
| 633 #if defined(OS_WIN) && !defined(OFFICIAL_BUILD) | 633 #if defined(OS_WIN) && !defined(OFFICIAL_BUILD) |
| 634 if (LowerCaseEqualsASCII(url.spec(), chrome::kChromeUINetworkURL)) { | 634 if (LowerCaseEqualsASCII(url.spec(), chrome::kChromeUINetworkURL)) { |
| 635 // Run the dialog. This will re-use the existing one if it's already up. | 635 // Run the dialog. This will re-use the existing one if it's already up. |
| 636 AboutNetworkDialog::RunDialog(); | 636 AboutNetworkDialog::RunDialog(); |
| 637 return true; | 637 return true; |
| 638 } | 638 } |
| 639 | 639 |
| 640 #ifdef IPC_MESSAGE_LOG_ENABLED | 640 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 641 if (LowerCaseEqualsASCII(url.spec(), chrome::kChromeUIIPCURL)) { | 641 if (LowerCaseEqualsASCII(url.spec(), chrome::kChromeUIIPCURL)) { |
| 642 // Run the dialog. This will re-use the existing one if it's already up. | 642 // Run the dialog. This will re-use the existing one if it's already up. |
| 643 AboutIPCDialog::RunDialog(); | 643 AboutIPCDialog::RunDialog(); |
| 644 return true; | 644 return true; |
| 645 } | 645 } |
| 646 #endif | 646 #endif |
| 647 | 647 |
| 648 #else | 648 #else |
| 649 // TODO(port) Implement this. | 649 // TODO(port) Implement this. |
| 650 #endif | 650 #endif |
| 651 return false; | 651 return false; |
| 652 } | 652 } |
| OLD | NEW |