| 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 "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 10 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 content::WebUIDataSource* CreateUberHTMLSource() { | 40 content::WebUIDataSource* CreateUberHTMLSource() { |
| 41 content::WebUIDataSource* source = | 41 content::WebUIDataSource* source = |
| 42 content::WebUIDataSource::Create(chrome::kChromeUIUberHost); | 42 content::WebUIDataSource::Create(chrome::kChromeUIUberHost); |
| 43 | 43 |
| 44 source->SetJsonPath("strings.js"); | 44 source->SetJsonPath("strings.js"); |
| 45 source->AddResourcePath("uber.js", IDR_UBER_JS); | 45 source->AddResourcePath("uber.js", IDR_UBER_JS); |
| 46 source->AddResourcePath("uber_utils.js", IDR_UBER_UTILS_JS); | 46 source->AddResourcePath("uber_utils.js", IDR_UBER_UTILS_JS); |
| 47 source->SetDefaultResource(IDR_UBER_HTML); | 47 source->SetDefaultResource(IDR_UBER_HTML); |
| 48 source->OverrideContentSecurityPolicyFrameSrc("frame-src chrome:;"); | 48 source->OverrideContentSecurityPolicyChildSrc("child-src chrome:;"); |
| 49 | 49 |
| 50 // Hack alert: continue showing "Loading..." until a real title is set. | 50 // Hack alert: continue showing "Loading..." until a real title is set. |
| 51 source->AddLocalizedString("pageTitle", IDS_TAB_LOADING_TITLE); | 51 source->AddLocalizedString("pageTitle", IDS_TAB_LOADING_TITLE); |
| 52 | 52 |
| 53 source->AddString("extensionsFrameURL", chrome::kChromeUIExtensionsFrameURL); | 53 source->AddString("extensionsFrameURL", chrome::kChromeUIExtensionsFrameURL); |
| 54 source->AddString("extensionsHost", chrome::kChromeUIExtensionsHost); | 54 source->AddString("extensionsHost", chrome::kChromeUIExtensionsHost); |
| 55 source->AddString("helpFrameURL", chrome::kChromeUIHelpFrameURL); | 55 source->AddString("helpFrameURL", chrome::kChromeUIHelpFrameURL); |
| 56 source->AddString("helpHost", chrome::kChromeUIHelpHost); | 56 source->AddString("helpHost", chrome::kChromeUIHelpHost); |
| 57 source->AddString("historyFrameURL", chrome::kChromeUIHistoryFrameURL); | 57 source->AddString("historyFrameURL", chrome::kChromeUIHistoryFrameURL); |
| 58 source->AddString("historyHost", chrome::kChromeUIHistoryHost); | 58 source->AddString("historyHost", chrome::kChromeUIHistoryHost); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 source->AddLocalizedString("settingsDisplayName", IDS_SETTINGS_TITLE); | 108 source->AddLocalizedString("settingsDisplayName", IDS_SETTINGS_TITLE); |
| 109 bool overrides_history = | 109 bool overrides_history = |
| 110 HasExtensionType(browser_context, chrome::kChromeUIHistoryHost); | 110 HasExtensionType(browser_context, chrome::kChromeUIHistoryHost); |
| 111 source->AddString("overridesHistory", overrides_history ? "yes" : "no"); | 111 source->AddString("overridesHistory", overrides_history ? "yes" : "no"); |
| 112 source->AddBoolean( | 112 source->AddBoolean( |
| 113 "hideHistory", | 113 "hideHistory", |
| 114 base::FeatureList::IsEnabled(features::kMaterialDesignHistoryFeature) | 114 base::FeatureList::IsEnabled(features::kMaterialDesignHistoryFeature) |
| 115 && !overrides_history); | 115 && !overrides_history); |
| 116 | 116 |
| 117 source->DisableDenyXFrameOptions(); | 117 source->DisableDenyXFrameOptions(); |
| 118 source->OverrideContentSecurityPolicyFrameSrc("frame-src chrome:;"); | 118 source->OverrideContentSecurityPolicyChildSrc("child-src chrome:;"); |
| 119 | 119 |
| 120 source->AddBoolean("profileIsGuest", | 120 source->AddBoolean("profileIsGuest", |
| 121 Profile::FromBrowserContext(browser_context)->IsGuestSession()); | 121 Profile::FromBrowserContext(browser_context)->IsGuestSession()); |
| 122 | 122 |
| 123 return source; | 123 return source; |
| 124 } | 124 } |
| 125 | 125 |
| 126 void UpdateHistoryNavigation(content::WebUI* web_ui) { | 126 void UpdateHistoryNavigation(content::WebUI* web_ui) { |
| 127 bool overrides_history = | 127 bool overrides_history = |
| 128 HasExtensionType(web_ui->GetWebContents()->GetBrowserContext(), | 128 HasExtensionType(web_ui->GetWebContents()->GetBrowserContext(), |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 // opens the default history page if one is uninstalled or disabled. | 241 // opens the default history page if one is uninstalled or disabled. |
| 242 UpdateHistoryNavigation(web_ui()); | 242 UpdateHistoryNavigation(web_ui()); |
| 243 } | 243 } |
| 244 | 244 |
| 245 void UberFrameUI::OnExtensionUnloaded( | 245 void UberFrameUI::OnExtensionUnloaded( |
| 246 content::BrowserContext* browser_context, | 246 content::BrowserContext* browser_context, |
| 247 const extensions::Extension* extension, | 247 const extensions::Extension* extension, |
| 248 extensions::UnloadedExtensionInfo::Reason reason) { | 248 extensions::UnloadedExtensionInfo::Reason reason) { |
| 249 UpdateHistoryNavigation(web_ui()); | 249 UpdateHistoryNavigation(web_ui()); |
| 250 } | 250 } |
| OLD | NEW |