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

Side by Side Diff: chrome/browser/themes/browser_theme_pack.cc

Issue 2568403004: Remove some theme images that are not used any more. (Closed)
Patch Set: fix Created 4 years 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
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 10 matching lines...) Expand all
21 #include "base/threading/thread_restrictions.h" 21 #include "base/threading/thread_restrictions.h"
22 #include "base/values.h" 22 #include "base/values.h"
23 #include "build/build_config.h" 23 #include "build/build_config.h"
24 #include "chrome/browser/themes/theme_properties.h" 24 #include "chrome/browser/themes/theme_properties.h"
25 #include "chrome/common/extensions/manifest_handlers/theme_handler.h" 25 #include "chrome/common/extensions/manifest_handlers/theme_handler.h"
26 #include "chrome/grit/theme_resources.h" 26 #include "chrome/grit/theme_resources.h"
27 #include "components/crx_file/id_util.h" 27 #include "components/crx_file/id_util.h"
28 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
29 #include "third_party/skia/include/core/SkCanvas.h" 29 #include "third_party/skia/include/core/SkCanvas.h"
30 #include "ui/base/resource/data_pack.h" 30 #include "ui/base/resource/data_pack.h"
31 #include "ui/base/resource/resource_bundle.h"
32 #include "ui/gfx/canvas.h" 31 #include "ui/gfx/canvas.h"
33 #include "ui/gfx/codec/png_codec.h" 32 #include "ui/gfx/codec/png_codec.h"
34 #include "ui/gfx/geometry/safe_integer_conversions.h" 33 #include "ui/gfx/geometry/safe_integer_conversions.h"
35 #include "ui/gfx/geometry/size_conversions.h" 34 #include "ui/gfx/geometry/size_conversions.h"
36 #include "ui/gfx/image/canvas_image_source.h" 35 #include "ui/gfx/image/canvas_image_source.h"
37 #include "ui/gfx/image/image.h" 36 #include "ui/gfx/image/image.h"
38 #include "ui/gfx/image/image_skia.h" 37 #include "ui/gfx/image/image_skia.h"
39 #include "ui/gfx/image/image_skia_operations.h" 38 #include "ui/gfx/image/image_skia_operations.h"
40 #include "ui/gfx/skia_util.h" 39 #include "ui/gfx/skia_util.h"
41 #include "ui/resources/grit/ui_resources.h" 40 #include "ui/resources/grit/ui_resources.h"
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 continue; 1231 continue;
1233 1232
1234 int crop_height = kImagesToCrop[i].max_height; 1233 int crop_height = kImagesToCrop[i].max_height;
1235 gfx::ImageSkia image_skia = it->second.AsImageSkia(); 1234 gfx::ImageSkia image_skia = it->second.AsImageSkia();
1236 (*images)[prs_id] = gfx::Image(gfx::ImageSkiaOperations::ExtractSubset( 1235 (*images)[prs_id] = gfx::Image(gfx::ImageSkiaOperations::ExtractSubset(
1237 image_skia, gfx::Rect(0, 0, image_skia.width(), crop_height))); 1236 image_skia, gfx::Rect(0, 0, image_skia.width(), crop_height)));
1238 } 1237 }
1239 } 1238 }
1240 1239
1241 void BrowserThemePack::CreateFrameImages(ImageCache* images) const { 1240 void BrowserThemePack::CreateFrameImages(ImageCache* images) const {
1242 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
1243
1244 // Create all the output images in a separate cache and move them back into 1241 // Create all the output images in a separate cache and move them back into
1245 // the input images because there can be name collisions. 1242 // the input images because there can be name collisions.
1246 ImageCache temp_output; 1243 ImageCache temp_output;
1247 1244
1248 for (size_t i = 0; i < arraysize(kFrameTintMap); ++i) { 1245 for (size_t i = 0; i < arraysize(kFrameTintMap); ++i) {
1249 int prs_id = kFrameTintMap[i].key; 1246 int prs_id = kFrameTintMap[i].key;
1250 gfx::Image frame; 1247 if (!images->count(prs_id)) {
1251 // If there's no frame image provided for the specified id, then load 1248 // Fall back from inactive incognito to active incognito.
1252 // the default provided frame. If that's not provided, skip this whole 1249 if (prs_id == PRS_THEME_FRAME_INCOGNITO_INACTIVE)
1253 // thing and just use the default images. 1250 prs_id = PRS_THEME_FRAME_INCOGNITO;
1254 int prs_base_id = 0;
1255 1251
1256 if (!prs_base_id) { 1252 // From there, fall back to the normal frame.
1257 if (prs_id == PRS_THEME_FRAME_INCOGNITO_INACTIVE) { 1253 if (!images->count(prs_id))
1258 prs_base_id = images->count(PRS_THEME_FRAME_INCOGNITO) ? 1254 prs_id = PRS_THEME_FRAME;
1259 PRS_THEME_FRAME_INCOGNITO : PRS_THEME_FRAME; 1255
1260 } else if (prs_id == PRS_THEME_FRAME_OVERLAY_INACTIVE) { 1256 // Fall back from inactive overlay to overlay, but stop there.
1261 prs_base_id = PRS_THEME_FRAME_OVERLAY; 1257 if (prs_id == PRS_THEME_FRAME_OVERLAY_INACTIVE)
1262 } else if (prs_id == PRS_THEME_FRAME_INACTIVE) { 1258 prs_id = PRS_THEME_FRAME_OVERLAY;
1263 prs_base_id = PRS_THEME_FRAME;
1264 } else if (prs_id == PRS_THEME_FRAME_INCOGNITO &&
1265 !images->count(PRS_THEME_FRAME_INCOGNITO)) {
1266 prs_base_id = PRS_THEME_FRAME;
1267 } else {
1268 prs_base_id = prs_id;
1269 }
1270 } 1259 }
1260
1261 // Note that if the original ID and all the fallbacks are absent, the caller
1262 // will rely on the frame colors instead.
1271 if (images->count(prs_id)) { 1263 if (images->count(prs_id)) {
1272 frame = (*images)[prs_id]; 1264 temp_output[kFrameTintMap[i].key] = CreateHSLShiftedImage(
1273 } else if (prs_base_id != prs_id && images->count(prs_base_id)) { 1265 (*images)[prs_id], GetTintInternal(kFrameTintMap[i].value));
1274 frame = (*images)[prs_base_id];
1275 } else if (prs_base_id == PRS_THEME_FRAME_OVERLAY) {
1276 if (images->count(PRS_THEME_FRAME)) {
1277 // If there is no theme overlay, don't tint the default frame,
1278 // because it will overwrite the custom frame image when we cache and
1279 // reload from disk.
1280 frame = gfx::Image();
1281 }
1282 } else {
1283 // If the theme doesn't specify an image, then apply the tint to
1284 // the default frame.
1285 frame = rb.GetImageNamed(IDR_THEME_FRAME);
1286 }
1287 if (!frame.IsEmpty()) {
1288 temp_output[prs_id] = CreateHSLShiftedImage(
1289 frame, GetTintInternal(kFrameTintMap[i].value));
1290 } 1266 }
1291 } 1267 }
1292 MergeImageCaches(temp_output, images); 1268 MergeImageCaches(temp_output, images);
1293 } 1269 }
1294 1270
1295 void BrowserThemePack::CreateTabBackgroundImages(ImageCache* images) const { 1271 void BrowserThemePack::CreateTabBackgroundImages(ImageCache* images) const {
1296 ImageCache temp_output; 1272 ImageCache temp_output;
1297 for (size_t i = 0; i < arraysize(kTabBackgroundMap); ++i) { 1273 for (size_t i = 0; i < arraysize(kTabBackgroundMap); ++i) {
1298 int prs_id = kTabBackgroundMap[i].key; 1274 int prs_id = kTabBackgroundMap[i].key;
1299 int prs_base_id = kTabBackgroundMap[i].value; 1275 int prs_base_id = kTabBackgroundMap[i].value;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 false, 1452 false,
1477 &bitmap_data)) { 1453 &bitmap_data)) {
1478 NOTREACHED() << "Unable to encode theme image for prs_id=" 1454 NOTREACHED() << "Unable to encode theme image for prs_id="
1479 << prs_id << " for scale_factor=" << scale_factors_[i]; 1455 << prs_id << " for scale_factor=" << scale_factors_[i];
1480 break; 1456 break;
1481 } 1457 }
1482 image_memory_[scaled_raw_id] = 1458 image_memory_[scaled_raw_id] =
1483 base::RefCountedBytes::TakeVector(&bitmap_data); 1459 base::RefCountedBytes::TakeVector(&bitmap_data);
1484 } 1460 }
1485 } 1461 }
OLDNEW
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698