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

Side by Side Diff: chrome/browser/extensions/bookmark_app_helper.cc

Issue 289283004: Add ability to constrain dominant color selection to a HSL range. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove C++11 features Created 6 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/webui/ntp/favicon_webui_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/extensions/bookmark_app_helper.h" 5 #include "chrome/browser/extensions/bookmark_app_helper.h"
6 6
7 #include <cctype> 7 #include <cctype>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 if (!domain_and_registry.empty()) { 269 if (!domain_and_registry.empty()) {
270 icon_letter = domain_and_registry[0]; 270 icon_letter = domain_and_registry[0];
271 } else if (!app_url.host().empty()) { 271 } else if (!app_url.host().empty()) {
272 icon_letter = app_url.host()[0]; 272 icon_letter = app_url.host()[0];
273 } 273 }
274 274
275 // The color that will be used for the icon's background. 275 // The color that will be used for the icon's background.
276 SkColor background_color = SK_ColorBLACK; 276 SkColor background_color = SK_ColorBLACK;
277 if (resized_bitmaps.size()) { 277 if (resized_bitmaps.size()) {
278 color_utils::GridSampler sampler; 278 color_utils::GridSampler sampler;
279 background_color = color_utils::CalculateKMeanColorOfPNG( 279 background_color = color_utils::CalculateKMeanColorOfBitmap(
280 gfx::Image::CreateFrom1xBitmap(resized_bitmaps.begin()->second) 280 resized_bitmaps.begin()->second);
281 .As1xPNGBytes(),
282 100,
283 568,
284 &sampler);
285 } 281 }
286 282
287 for (std::set<int>::const_iterator it = generate_sizes.begin(); 283 for (std::set<int>::const_iterator it = generate_sizes.begin();
288 it != generate_sizes.end(); 284 it != generate_sizes.end();
289 ++it) { 285 ++it) {
290 GenerateIcon(&resized_bitmaps, *it, background_color, icon_letter); 286 GenerateIcon(&resized_bitmaps, *it, background_color, icon_letter);
291 // Also generate the 2x resource for this size. 287 // Also generate the 2x resource for this size.
292 GenerateIcon(&resized_bitmaps, *it * 2, background_color, icon_letter); 288 GenerateIcon(&resized_bitmaps, *it * 2, background_color, icon_letter);
293 } 289 }
294 } 290 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); 370 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback));
375 } 371 }
376 372
377 bool IsValidBookmarkAppUrl(const GURL& url) { 373 bool IsValidBookmarkAppUrl(const GURL& url) {
378 URLPattern origin_only_pattern(Extension::kValidWebExtentSchemes); 374 URLPattern origin_only_pattern(Extension::kValidWebExtentSchemes);
379 origin_only_pattern.SetMatchAllURLs(true); 375 origin_only_pattern.SetMatchAllURLs(true);
380 return url.is_valid() && origin_only_pattern.MatchesURL(url); 376 return url.is_valid() && origin_only_pattern.MatchesURL(url);
381 } 377 }
382 378
383 } // namespace extensions 379 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/ntp/favicon_webui_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698