This source file includes following definitions.
- WillHandleBrowserAboutURL
- HandleNonNavigationAboutURL
#include "chrome/browser/browser_about_handler.h"
#include <string>
#include "base/logging.h"
#include "base/strings/string_util.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/common/net/url_fixer_upper.h"
#include "chrome/common/url_constants.h"
bool WillHandleBrowserAboutURL(GURL* url,
content::BrowserContext* browser_context) {
*url = URLFixerUpper::FixupURL(url->possibly_invalid_spec(), std::string());
DCHECK((*url == GURL(content::kAboutBlankURL)) ||
!url->SchemeIs(content::kAboutScheme));
if (!url->SchemeIs(content::kChromeUIScheme))
return false;
std::string host(url->host());
std::string path;
if (host == chrome::kChromeUIAboutHost)
host = chrome::kChromeUIChromeURLsHost;
if (host == chrome::kChromeUICacheHost) {
host = content::kChromeUINetworkViewCacheHost;
} else if (host == chrome::kChromeUISyncHost) {
host = chrome::kChromeUISyncInternalsHost;
} else if (host == chrome::kChromeUIExtensionsHost) {
host = chrome::kChromeUIUberHost;
path = chrome::kChromeUIExtensionsHost + url->path();
} else if (host == chrome::kChromeUISettingsHost &&
url->path() == std::string("/") + chrome::kExtensionsSubPage) {
host = chrome::kChromeUIUberHost;
path = chrome::kChromeUIExtensionsHost;
} else if (host == chrome::kChromeUIHistoryHost) {
#if defined(OS_ANDROID)
host = chrome::kChromeUIHistoryFrameHost;
#else
host = chrome::kChromeUIUberHost;
path = chrome::kChromeUIHistoryHost + url->path();
#endif
} else if (host == chrome::kChromeUISettingsHost) {
host = chrome::kChromeUIUberHost;
path = chrome::kChromeUISettingsHost + url->path();
} else if (host == chrome::kChromeUIHelpHost) {
host = chrome::kChromeUIUberHost;
path = chrome::kChromeUIHelpHost + url->path();
}
GURL::Replacements replacements;
replacements.SetHostStr(host);
if (!path.empty())
replacements.SetPathStr(path);
*url = url->ReplaceComponents(replacements);
return false;
}
bool HandleNonNavigationAboutURL(const GURL& url) {
const std::string host(url.host());
if (host == chrome::kChromeUIRestartHost) {
base::MessageLoop::current()->PostTask(FROM_HERE,
base::Bind(&chrome::AttemptRestart));
return true;
} else if (host == chrome::kChromeUIQuitHost) {
base::MessageLoop::current()->PostTask(FROM_HERE,
base::Bind(&chrome::AttemptExit));
return true;
}
#if !defined(OFFICIAL_BUILD)
#if (defined(OS_MACOSX) || defined(OS_WIN)) && defined(IPC_MESSAGE_LOG_ENABLED)
if (LowerCaseEqualsASCII(url.spec(), chrome::kChromeUIIPCURL)) {
chrome::ShowAboutIPCDialog();
return true;
}
#endif
#endif
return false;
}