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