| 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 // Contains code for handling "about:" URLs in the browser process. | 5 // Contains code for handling "about:" URLs in the browser process. |
| 6 | 6 |
| 7 #ifndef CHROME_BROWSER_BROWSER_ABOUT_HANDLER_H_ | 7 #ifndef CHROME_BROWSER_BROWSER_ABOUT_HANDLER_H_ |
| 8 #define CHROME_BROWSER_BROWSER_ABOUT_HANDLER_H_ | 8 #define CHROME_BROWSER_BROWSER_ABOUT_HANDLER_H_ |
| 9 #pragma once | 9 #pragma once |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/process.h" | 14 #include "base/process.h" |
| 15 #include "base/singleton.h" | |
| 16 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 17 | 16 |
| 17 template <typename T> struct DefaultSingletonTraits; |
| 18 class GURL; | 18 class GURL; |
| 19 class Profile; | 19 class Profile; |
| 20 | 20 |
| 21 // Decides whether the given URL will be handled by the browser about handler | 21 // Decides whether the given URL will be handled by the browser about handler |
| 22 // and returns true if so. On true, it may also modify the given URL to be the | 22 // and returns true if so. On true, it may also modify the given URL to be the |
| 23 // final form (we fix up most "about:" URLs to be "chrome:" because WebKit | 23 // final form (we fix up most "about:" URLs to be "chrome:" because WebKit |
| 24 // handles all "about:" URLs as "about:blank. | 24 // handles all "about:" URLs as "about:blank. |
| 25 // | 25 // |
| 26 // This is used by BrowserURLHandler. | 26 // This is used by BrowserURLHandler. |
| 27 bool WillHandleBrowserAboutURL(GURL* url, Profile* profile); | 27 bool WillHandleBrowserAboutURL(GURL* url, Profile* profile); |
| 28 | 28 |
| 29 // We have a few magic commands that don't cause navigations, but rather pop up | 29 // We have a few magic commands that don't cause navigations, but rather pop up |
| 30 // dialogs. This function handles those cases, and returns true if so. In this | 30 // dialogs. This function handles those cases, and returns true if so. In this |
| 31 // case, normal tab navigation should be skipped. | 31 // case, normal tab navigation should be skipped. |
| 32 bool HandleNonNavigationAboutURL(const GURL& url); | 32 bool HandleNonNavigationAboutURL(const GURL& url); |
| 33 | 33 |
| 34 #if defined(USE_TCMALLOC) | 34 #if defined(USE_TCMALLOC) |
| 35 // A map of header strings (e.g. "Browser", "Renderer PID 123") | 35 // A map of header strings (e.g. "Browser", "Renderer PID 123") |
| 36 // to the tcmalloc output collected for each process. | 36 // to the tcmalloc output collected for each process. |
| 37 typedef std::map<std::string, std::string> AboutTcmallocOutputsType; | 37 typedef std::map<std::string, std::string> AboutTcmallocOutputsType; |
| 38 | 38 |
| 39 class AboutTcmallocOutputs { | 39 class AboutTcmallocOutputs { |
| 40 public: | 40 public: |
| 41 AboutTcmallocOutputs() {} | 41 // Returns the singleton instance. |
| 42 static AboutTcmallocOutputs* GetInstance(); |
| 42 | 43 |
| 43 AboutTcmallocOutputsType* outputs() { return &outputs_; } | 44 AboutTcmallocOutputsType* outputs() { return &outputs_; } |
| 44 | 45 |
| 45 // Records the output for a specified header string. | 46 // Records the output for a specified header string. |
| 46 void SetOutput(std::string header, std::string output) { | 47 void SetOutput(std::string header, std::string output) { |
| 47 outputs_[header] = output; | 48 outputs_[header] = output; |
| 48 } | 49 } |
| 49 | 50 |
| 50 // Callback for output returned from renderer processes. Adds | 51 // Callback for output returned from renderer processes. Adds |
| 51 // the output for a canonical renderer header string that | 52 // the output for a canonical renderer header string that |
| 52 // incorporates the pid. | 53 // incorporates the pid. |
| 53 void RendererCallback(base::ProcessId pid, std::string output) { | 54 void RendererCallback(base::ProcessId pid, std::string output) { |
| 54 SetOutput(StringPrintf("Renderer PID %d", static_cast<int>(pid)), output); | 55 SetOutput(StringPrintf("Renderer PID %d", static_cast<int>(pid)), output); |
| 55 } | 56 } |
| 56 | 57 |
| 57 private: | 58 private: |
| 59 AboutTcmallocOutputs() {} |
| 60 |
| 58 AboutTcmallocOutputsType outputs_; | 61 AboutTcmallocOutputsType outputs_; |
| 59 | 62 |
| 60 friend struct DefaultSingletonTraits<AboutTcmallocOutputs>; | 63 friend struct DefaultSingletonTraits<AboutTcmallocOutputs>; |
| 61 | 64 |
| 62 DISALLOW_COPY_AND_ASSIGN(AboutTcmallocOutputs); | 65 DISALLOW_COPY_AND_ASSIGN(AboutTcmallocOutputs); |
| 63 }; | 66 }; |
| 64 | 67 |
| 65 // Glue between the callback task and the method in the singleton. | 68 // Glue between the callback task and the method in the singleton. |
| 66 void AboutTcmallocRendererCallback(base::ProcessId pid, std::string output); | 69 void AboutTcmallocRendererCallback(base::ProcessId pid, std::string output); |
| 67 #endif | 70 #endif |
| 68 | 71 |
| 69 #endif // CHROME_BROWSER_BROWSER_ABOUT_HANDLER_H_ | 72 #endif // CHROME_BROWSER_BROWSER_ABOUT_HANDLER_H_ |
| OLD | NEW |