| Index: chrome/browser/extensions/api/url_overrides/url_overrides_api.cc
|
| diff --git a/chrome/browser/extensions/api/url_overrides/url_overrides_api.cc b/chrome/browser/extensions/api/url_overrides/url_overrides_api.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..85e6adbcea0591b817e77479c7b919e611e220ff
|
| --- /dev/null
|
| +++ b/chrome/browser/extensions/api/url_overrides/url_overrides_api.cc
|
| @@ -0,0 +1,49 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/extensions/api/url_overrides/url_overrides_api.h"
|
| +
|
| +#include "chrome/browser/extensions/extension_web_ui.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/common/chrome_notification_types.h"
|
| +#include "chrome/common/extensions/api/url_overrides/url_overrides_handler.h"
|
| +#include "chrome/common/extensions/extension_manifest_constants.h"
|
| +#include "chrome/common/extensions/manifest_handler.h"
|
| +#include "content/public/browser/notification_details.h"
|
| +#include "content/public/browser/notification_service.h"
|
| +
|
| +namespace extensions {
|
| +
|
| +URLOverridesAPI::URLOverridesAPI(Profile* profile)
|
| + : profile_(profile) {
|
| + ManifestHandler::Register(extension_manifest_keys::kChromeURLOverrides,
|
| + new URLOverridesHandler);
|
| +
|
| + registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
|
| + content::Source<Profile>(profile));
|
| + registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
|
| + content::Source<Profile>(profile));
|
| +}
|
| +
|
| +URLOverridesAPI::~URLOverridesAPI() {
|
| +}
|
| +
|
| +void URLOverridesAPI::Observe(int type,
|
| + const content::NotificationSource& source,
|
| + const content::NotificationDetails& details) {
|
| + if (type == chrome::NOTIFICATION_EXTENSION_LOADED) {
|
| + const Extension* extension =
|
| + content::Details<const Extension>(details).ptr();
|
| + ExtensionWebUI::RegisterChromeURLOverrides(
|
| + profile_, URLOverridesInfo::GetChromeURLOverrides(extension));
|
| +
|
| + } else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) {
|
| + const Extension* extension =
|
| + content::Details<const UnloadedExtensionInfo>(details)->extension;
|
| + ExtensionWebUI::UnregisterChromeURLOverrides(
|
| + profile_, URLOverridesInfo::GetChromeURLOverrides(extension));
|
| + }
|
| +}
|
| +
|
| +} // namespace extensions
|
|
|