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" |
11 #include "chrome/browser/ui/webui/extensions/extensions_ui.h" | 11 #include "chrome/browser/ui/webui/extensions/extensions_ui.h" |
12 #include "chrome/browser/ui/webui/log_web_ui_url.h" | 12 #include "chrome/browser/ui/webui/log_web_ui_url.h" |
13 #include "chrome/browser/ui/webui/md_history_ui.h" | |
13 #include "chrome/browser/ui/webui/options/options_ui.h" | 14 #include "chrome/browser/ui/webui/options/options_ui.h" |
14 #include "chrome/common/chrome_features.h" | 15 #include "chrome/common/chrome_features.h" |
15 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/extensions/chrome_manifest_url_handlers.h" | 17 #include "chrome/common/extensions/chrome_manifest_url_handlers.h" |
17 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
18 #include "chrome/grit/chromium_strings.h" | 19 #include "chrome/grit/chromium_strings.h" |
19 #include "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.h" |
20 #include "components/strings/grit/components_strings.h" | 21 #include "components/strings/grit/components_strings.h" |
21 #include "content/public/browser/browser_context.h" | 22 #include "content/public/browser/browser_context.h" |
22 #include "content/public/browser/navigation_controller.h" | 23 #include "content/public/browser/navigation_controller.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 return true; | 76 return true; |
76 } | 77 } |
77 | 78 |
78 return false; | 79 return false; |
79 } | 80 } |
80 | 81 |
81 content::WebUIDataSource* CreateUberFrameHTMLSource( | 82 content::WebUIDataSource* CreateUberFrameHTMLSource( |
82 content::BrowserContext* browser_context) { | 83 content::BrowserContext* browser_context) { |
83 content::WebUIDataSource* source = | 84 content::WebUIDataSource* source = |
84 content::WebUIDataSource::Create(chrome::kChromeUIUberFrameHost); | 85 content::WebUIDataSource::Create(chrome::kChromeUIUberFrameHost); |
86 Profile* profile = Profile::FromBrowserContext(browser_context); | |
85 | 87 |
86 source->SetJsonPath("strings.js"); | 88 source->SetJsonPath("strings.js"); |
87 source->AddResourcePath("uber_frame.js", IDR_UBER_FRAME_JS); | 89 source->AddResourcePath("uber_frame.js", IDR_UBER_FRAME_JS); |
88 source->SetDefaultResource(IDR_UBER_FRAME_HTML); | 90 source->SetDefaultResource(IDR_UBER_FRAME_HTML); |
89 | 91 |
90 // TODO(jhawkins): Attempt to get rid of IDS_SHORT_PRODUCT_OS_NAME. | 92 // TODO(jhawkins): Attempt to get rid of IDS_SHORT_PRODUCT_OS_NAME. |
91 #if defined(OS_CHROMEOS) | 93 #if defined(OS_CHROMEOS) |
92 source->AddLocalizedString("shortProductName", IDS_SHORT_PRODUCT_OS_NAME); | 94 source->AddLocalizedString("shortProductName", IDS_SHORT_PRODUCT_OS_NAME); |
93 #else | 95 #else |
94 source->AddLocalizedString("shortProductName", IDS_SHORT_PRODUCT_NAME); | 96 source->AddLocalizedString("shortProductName", IDS_SHORT_PRODUCT_NAME); |
95 #endif // defined(OS_CHROMEOS) | 97 #endif // defined(OS_CHROMEOS) |
96 | 98 |
97 source->AddBoolean("hideExtensions", ::switches::MdExtensionsEnabled()); | 99 source->AddBoolean("hideExtensions", ::switches::MdExtensionsEnabled()); |
98 source->AddBoolean("hideSettingsAndHelp", | 100 source->AddBoolean("hideSettingsAndHelp", |
99 ::switches::SettingsWindowEnabled()); | 101 ::switches::SettingsWindowEnabled()); |
100 source->AddString("extensionsHost", chrome::kChromeUIExtensionsHost); | 102 source->AddString("extensionsHost", chrome::kChromeUIExtensionsHost); |
101 source->AddLocalizedString("extensionsDisplayName", | 103 source->AddLocalizedString("extensionsDisplayName", |
102 IDS_MANAGE_EXTENSIONS_SETTING_WINDOWS_TITLE); | 104 IDS_MANAGE_EXTENSIONS_SETTING_WINDOWS_TITLE); |
103 source->AddString("helpHost", chrome::kChromeUIHelpHost); | 105 source->AddString("helpHost", chrome::kChromeUIHelpHost); |
104 source->AddLocalizedString("helpDisplayName", IDS_ABOUT_TITLE); | 106 source->AddLocalizedString("helpDisplayName", IDS_ABOUT_TITLE); |
105 source->AddString("historyHost", chrome::kChromeUIHistoryHost); | 107 source->AddString("historyHost", chrome::kChromeUIHistoryHost); |
106 source->AddLocalizedString("historyDisplayName", IDS_HISTORY_TITLE); | 108 source->AddLocalizedString("historyDisplayName", IDS_HISTORY_TITLE); |
107 source->AddString("settingsHost", chrome::kChromeUISettingsHost); | 109 source->AddString("settingsHost", chrome::kChromeUISettingsHost); |
108 source->AddLocalizedString("settingsDisplayName", IDS_SETTINGS_TITLE); | 110 source->AddLocalizedString("settingsDisplayName", IDS_SETTINGS_TITLE); |
109 bool overrides_history = | 111 bool overrides_history = |
110 HasExtensionType(browser_context, chrome::kChromeUIHistoryHost); | 112 HasExtensionType(browser_context, chrome::kChromeUIHistoryHost); |
111 source->AddString("overridesHistory", overrides_history ? "yes" : "no"); | 113 source->AddString("overridesHistory", overrides_history ? "yes" : "no"); |
112 source->AddBoolean( | 114 source->AddBoolean( |
113 "hideHistory", | 115 "hideHistory", |
114 base::FeatureList::IsEnabled(features::kMaterialDesignHistoryFeature) | 116 MdHistoryUI::IsEnabled(profile) |
115 && !overrides_history); | 117 && !overrides_history); |
116 | 118 |
117 source->DisableDenyXFrameOptions(); | 119 source->DisableDenyXFrameOptions(); |
118 source->OverrideContentSecurityPolicyFrameSrc("frame-src chrome:;"); | 120 source->OverrideContentSecurityPolicyFrameSrc("frame-src chrome:;"); |
119 | 121 |
120 source->AddBoolean("profileIsGuest", | 122 source->AddBoolean("profileIsGuest", |
121 Profile::FromBrowserContext(browser_context)->IsGuestSession()); | 123 profile->IsGuestSession()); |
Dan Beam
2016/06/03 04:51:07
unwrap
| |
122 | 124 |
123 return source; | 125 return source; |
124 } | 126 } |
125 | 127 |
126 void UpdateHistoryNavigation(content::WebUI* web_ui) { | 128 void UpdateHistoryNavigation(content::WebUI* web_ui) { |
127 bool overrides_history = | 129 bool overrides_history = |
128 HasExtensionType(web_ui->GetWebContents()->GetBrowserContext(), | 130 HasExtensionType(web_ui->GetWebContents()->GetBrowserContext(), |
129 chrome::kChromeUIHistoryHost); | 131 chrome::kChromeUIHistoryHost); |
130 web_ui->CallJavascriptFunction( | 132 web_ui->CallJavascriptFunction( |
131 "uber_frame.setNavigationOverride", | 133 "uber_frame.setNavigationOverride", |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 // opens the default history page if one is uninstalled or disabled. | 243 // opens the default history page if one is uninstalled or disabled. |
242 UpdateHistoryNavigation(web_ui()); | 244 UpdateHistoryNavigation(web_ui()); |
243 } | 245 } |
244 | 246 |
245 void UberFrameUI::OnExtensionUnloaded( | 247 void UberFrameUI::OnExtensionUnloaded( |
246 content::BrowserContext* browser_context, | 248 content::BrowserContext* browser_context, |
247 const extensions::Extension* extension, | 249 const extensions::Extension* extension, |
248 extensions::UnloadedExtensionInfo::Reason reason) { | 250 extensions::UnloadedExtensionInfo::Reason reason) { |
249 UpdateHistoryNavigation(web_ui()); | 251 UpdateHistoryNavigation(web_ui()); |
250 } | 252 } |
OLD | NEW |