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/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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 | 411 |
411 // static | 412 // static |
412 scoped_refptr<BrowserThemePack> BrowserThemePack::BuildFromExtension( | 413 scoped_refptr<BrowserThemePack> BrowserThemePack::BuildFromExtension( |
413 const Extension* extension) { | 414 const Extension* extension) { |
414 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 415 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
415 DCHECK(extension); | 416 DCHECK(extension); |
416 DCHECK(extension->is_theme()); | 417 DCHECK(extension->is_theme()); |
417 | 418 |
418 scoped_refptr<BrowserThemePack> pack(new BrowserThemePack); | 419 scoped_refptr<BrowserThemePack> pack(new BrowserThemePack); |
419 pack->BuildHeader(extension); | 420 pack->BuildHeader(extension); |
420 pack->BuildTintsFromJSON(extension->GetThemeTints()); | 421 pack->BuildTintsFromJSON(extensions::ThemeInfo::GetThemeTints(extension)); |
421 pack->BuildColorsFromJSON(extension->GetThemeColors()); | 422 pack->BuildColorsFromJSON(extensions::ThemeInfo::GetThemeColors(extension)); |
422 pack->BuildDisplayPropertiesFromJSON(extension->GetThemeDisplayProperties()); | 423 pack->BuildDisplayPropertiesFromJSON( |
| 424 extensions::ThemeInfo::GetThemeDisplayProperties(extension)); |
423 | 425 |
424 // Builds the images. (Image building is dependent on tints). | 426 // Builds the images. (Image building is dependent on tints). |
425 FilePathMap file_paths; | 427 FilePathMap file_paths; |
426 pack->ParseImageNamesFromJSON(extension->GetThemeImages(), | 428 pack->ParseImageNamesFromJSON( |
427 extension->path(), | 429 extensions::ThemeInfo::GetThemeImages(extension), |
428 &file_paths); | 430 extension->path(), |
| 431 &file_paths); |
429 pack->BuildSourceImagesArray(file_paths); | 432 pack->BuildSourceImagesArray(file_paths); |
430 | 433 |
431 if (!pack->LoadRawBitmapsTo(file_paths, &pack->images_on_ui_thread_)) | 434 if (!pack->LoadRawBitmapsTo(file_paths, &pack->images_on_ui_thread_)) |
432 return NULL; | 435 return NULL; |
433 | 436 |
434 pack->CopyImagesTo(pack->images_on_ui_thread_, &pack->images_on_file_thread_); | 437 pack->CopyImagesTo(pack->images_on_ui_thread_, &pack->images_on_file_thread_); |
435 | 438 |
436 pack->CreateImages(&pack->images_on_ui_thread_); | 439 pack->CreateImages(&pack->images_on_ui_thread_); |
437 pack->CreateImages(&pack->images_on_file_thread_); | 440 pack->CreateImages(&pack->images_on_file_thread_); |
438 | 441 |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 ui::ScaleFactor scale_factor) const { | 1178 ui::ScaleFactor scale_factor) const { |
1176 if (prs_id < 0) | 1179 if (prs_id < 0) |
1177 return -1; | 1180 return -1; |
1178 | 1181 |
1179 for (size_t i = 0; i < scale_factors_.size(); ++i) { | 1182 for (size_t i = 0; i < scale_factors_.size(); ++i) { |
1180 if (scale_factors_[i] == scale_factor) | 1183 if (scale_factors_[i] == scale_factor) |
1181 return static_cast<int>(kPersistingImagesLength * i) + prs_id; | 1184 return static_cast<int>(kPersistingImagesLength * i) + prs_id; |
1182 } | 1185 } |
1183 return -1; | 1186 return -1; |
1184 } | 1187 } |
OLD | NEW |