| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/extensions/api/url_overrides/url_overrides_api.h" |
| 6 |
| 7 #include "chrome/browser/extensions/extension_web_ui.h" |
| 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/common/chrome_notification_types.h" |
| 10 #include "chrome/common/extensions/api/url_overrides/url_overrides_handler.h" |
| 11 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 12 #include "chrome/common/extensions/manifest_handler.h" |
| 13 #include "content/public/browser/notification_details.h" |
| 14 #include "content/public/browser/notification_service.h" |
| 15 |
| 16 namespace extensions { |
| 17 |
| 18 URLOverridesAPI::URLOverridesAPI(Profile* profile) |
| 19 : profile_(profile) { |
| 20 ManifestHandler::Register(extension_manifest_keys::kChromeURLOverrides, |
| 21 new URLOverridesHandler); |
| 22 |
| 23 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 24 content::Source<Profile>(profile)); |
| 25 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 26 content::Source<Profile>(profile)); |
| 27 } |
| 28 |
| 29 URLOverridesAPI::~URLOverridesAPI() { |
| 30 } |
| 31 |
| 32 void URLOverridesAPI::Observe(int type, |
| 33 const content::NotificationSource& source, |
| 34 const content::NotificationDetails& details) { |
| 35 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) { |
| 36 const Extension* extension = |
| 37 content::Details<const Extension>(details).ptr(); |
| 38 ExtensionWebUI::RegisterChromeURLOverrides( |
| 39 profile_, URLOverridesInfo::GetChromeURLOverrides(extension)); |
| 40 |
| 41 } else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { |
| 42 const Extension* extension = |
| 43 content::Details<const UnloadedExtensionInfo>(details)->extension; |
| 44 ExtensionWebUI::UnregisterChromeURLOverrides( |
| 45 profile_, URLOverridesInfo::GetChromeURLOverrides(extension)); |
| 46 } |
| 47 } |
| 48 |
| 49 } // namespace extensions |
| OLD | NEW |