Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: chrome/browser/dom_ui/ntp_resource_cache.cc

Issue 3538014: Implement layout of NTP apps promo. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/dom_ui/ntp_resource_cache.h" 5 #include "chrome/browser/dom_ui/ntp_resource_cache.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "app/animation.h" 10 #include "app/animation.h"
11 #include "app/l10n_util.h" 11 #include "app/l10n_util.h"
12 #include "app/resource_bundle.h" 12 #include "app/resource_bundle.h"
13 #include "app/theme_provider.h" 13 #include "app/theme_provider.h"
14 #include "base/command_line.h"
14 #include "base/file_util.h" 15 #include "base/file_util.h"
15 #include "base/ref_counted_memory.h" 16 #include "base/ref_counted_memory.h"
16 #include "base/string16.h" 17 #include "base/string16.h"
17 #include "base/string_number_conversions.h" 18 #include "base/string_number_conversions.h"
18 #include "base/time.h" 19 #include "base/time.h"
19 #include "base/utf_string_conversions.h" 20 #include "base/utf_string_conversions.h"
20 #include "base/values.h" 21 #include "base/values.h"
21 #include "chrome/browser/chrome_thread.h" 22 #include "chrome/browser/chrome_thread.h"
22 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" 23 #include "chrome/browser/dom_ui/chrome_url_data_manager.h"
23 #include "chrome/browser/dom_ui/shown_sections_handler.h" 24 #include "chrome/browser/dom_ui/shown_sections_handler.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 localized_strings.SetString("applaunchtypepinned", 285 localized_strings.SetString("applaunchtypepinned",
285 l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_OPEN_PINNED)); 286 l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_OPEN_PINNED));
286 localized_strings.SetString("applaunchtyperegular", 287 localized_strings.SetString("applaunchtyperegular",
287 l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_OPEN_REGULAR)); 288 l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_OPEN_REGULAR));
288 localized_strings.SetString("applaunchtypefullscreen", 289 localized_strings.SetString("applaunchtypefullscreen",
289 l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_OPEN_FULLSCREEN)); 290 l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_OPEN_FULLSCREEN));
290 localized_strings.SetString("web_store_title", 291 localized_strings.SetString("web_store_title",
291 l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE)); 292 l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE));
292 localized_strings.SetString("web_store_url", 293 localized_strings.SetString("web_store_url",
293 GetUrlWithLang(GURL(Extension::ChromeStoreURL()))); 294 GetUrlWithLang(GURL(Extension::ChromeStoreURL())));
295 localized_strings.SetString("appspromohide",
296 l10n_util::GetStringUTF16(IDS_APPS_PROMO_HIDE));
297 localized_strings.SetString("appspromoheader",
298 l10n_util::GetStringUTF16(IDS_APPS_PROMO_HEADER));
299 localized_strings.SetString("appspromotext1",
300 l10n_util::GetStringUTF16(IDS_APPS_PROMO_TEXT_1));
301 localized_strings.SetString("appspromotext2",
302 l10n_util::GetStringUTF16(IDS_APPS_PROMO_TEXT_2));
303
304 localized_strings.SetString("appspromovisible",
305 CommandLine::ForCurrentProcess()->HasSwitch(
306 switches::kForceAppsPromoVisible) ? "true" : "false");
294 307
295 // Don't initiate the sync related message passing with the page if the sync 308 // Don't initiate the sync related message passing with the page if the sync
296 // code is not present. 309 // code is not present.
297 if (profile_->GetProfileSyncService()) 310 if (profile_->GetProfileSyncService())
298 localized_strings.SetString("syncispresent", "true"); 311 localized_strings.SetString("syncispresent", "true");
299 else 312 else
300 localized_strings.SetString("syncispresent", "false"); 313 localized_strings.SetString("syncispresent", "false");
301 314
302 ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings); 315 ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings);
303 316
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 SkColor color_section_link_underline = 425 SkColor color_section_link_underline =
413 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_LINK_UNDERLINE); 426 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_LINK_UNDERLINE);
414 SkColor color_section_header_text = 427 SkColor color_section_header_text =
415 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_HEADER_TEXT); 428 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_HEADER_TEXT);
416 SkColor color_section_header_text_hover = 429 SkColor color_section_header_text_hover =
417 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_HEADER_TEXT_HOVER); 430 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_HEADER_TEXT_HOVER);
418 SkColor color_section_header_rule = 431 SkColor color_section_header_rule =
419 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_HEADER_RULE); 432 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_HEADER_RULE);
420 SkColor color_section_header_rule_light = 433 SkColor color_section_header_rule_light =
421 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_HEADER_RULE_LIGHT); 434 tp->GetColor(BrowserThemeProvider::COLOR_NTP_SECTION_HEADER_RULE_LIGHT);
435 SkColor color_text_light =
436 tp->GetColor(BrowserThemeProvider::COLOR_NTP_TEXT_LIGHT);
422 437
423 SkColor color_header = 438 SkColor color_header =
424 tp->GetColor(BrowserThemeProvider::COLOR_NTP_HEADER); 439 tp->GetColor(BrowserThemeProvider::COLOR_NTP_HEADER);
425 // Generate a lighter color for the header gradients. 440 // Generate a lighter color for the header gradients.
426 color_utils::HSL header_lighter; 441 color_utils::HSL header_lighter;
427 color_utils::SkColorToHSL(color_header, &header_lighter); 442 color_utils::SkColorToHSL(color_header, &header_lighter);
428 header_lighter.l += (1 - header_lighter.l) * 0.33; 443 header_lighter.l += (1 - header_lighter.l) * 0.33;
429 SkColor color_header_gradient_light = 444 SkColor color_header_gradient_light =
430 color_utils::HSLToSkColor(header_lighter, SkColorGetA(color_header)); 445 color_utils::HSLToSkColor(header_lighter, SkColorGetA(color_header));
431 446
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 subst2.push_back(SkColorToRGBAString(color_section_link_underline)); // $$6 482 subst2.push_back(SkColorToRGBAString(color_section_link_underline)); // $$6
468 subst2.push_back(SkColorToRGBAString(color_section_header_text)); // $$7 483 subst2.push_back(SkColorToRGBAString(color_section_header_text)); // $$7
469 subst2.push_back(SkColorToRGBAString( 484 subst2.push_back(SkColorToRGBAString(
470 color_section_header_text_hover)); // $$8 485 color_section_header_text_hover)); // $$8
471 subst2.push_back(SkColorToRGBAString(color_section_header_rule)); // $$9 486 subst2.push_back(SkColorToRGBAString(color_section_header_rule)); // $$9
472 487
473 subst3.push_back(SkColorToRGBAString( 488 subst3.push_back(SkColorToRGBAString(
474 color_section_header_rule_light)); // $$$1 489 color_section_header_rule_light)); // $$$1
475 subst3.push_back(SkColorToRGBAString( 490 subst3.push_back(SkColorToRGBAString(
476 SkColorSetA(color_section_header_rule, 0))); // $$$2 491 SkColorSetA(color_section_header_rule, 0))); // $$$2
492 subst3.push_back(SkColorToRGBAString(color_text_light)); // $$$3
477 493
478 494
479 // Get our template. 495 // Get our template.
480 static const base::StringPiece new_tab_theme_css( 496 static const base::StringPiece new_tab_theme_css(
481 ResourceBundle::GetSharedInstance().GetRawDataResource( 497 ResourceBundle::GetSharedInstance().GetRawDataResource(
482 IDR_NEW_TAB_THEME_CSS)); 498 IDR_NEW_TAB_THEME_CSS));
483 499
484 // Create the string from our template and the replacements. 500 // Create the string from our template and the replacements.
485 std::string css_string; 501 std::string css_string;
486 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); 502 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL);
487 css_string = ReplaceStringPlaceholders(css_string, subst2, NULL); 503 css_string = ReplaceStringPlaceholders(css_string, subst2, NULL);
488 css_string = ReplaceStringPlaceholders(css_string, subst3, NULL); 504 css_string = ReplaceStringPlaceholders(css_string, subst3, NULL);
489 505
490 new_tab_css_ = new RefCountedBytes; 506 new_tab_css_ = new RefCountedBytes;
491 new_tab_css_->data.resize(css_string.size()); 507 new_tab_css_->data.resize(css_string.size());
492 std::copy(css_string.begin(), css_string.end(), 508 std::copy(css_string.begin(), css_string.end(),
493 new_tab_css_->data.begin()); 509 new_tab_css_->data.begin());
494 } 510 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698