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/ntp/ntp_resource_cache.h" | 5 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/first_run/first_run.h" | 19 #include "chrome/browser/first_run/first_run.h" |
20 #include "chrome/browser/google/google_util.h" | 20 #include "chrome/browser/google/google_util.h" |
21 #include "chrome/browser/policy/browser_policy_connector.h" | 21 #include "chrome/browser/policy/browser_policy_connector.h" |
22 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service.h" |
23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/sync/profile_sync_service.h" | 24 #include "chrome/browser/sync/profile_sync_service.h" |
25 #include "chrome/browser/sync/profile_sync_service_factory.h" | 25 #include "chrome/browser/sync/profile_sync_service_factory.h" |
26 #include "chrome/browser/themes/theme_service.h" | 26 #include "chrome/browser/themes/theme_service.h" |
27 #include "chrome/browser/themes/theme_service_factory.h" | 27 #include "chrome/browser/themes/theme_service_factory.h" |
28 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" | 28 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" |
29 #include "chrome/browser/ui/search/search.h" | 29 #include "chrome/browser/ui/search/search.h" |
30 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | |
31 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h" | 30 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h" |
32 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 31 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
33 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h" | 32 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h" |
34 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" | 33 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" |
35 #include "chrome/browser/ui/webui/sync_setup_handler.h" | 34 #include "chrome/browser/ui/webui/sync_setup_handler.h" |
| 35 #include "chrome/browser/ui/webui/web_ui_util.h" |
36 #include "chrome/browser/web_resource/notification_promo.h" | 36 #include "chrome/browser/web_resource/notification_promo.h" |
37 #include "chrome/common/chrome_notification_types.h" | 37 #include "chrome/common/chrome_notification_types.h" |
38 #include "chrome/common/chrome_switches.h" | 38 #include "chrome/common/chrome_switches.h" |
39 #include "chrome/common/extensions/extension.h" | 39 #include "chrome/common/extensions/extension.h" |
40 #include "chrome/common/extensions/extension_constants.h" | 40 #include "chrome/common/extensions/extension_constants.h" |
41 #include "chrome/common/jstemplate_builder.h" | 41 #include "chrome/common/jstemplate_builder.h" |
42 #include "chrome/common/pref_names.h" | 42 #include "chrome/common/pref_names.h" |
43 #include "chrome/common/url_constants.h" | 43 #include "chrome/common/url_constants.h" |
44 #include "content/public/browser/browser_thread.h" | 44 #include "content/public/browser/browser_thread.h" |
45 #include "content/public/browser/notification_service.h" | 45 #include "content/public/browser/notification_service.h" |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 GetUrlWithLang(GURL(new_tab_link)))); | 291 GetUrlWithLang(GURL(new_tab_link)))); |
292 localized_strings.SetString("extensionsmessage", | 292 localized_strings.SetString("extensionsmessage", |
293 l10n_util::GetStringFUTF16( | 293 l10n_util::GetStringFUTF16( |
294 IDS_NEW_TAB_OTR_EXTENSIONS_MESSAGE, | 294 IDS_NEW_TAB_OTR_EXTENSIONS_MESSAGE, |
295 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | 295 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), |
296 ASCIIToUTF16(chrome::kChromeUIExtensionsURL))); | 296 ASCIIToUTF16(chrome::kChromeUIExtensionsURL))); |
297 bool bookmark_bar_attached = profile_->GetPrefs()->GetBoolean( | 297 bool bookmark_bar_attached = profile_->GetPrefs()->GetBoolean( |
298 prefs::kShowBookmarkBar); | 298 prefs::kShowBookmarkBar); |
299 localized_strings.SetBoolean("bookmarkbarattached", bookmark_bar_attached); | 299 localized_strings.SetBoolean("bookmarkbarattached", bookmark_bar_attached); |
300 | 300 |
301 URLDataSource::SetFontAndTextDirection(&localized_strings); | 301 web_ui_util::SetFontAndTextDirection(&localized_strings); |
302 | 302 |
303 static const base::StringPiece incognito_tab_html( | 303 static const base::StringPiece incognito_tab_html( |
304 ResourceBundle::GetSharedInstance().GetRawDataResource( | 304 ResourceBundle::GetSharedInstance().GetRawDataResource( |
305 new_tab_html_idr)); | 305 new_tab_html_idr)); |
306 | 306 |
307 std::string full_html = jstemplate_builder::GetI18nTemplateHtml( | 307 std::string full_html = jstemplate_builder::GetI18nTemplateHtml( |
308 incognito_tab_html, &localized_strings); | 308 incognito_tab_html, &localized_strings); |
309 | 309 |
310 new_tab_incognito_html_ = base::RefCountedString::TakeString(&full_html); | 310 new_tab_incognito_html_ = base::RefCountedString::TakeString(&full_html); |
311 } | 311 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 is_swipe_tracking_from_scroll_events_enabled_); | 408 is_swipe_tracking_from_scroll_events_enabled_); |
409 | 409 |
410 #if defined(OS_CHROMEOS) | 410 #if defined(OS_CHROMEOS) |
411 load_time_data.SetString("expandMenu", | 411 load_time_data.SetString("expandMenu", |
412 l10n_util::GetStringUTF16(IDS_NEW_TAB_CLOSE_MENU_EXPAND)); | 412 l10n_util::GetStringUTF16(IDS_NEW_TAB_CLOSE_MENU_EXPAND)); |
413 #endif | 413 #endif |
414 | 414 |
415 NewTabPageHandler::GetLocalizedValues(profile_, &load_time_data); | 415 NewTabPageHandler::GetLocalizedValues(profile_, &load_time_data); |
416 NTPLoginHandler::GetLocalizedValues(profile_, &load_time_data); | 416 NTPLoginHandler::GetLocalizedValues(profile_, &load_time_data); |
417 | 417 |
418 URLDataSource::SetFontAndTextDirection(&load_time_data); | 418 web_ui_util::SetFontAndTextDirection(&load_time_data); |
419 | 419 |
420 // Control fade and resize animations. | 420 // Control fade and resize animations. |
421 load_time_data.SetBoolean("anim", ui::Animation::ShouldRenderRichAnimation()); | 421 load_time_data.SetBoolean("anim", ui::Animation::ShouldRenderRichAnimation()); |
422 | 422 |
423 int alignment; | 423 int alignment; |
424 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); | 424 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); |
425 tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_ALIGNMENT, &alignment); | 425 tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_ALIGNMENT, &alignment); |
426 load_time_data.SetString("themegravity", | 426 load_time_data.SetString("themegravity", |
427 (alignment & ThemeService::ALIGN_RIGHT) ? "right" : ""); | 427 (alignment & ThemeService::ALIGN_RIGHT) ? "right" : ""); |
428 | 428 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 // Get our template. | 589 // Get our template. |
590 static const base::StringPiece new_tab_theme_css( | 590 static const base::StringPiece new_tab_theme_css( |
591 ResourceBundle::GetSharedInstance().GetRawDataResource(is_ntp_search ? | 591 ResourceBundle::GetSharedInstance().GetRawDataResource(is_ntp_search ? |
592 IDR_NEW_TAB_SEARCH_THEME_CSS : IDR_NEW_TAB_4_THEME_CSS)); | 592 IDR_NEW_TAB_SEARCH_THEME_CSS : IDR_NEW_TAB_4_THEME_CSS)); |
593 | 593 |
594 // Create the string from our template and the replacements. | 594 // Create the string from our template and the replacements. |
595 std::string css_string; | 595 std::string css_string; |
596 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); | 596 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
597 new_tab_css_ = base::RefCountedString::TakeString(&css_string); | 597 new_tab_css_ = base::RefCountedString::TakeString(&css_string); |
598 } | 598 } |
OLD | NEW |