| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/ui/webui/uber/uber_ui.h" | 5 #include "chrome/browser/ui/webui/uber/uber_ui.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 return true; | 186 return true; |
| 187 } | 187 } |
| 188 | 188 |
| 189 // UberFrameUI | 189 // UberFrameUI |
| 190 | 190 |
| 191 UberFrameUI::UberFrameUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 191 UberFrameUI::UberFrameUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| 192 Profile* profile = Profile::FromWebUI(web_ui); | 192 Profile* profile = Profile::FromWebUI(web_ui); |
| 193 content::WebUIDataSource::Add(profile, CreateUberFrameHTMLSource(profile)); | 193 content::WebUIDataSource::Add(profile, CreateUberFrameHTMLSource(profile)); |
| 194 | 194 |
| 195 // Register as an observer for when extensions are loaded and unloaded. | 195 // Register as an observer for when extensions are loaded and unloaded. |
| 196 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, | 196 registrar_.Add(this, |
| 197 content::Source<Profile>(profile)); | 197 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 198 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 198 content::Source<Profile>(profile)); |
| 199 content::Source<Profile>(profile)); | 199 registrar_.Add(this, |
| 200 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 201 content::Source<Profile>(profile)); |
| 200 } | 202 } |
| 201 | 203 |
| 202 UberFrameUI::~UberFrameUI() { | 204 UberFrameUI::~UberFrameUI() { |
| 203 } | 205 } |
| 204 | 206 |
| 205 void UberFrameUI::Observe(int type, | 207 void UberFrameUI::Observe(int type, |
| 206 const content::NotificationSource& source, | 208 const content::NotificationSource& source, |
| 207 const content::NotificationDetails& details) { | 209 const content::NotificationDetails& details) { |
| 208 switch (type) { | 210 switch (type) { |
| 209 // We listen for notifications that indicate an extension has been loaded | 211 // We listen for notifications that indicate an extension has been loaded |
| 210 // (i.e., has been installed and/or enabled) or unloaded (i.e., has been | 212 // (i.e., has been installed and/or enabled) or unloaded (i.e., has been |
| 211 // uninstalled and/or disabled). If one of these events has occurred, then | 213 // uninstalled and/or disabled). If one of these events has occurred, then |
| 212 // we must update the behavior of the History navigation element so that | 214 // we must update the behavior of the History navigation element so that |
| 213 // it opens the history extension if one is installed and enabled or | 215 // it opens the history extension if one is installed and enabled or |
| 214 // opens the default history page if one is uninstalled or disabled. | 216 // opens the default history page if one is uninstalled or disabled. |
| 215 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: | 217 case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: |
| 216 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { | 218 case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { |
| 217 Profile* profile = Profile::FromWebUI(web_ui()); | 219 Profile* profile = Profile::FromWebUI(web_ui()); |
| 218 bool overrides_history = | 220 bool overrides_history = |
| 219 HasExtensionType(profile, chrome::kChromeUIHistoryHost); | 221 HasExtensionType(profile, chrome::kChromeUIHistoryHost); |
| 220 web_ui()->CallJavascriptFunction( | 222 web_ui()->CallJavascriptFunction( |
| 221 "uber_frame.setNavigationOverride", | 223 "uber_frame.setNavigationOverride", |
| 222 base::StringValue(chrome::kChromeUIHistoryHost), | 224 base::StringValue(chrome::kChromeUIHistoryHost), |
| 223 base::StringValue(overrides_history ? "yes" : "no")); | 225 base::StringValue(overrides_history ? "yes" : "no")); |
| 224 break; | 226 break; |
| 225 } | 227 } |
| 226 default: | 228 default: |
| 227 NOTREACHED(); | 229 NOTREACHED(); |
| 228 } | 230 } |
| 229 } | 231 } |
| OLD | NEW |