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

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: delete some theming code too 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 gfx::Image frame;
1251 // If there's no frame image provided for the specified id, then load 1248 if (images->count(prs_id)) {
1252 // the default provided frame. If that's not provided, skip this whole 1249 frame = (*images)[prs_id];
1253 // thing and just use the default images. 1250 } else {
1254 int prs_base_id = 0; 1251 // If there's no frame image provided for the specified id, then load
Evan Stade 2016/12/13 17:40:11 explanation of changes to this function. 1) This
1255 1252 // the default provided frame. If that's not provided, skip this whole
1256 if (!prs_base_id) { 1253 // thing and just use theme colors.
Peter Kasting 2016/12/14 04:27:54 Nit: The last sentence isn't really about what thi
Evan Stade 2016/12/15 03:31:14 Done.
1254 int prs_base_id = prs_id;
1257 if (prs_id == PRS_THEME_FRAME_INCOGNITO_INACTIVE) { 1255 if (prs_id == PRS_THEME_FRAME_INCOGNITO_INACTIVE) {
1258 prs_base_id = images->count(PRS_THEME_FRAME_INCOGNITO) ? 1256 prs_base_id = images->count(PRS_THEME_FRAME_INCOGNITO) ?
1259 PRS_THEME_FRAME_INCOGNITO : PRS_THEME_FRAME; 1257 PRS_THEME_FRAME_INCOGNITO : PRS_THEME_FRAME;
1260 } else if (prs_id == PRS_THEME_FRAME_OVERLAY_INACTIVE) { 1258 } else if (prs_id == PRS_THEME_FRAME_OVERLAY_INACTIVE) {
1261 prs_base_id = PRS_THEME_FRAME_OVERLAY; 1259 prs_base_id = PRS_THEME_FRAME_OVERLAY;
1262 } else if (prs_id == PRS_THEME_FRAME_INACTIVE) { 1260 } else if (prs_id == PRS_THEME_FRAME_INACTIVE) {
1263 prs_base_id = PRS_THEME_FRAME; 1261 prs_base_id = PRS_THEME_FRAME;
1264 } else if (prs_id == PRS_THEME_FRAME_INCOGNITO && 1262 } else if (prs_id == PRS_THEME_FRAME_INCOGNITO &&
1265 !images->count(PRS_THEME_FRAME_INCOGNITO)) { 1263 !images->count(PRS_THEME_FRAME_INCOGNITO)) {
1266 prs_base_id = PRS_THEME_FRAME; 1264 prs_base_id = PRS_THEME_FRAME;
1267 } else {
1268 prs_base_id = prs_id;
1269 } 1265 }
Peter Kasting 2016/12/14 04:27:54 Nit: This isn't much better (it's just as long), b
Evan Stade 2016/12/15 03:31:14 I further refined this for simplicity.
1266 if (prs_base_id != prs_id && images->count(prs_base_id))
1267 frame = (*images)[prs_base_id];
1270 } 1268 }
1271 if (images->count(prs_id)) { 1269
1272 frame = (*images)[prs_id];
1273 } else if (prs_base_id != prs_id && images->count(prs_base_id)) {
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();
Evan Stade 2016/12/13 17:40:11 3) this was a pointless assignment. This entire br
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()) { 1270 if (!frame.IsEmpty()) {
1288 temp_output[prs_id] = CreateHSLShiftedImage( 1271 temp_output[prs_id] = CreateHSLShiftedImage(
1289 frame, GetTintInternal(kFrameTintMap[i].value)); 1272 frame, GetTintInternal(kFrameTintMap[i].value));
1290 } 1273 }
1291 } 1274 }
1292 MergeImageCaches(temp_output, images); 1275 MergeImageCaches(temp_output, images);
1293 } 1276 }
1294 1277
1295 void BrowserThemePack::CreateTabBackgroundImages(ImageCache* images) const { 1278 void BrowserThemePack::CreateTabBackgroundImages(ImageCache* images) const {
1296 ImageCache temp_output; 1279 ImageCache temp_output;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 false, 1459 false,
1477 &bitmap_data)) { 1460 &bitmap_data)) {
1478 NOTREACHED() << "Unable to encode theme image for prs_id=" 1461 NOTREACHED() << "Unable to encode theme image for prs_id="
1479 << prs_id << " for scale_factor=" << scale_factors_[i]; 1462 << prs_id << " for scale_factor=" << scale_factors_[i];
1480 break; 1463 break;
1481 } 1464 }
1482 image_memory_[scaled_raw_id] = 1465 image_memory_[scaled_raw_id] =
1483 base::RefCountedBytes::TakeVector(&bitmap_data); 1466 base::RefCountedBytes::TakeVector(&bitmap_data);
1484 } 1467 }
1485 } 1468 }
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