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/themes/browser_theme_pack.h" | 5 #include "chrome/browser/themes/browser_theme_pack.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/themes/theme_service.h" | 17 #include "chrome/browser/themes/theme_service.h" |
| 18 #include "chrome/common/extensions/api/themes/theme_handler.h" |
18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
19 #include "grit/theme_resources.h" | 20 #include "grit/theme_resources.h" |
20 #include "grit/ui_resources.h" | 21 #include "grit/ui_resources.h" |
21 #include "net/base/file_stream.h" | 22 #include "net/base/file_stream.h" |
22 #include "net/base/net_errors.h" | 23 #include "net/base/net_errors.h" |
23 #include "third_party/skia/include/core/SkCanvas.h" | 24 #include "third_party/skia/include/core/SkCanvas.h" |
24 #include "ui/base/resource/data_pack.h" | 25 #include "ui/base/resource/data_pack.h" |
25 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
26 #include "ui/gfx/canvas.h" | 27 #include "ui/gfx/canvas.h" |
27 #include "ui/gfx/codec/png_codec.h" | 28 #include "ui/gfx/codec/png_codec.h" |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 | 448 |
448 // static | 449 // static |
449 scoped_refptr<BrowserThemePack> BrowserThemePack::BuildFromExtension( | 450 scoped_refptr<BrowserThemePack> BrowserThemePack::BuildFromExtension( |
450 const Extension* extension) { | 451 const Extension* extension) { |
451 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 452 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
452 DCHECK(extension); | 453 DCHECK(extension); |
453 DCHECK(extension->is_theme()); | 454 DCHECK(extension->is_theme()); |
454 | 455 |
455 scoped_refptr<BrowserThemePack> pack(new BrowserThemePack); | 456 scoped_refptr<BrowserThemePack> pack(new BrowserThemePack); |
456 pack->BuildHeader(extension); | 457 pack->BuildHeader(extension); |
457 pack->BuildTintsFromJSON(extension->GetThemeTints()); | 458 pack->BuildTintsFromJSON(extensions::ThemeInfo::GetThemeTints(extension)); |
458 pack->BuildColorsFromJSON(extension->GetThemeColors()); | 459 pack->BuildColorsFromJSON(extensions::ThemeInfo::GetThemeColors(extension)); |
459 pack->BuildDisplayPropertiesFromJSON(extension->GetThemeDisplayProperties()); | 460 pack->BuildDisplayPropertiesFromJSON( |
| 461 extensions::ThemeInfo::GetThemeDisplayProperties(extension)); |
460 | 462 |
461 // Builds the images. (Image building is dependent on tints). | 463 // Builds the images. (Image building is dependent on tints). |
462 FilePathMap file_paths; | 464 FilePathMap file_paths; |
463 pack->ParseImageNamesFromJSON(extension->GetThemeImages(), | 465 pack->ParseImageNamesFromJSON( |
464 extension->path(), | 466 extensions::ThemeInfo::GetThemeImages(extension), |
465 &file_paths); | 467 extension->path(), |
| 468 &file_paths); |
466 pack->BuildSourceImagesArray(file_paths); | 469 pack->BuildSourceImagesArray(file_paths); |
467 | 470 |
468 if (!pack->LoadRawBitmapsTo(file_paths, &pack->images_on_ui_thread_)) | 471 if (!pack->LoadRawBitmapsTo(file_paths, &pack->images_on_ui_thread_)) |
469 return NULL; | 472 return NULL; |
470 | 473 |
471 pack->CopyImagesTo(pack->images_on_ui_thread_, &pack->images_on_file_thread_); | 474 pack->CopyImagesTo(pack->images_on_ui_thread_, &pack->images_on_file_thread_); |
472 | 475 |
473 pack->CreateImages(&pack->images_on_ui_thread_); | 476 pack->CreateImages(&pack->images_on_ui_thread_); |
474 pack->CreateImages(&pack->images_on_file_thread_); | 477 pack->CreateImages(&pack->images_on_file_thread_); |
475 | 478 |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 ui::ScaleFactor scale_factor) const { | 1216 ui::ScaleFactor scale_factor) const { |
1214 if (prs_id < 0) | 1217 if (prs_id < 0) |
1215 return -1; | 1218 return -1; |
1216 | 1219 |
1217 for (size_t i = 0; i < scale_factors_.size(); ++i) { | 1220 for (size_t i = 0; i < scale_factors_.size(); ++i) { |
1218 if (scale_factors_[i] == scale_factor) | 1221 if (scale_factors_[i] == scale_factor) |
1219 return static_cast<int>(kPersistingImagesLength * i) + prs_id; | 1222 return static_cast<int>(kPersistingImagesLength * i) + prs_id; |
1220 } | 1223 } |
1221 return -1; | 1224 return -1; |
1222 } | 1225 } |
OLD | NEW |