| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 7 #include <algorithm> |
| 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/stringprintf.h" |
| 14 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
| 15 #include "base/time.h" | 16 #include "base/time.h" |
| 16 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 17 #include "base/values.h" | 18 #include "base/values.h" |
| 18 #include "chrome/browser/google/google_util.h" | 19 #include "chrome/browser/google/google_util.h" |
| 19 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/themes/theme_service.h" | 22 #include "chrome/browser/themes/theme_service.h" |
| 22 #include "chrome/browser/themes/theme_service_factory.h" | 23 #include "chrome/browser/themes/theme_service_factory.h" |
| 23 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 24 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 const char kHelpContentUrl[] = | 77 const char kHelpContentUrl[] = |
| 77 "https://www.google.com/support/chrome/"; | 78 "https://www.google.com/support/chrome/"; |
| 78 | 79 |
| 79 string16 GetUrlWithLang(const GURL& url) { | 80 string16 GetUrlWithLang(const GURL& url) { |
| 80 return ASCIIToUTF16(google_util::AppendGoogleLocaleParam(url).spec()); | 81 return ASCIIToUTF16(google_util::AppendGoogleLocaleParam(url).spec()); |
| 81 } | 82 } |
| 82 | 83 |
| 83 std::string SkColorToRGBAString(SkColor color) { | 84 std::string SkColorToRGBAString(SkColor color) { |
| 84 // We convert the alpha using DoubleToString because StringPrintf will use | 85 // We convert the alpha using DoubleToString because StringPrintf will use |
| 85 // locale specific formatters (e.g., use , instead of . in German). | 86 // locale specific formatters (e.g., use , instead of . in German). |
| 86 return StringPrintf("rgba(%d,%d,%d,%s)", SkColorGetR(color), | 87 return base::StringPrintf( |
| 87 SkColorGetG(color), SkColorGetB(color), | 88 "rgba(%d,%d,%d,%s)", |
| 89 SkColorGetR(color), |
| 90 SkColorGetG(color), |
| 91 SkColorGetB(color), |
| 88 base::DoubleToString(SkColorGetA(color) / 255.0).c_str()); | 92 base::DoubleToString(SkColorGetA(color) / 255.0).c_str()); |
| 89 } | 93 } |
| 90 | 94 |
| 91 // Get the CSS string for the background position on the new tab page for the | 95 // Get the CSS string for the background position on the new tab page for the |
| 92 // states when the bar is attached or detached. | 96 // states when the bar is attached or detached. |
| 93 std::string GetNewTabBackgroundCSS(const ui::ThemeProvider* theme_provider, | 97 std::string GetNewTabBackgroundCSS(const ui::ThemeProvider* theme_provider, |
| 94 bool bar_attached) { | 98 bool bar_attached) { |
| 95 int alignment; | 99 int alignment; |
| 96 theme_provider->GetDisplayProperty( | 100 theme_provider->GetDisplayProperty( |
| 97 ThemeService::NTP_BACKGROUND_ALIGNMENT, &alignment); | 101 ThemeService::NTP_BACKGROUND_ALIGNMENT, &alignment); |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 std::string css_string; | 564 std::string css_string; |
| 561 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); | 565 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
| 562 css_string = ReplaceStringPlaceholders(css_string, subst2, NULL); | 566 css_string = ReplaceStringPlaceholders(css_string, subst2, NULL); |
| 563 css_string = ReplaceStringPlaceholders(css_string, subst3, NULL); | 567 css_string = ReplaceStringPlaceholders(css_string, subst3, NULL); |
| 564 | 568 |
| 565 new_tab_css_ = new RefCountedBytes; | 569 new_tab_css_ = new RefCountedBytes; |
| 566 new_tab_css_->data.resize(css_string.size()); | 570 new_tab_css_->data.resize(css_string.size()); |
| 567 std::copy(css_string.begin(), css_string.end(), | 571 std::copy(css_string.begin(), css_string.end(), |
| 568 new_tab_css_->data.begin()); | 572 new_tab_css_->data.begin()); |
| 569 } | 573 } |
| OLD | NEW |