OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/search/instant_service.h" | 5 #include "chrome/browser/search/instant_service.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 } | 325 } |
326 | 326 |
327 // Set colors. | 327 // Set colors. |
328 theme_info_->background_color = SkColorToRGBAColor(background_color); | 328 theme_info_->background_color = SkColorToRGBAColor(background_color); |
329 theme_info_->text_color = SkColorToRGBAColor(text_color); | 329 theme_info_->text_color = SkColorToRGBAColor(text_color); |
330 theme_info_->link_color = SkColorToRGBAColor(link_color); | 330 theme_info_->link_color = SkColorToRGBAColor(link_color); |
331 theme_info_->text_color_light = SkColorToRGBAColor(text_color_light); | 331 theme_info_->text_color_light = SkColorToRGBAColor(text_color_light); |
332 theme_info_->header_color = SkColorToRGBAColor(header_color); | 332 theme_info_->header_color = SkColorToRGBAColor(header_color); |
333 theme_info_->section_border_color = SkColorToRGBAColor(section_border_color); | 333 theme_info_->section_border_color = SkColorToRGBAColor(section_border_color); |
334 | 334 |
335 // Set logo for the theme. By default, use alternate logo. | 335 int logo_alternate = theme_service->GetDisplayProperty( |
336 theme_info_->logo_alternate = true; | 336 ThemeProperties::NTP_LOGO_ALTERNATE); |
337 int logo_alternate = 0; | 337 theme_info_->logo_alternate = logo_alternate == 1; |
338 if (theme_service->GetDisplayProperty( | |
339 ThemeProperties::NTP_LOGO_ALTERNATE, &logo_alternate)) | |
340 theme_info_->logo_alternate = logo_alternate == 1; | |
341 | 338 |
342 if (theme_service->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) { | 339 if (theme_service->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) { |
343 // Set theme id for theme background image url. | 340 // Set theme id for theme background image url. |
344 theme_info_->theme_id = theme_service->GetThemeID(); | 341 theme_info_->theme_id = theme_service->GetThemeID(); |
345 | 342 |
346 // Set theme background image horizontal alignment. | 343 // Set theme background image horizontal alignment. |
347 int alignment = 0; | 344 int alignment = theme_service->GetDisplayProperty( |
348 theme_service->GetDisplayProperty( | 345 ThemeProperties::NTP_BACKGROUND_ALIGNMENT); |
349 ThemeProperties::NTP_BACKGROUND_ALIGNMENT, &alignment); | |
350 if (alignment & ThemeProperties::ALIGN_LEFT) | 346 if (alignment & ThemeProperties::ALIGN_LEFT) |
351 theme_info_->image_horizontal_alignment = THEME_BKGRND_IMAGE_ALIGN_LEFT; | 347 theme_info_->image_horizontal_alignment = THEME_BKGRND_IMAGE_ALIGN_LEFT; |
352 else if (alignment & ThemeProperties::ALIGN_RIGHT) | 348 else if (alignment & ThemeProperties::ALIGN_RIGHT) |
353 theme_info_->image_horizontal_alignment = THEME_BKGRND_IMAGE_ALIGN_RIGHT; | 349 theme_info_->image_horizontal_alignment = THEME_BKGRND_IMAGE_ALIGN_RIGHT; |
354 else | 350 else |
355 theme_info_->image_horizontal_alignment = THEME_BKGRND_IMAGE_ALIGN_CENTER; | 351 theme_info_->image_horizontal_alignment = THEME_BKGRND_IMAGE_ALIGN_CENTER; |
356 | 352 |
357 // Set theme background image vertical alignment. | 353 // Set theme background image vertical alignment. |
358 if (alignment & ThemeProperties::ALIGN_TOP) | 354 if (alignment & ThemeProperties::ALIGN_TOP) |
359 theme_info_->image_vertical_alignment = THEME_BKGRND_IMAGE_ALIGN_TOP; | 355 theme_info_->image_vertical_alignment = THEME_BKGRND_IMAGE_ALIGN_TOP; |
360 else if (alignment & ThemeProperties::ALIGN_BOTTOM) | 356 else if (alignment & ThemeProperties::ALIGN_BOTTOM) |
361 theme_info_->image_vertical_alignment = THEME_BKGRND_IMAGE_ALIGN_BOTTOM; | 357 theme_info_->image_vertical_alignment = THEME_BKGRND_IMAGE_ALIGN_BOTTOM; |
362 else | 358 else |
363 theme_info_->image_vertical_alignment = THEME_BKGRND_IMAGE_ALIGN_CENTER; | 359 theme_info_->image_vertical_alignment = THEME_BKGRND_IMAGE_ALIGN_CENTER; |
364 | 360 |
365 // Set theme backgorund image tiling. | 361 // Set theme backgorund image tiling. |
366 int tiling = 0; | 362 int tiling = theme_service->GetDisplayProperty( |
367 theme_service->GetDisplayProperty(ThemeProperties::NTP_BACKGROUND_TILING, | 363 ThemeProperties::NTP_BACKGROUND_TILING); |
368 &tiling); | |
369 switch (tiling) { | 364 switch (tiling) { |
370 case ThemeProperties::NO_REPEAT: | 365 case ThemeProperties::NO_REPEAT: |
371 theme_info_->image_tiling = THEME_BKGRND_IMAGE_NO_REPEAT; | 366 theme_info_->image_tiling = THEME_BKGRND_IMAGE_NO_REPEAT; |
372 break; | 367 break; |
373 case ThemeProperties::REPEAT_X: | 368 case ThemeProperties::REPEAT_X: |
374 theme_info_->image_tiling = THEME_BKGRND_IMAGE_REPEAT_X; | 369 theme_info_->image_tiling = THEME_BKGRND_IMAGE_REPEAT_X; |
375 break; | 370 break; |
376 case ThemeProperties::REPEAT_Y: | 371 case ThemeProperties::REPEAT_Y: |
377 theme_info_->image_tiling = THEME_BKGRND_IMAGE_REPEAT_Y; | 372 theme_info_->image_tiling = THEME_BKGRND_IMAGE_REPEAT_Y; |
378 break; | 373 break; |
(...skipping 12 matching lines...) Expand all Loading... |
391 theme_service->HasCustomImage(IDR_THEME_NTP_ATTRIBUTION); | 386 theme_service->HasCustomImage(IDR_THEME_NTP_ATTRIBUTION); |
392 } | 387 } |
393 | 388 |
394 FOR_EACH_OBSERVER(InstantServiceObserver, observers_, | 389 FOR_EACH_OBSERVER(InstantServiceObserver, observers_, |
395 ThemeInfoChanged(*theme_info_)); | 390 ThemeInfoChanged(*theme_info_)); |
396 } | 391 } |
397 | 392 |
398 InstantNTPPrerenderer* InstantService::ntp_prerenderer() { | 393 InstantNTPPrerenderer* InstantService::ntp_prerenderer() { |
399 return &ntp_prerenderer_; | 394 return &ntp_prerenderer_; |
400 } | 395 } |
OLD | NEW |