| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
| 29 | 29 |
| 30 using base::ASCIIToUTF16; | 30 using base::ASCIIToUTF16; |
| 31 using content::NavigationController; | 31 using content::NavigationController; |
| 32 using content::NavigationEntry; | 32 using content::NavigationEntry; |
| 33 using content::RenderViewHost; | 33 using content::RenderViewHost; |
| 34 using content::WebContents; | 34 using content::WebContents; |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 bool IsSettingsWindowEnabled() { | |
| 39 return CommandLine::ForCurrentProcess()->HasSwitch( | |
| 40 ::switches::kEnableSettingsWindow); | |
| 41 } | |
| 42 | |
| 43 content::WebUIDataSource* CreateUberHTMLSource() { | 38 content::WebUIDataSource* CreateUberHTMLSource() { |
| 44 content::WebUIDataSource* source = | 39 content::WebUIDataSource* source = |
| 45 content::WebUIDataSource::Create(chrome::kChromeUIUberHost); | 40 content::WebUIDataSource::Create(chrome::kChromeUIUberHost); |
| 46 | 41 |
| 47 source->SetUseJsonJSFormatV2(); | 42 source->SetUseJsonJSFormatV2(); |
| 48 source->SetJsonPath("strings.js"); | 43 source->SetJsonPath("strings.js"); |
| 49 source->AddResourcePath("uber.js", IDR_UBER_JS); | 44 source->AddResourcePath("uber.js", IDR_UBER_JS); |
| 50 source->AddResourcePath("uber_utils.js", IDR_UBER_UTILS_JS); | 45 source->AddResourcePath("uber_utils.js", IDR_UBER_UTILS_JS); |
| 51 source->SetDefaultResource(IDR_UBER_HTML); | 46 source->SetDefaultResource(IDR_UBER_HTML); |
| 52 source->OverrideContentSecurityPolicyFrameSrc("frame-src chrome:;"); | 47 source->OverrideContentSecurityPolicyFrameSrc("frame-src chrome:;"); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // TODO(jhawkins): Attempt to get rid of IDS_SHORT_PRODUCT_OS_NAME. | 100 // TODO(jhawkins): Attempt to get rid of IDS_SHORT_PRODUCT_OS_NAME. |
| 106 #if defined(OS_CHROMEOS) | 101 #if defined(OS_CHROMEOS) |
| 107 source->AddLocalizedString("shortProductName", IDS_SHORT_PRODUCT_OS_NAME); | 102 source->AddLocalizedString("shortProductName", IDS_SHORT_PRODUCT_OS_NAME); |
| 108 #else | 103 #else |
| 109 source->AddLocalizedString("shortProductName", IDS_SHORT_PRODUCT_NAME); | 104 source->AddLocalizedString("shortProductName", IDS_SHORT_PRODUCT_NAME); |
| 110 #endif // defined(OS_CHROMEOS) | 105 #endif // defined(OS_CHROMEOS) |
| 111 | 106 |
| 112 // Group settings and help separately if settings in a window is enabled. | 107 // Group settings and help separately if settings in a window is enabled. |
| 113 base::string16 settings_group(ASCIIToUTF16("settings_group")); | 108 base::string16 settings_group(ASCIIToUTF16("settings_group")); |
| 114 base::string16 other_group(ASCIIToUTF16( | 109 base::string16 other_group(ASCIIToUTF16( |
| 115 IsSettingsWindowEnabled() ? "other_group" : "settings_group")); | 110 ::switches::SettingsWindowEnabled() ? "other_group" : "settings_group")); |
| 116 source->AddString("extensionsHost", | 111 source->AddString("extensionsHost", |
| 117 ASCIIToUTF16(chrome::kChromeUIExtensionsHost)); | 112 ASCIIToUTF16(chrome::kChromeUIExtensionsHost)); |
| 118 source->AddLocalizedString("extensionsDisplayName", | 113 source->AddLocalizedString("extensionsDisplayName", |
| 119 IDS_MANAGE_EXTENSIONS_SETTING_WINDOWS_TITLE); | 114 IDS_MANAGE_EXTENSIONS_SETTING_WINDOWS_TITLE); |
| 120 source->AddString("extensionsGroup", other_group); | 115 source->AddString("extensionsGroup", other_group); |
| 121 source->AddString("helpHost", | 116 source->AddString("helpHost", |
| 122 ASCIIToUTF16(chrome::kChromeUIHelpHost)); | 117 ASCIIToUTF16(chrome::kChromeUIHelpHost)); |
| 123 source->AddLocalizedString("helpDisplayName", IDS_ABOUT_TITLE); | 118 source->AddLocalizedString("helpDisplayName", IDS_ABOUT_TITLE); |
| 124 source->AddString("helpGroup", settings_group); | 119 source->AddString("helpGroup", settings_group); |
| 125 source->AddString("historyHost", | 120 source->AddString("historyHost", |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 web_ui()->CallJavascriptFunction( | 239 web_ui()->CallJavascriptFunction( |
| 245 "uber_frame.setNavigationOverride", | 240 "uber_frame.setNavigationOverride", |
| 246 base::StringValue(chrome::kChromeUIHistoryHost), | 241 base::StringValue(chrome::kChromeUIHistoryHost), |
| 247 base::StringValue(overrides_history ? "yes" : "no")); | 242 base::StringValue(overrides_history ? "yes" : "no")); |
| 248 break; | 243 break; |
| 249 } | 244 } |
| 250 default: | 245 default: |
| 251 NOTREACHED(); | 246 NOTREACHED(); |
| 252 } | 247 } |
| 253 } | 248 } |
| OLD | NEW |