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

Side by Side Diff: chrome/browser/sync/test/integration/bookmarks_helper.cc

Issue 24175004: Remove dependency on ui::ScaleFactor from ui/gfx (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix new usage of scale in FastShowPickler Created 7 years, 3 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
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/sync/test/integration/bookmarks_helper.h" 5 #include "chrome/browser/sync/test/integration/bookmarks_helper.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 gfx::Image image_b = favicon_data_b.image; 285 gfx::Image image_b = favicon_data_b.image;
286 286
287 if (image_a.IsEmpty() && image_b.IsEmpty()) 287 if (image_a.IsEmpty() && image_b.IsEmpty())
288 return true; // Two empty images are equivalent. 288 return true; // Two empty images are equivalent.
289 289
290 if (image_a.IsEmpty() != image_b.IsEmpty()) 290 if (image_a.IsEmpty() != image_b.IsEmpty())
291 return false; 291 return false;
292 292
293 // Compare only the 1x bitmaps as only those are synced. 293 // Compare only the 1x bitmaps as only those are synced.
294 SkBitmap bitmap_a = image_a.AsImageSkia().GetRepresentation( 294 SkBitmap bitmap_a = image_a.AsImageSkia().GetRepresentation(
295 ui::SCALE_FACTOR_100P).sk_bitmap(); 295 1.0f).sk_bitmap();
296 SkBitmap bitmap_b = image_b.AsImageSkia().GetRepresentation( 296 SkBitmap bitmap_b = image_b.AsImageSkia().GetRepresentation(
297 ui::SCALE_FACTOR_100P).sk_bitmap(); 297 1.0f).sk_bitmap();
298 return FaviconBitmapsMatch(bitmap_a, bitmap_b); 298 return FaviconBitmapsMatch(bitmap_a, bitmap_b);
299 } 299 }
300 300
301 // Does a deep comparison of BookmarkNode fields in |model_a| and |model_b|. 301 // Does a deep comparison of BookmarkNode fields in |model_a| and |model_b|.
302 // Returns true if they are all equal. 302 // Returns true if they are all equal.
303 bool NodesMatch(const BookmarkNode* node_a, const BookmarkNode* node_b) { 303 bool NodesMatch(const BookmarkNode* node_a, const BookmarkNode* node_b) {
304 if (node_a == NULL || node_b == NULL) 304 if (node_a == NULL || node_b == NULL)
305 return node_a == node_b; 305 return node_a == node_b;
306 if (node_a->is_folder() != node_b->is_folder()) { 306 if (node_a->is_folder() != node_b->is_folder()) {
307 LOG(ERROR) << "Cannot compare folder with bookmark"; 307 LOG(ERROR) << "Cannot compare folder with bookmark";
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 WideToUTF16(title)); 707 WideToUTF16(title));
708 } 708 }
709 709
710 gfx::Image CreateFavicon(SkColor color) { 710 gfx::Image CreateFavicon(SkColor color) {
711 const int dip_width = 16; 711 const int dip_width = 16;
712 const int dip_height = 16; 712 const int dip_height = 16;
713 std::vector<ui::ScaleFactor> favicon_scale_factors = 713 std::vector<ui::ScaleFactor> favicon_scale_factors =
714 FaviconUtil::GetFaviconScaleFactors(); 714 FaviconUtil::GetFaviconScaleFactors();
715 gfx::ImageSkia favicon; 715 gfx::ImageSkia favicon;
716 for (size_t i = 0; i < favicon_scale_factors.size(); ++i) { 716 for (size_t i = 0; i < favicon_scale_factors.size(); ++i) {
717 float scale = ui::GetScaleFactorScale(favicon_scale_factors[i]); 717 float scale = ui::GetImageScale(favicon_scale_factors[i]);
718 int pixel_width = dip_width * scale; 718 int pixel_width = dip_width * scale;
719 int pixel_height = dip_height * scale; 719 int pixel_height = dip_height * scale;
720 SkBitmap bmp; 720 SkBitmap bmp;
721 bmp.setConfig(SkBitmap::kARGB_8888_Config, pixel_width, pixel_height); 721 bmp.setConfig(SkBitmap::kARGB_8888_Config, pixel_width, pixel_height);
722 bmp.allocPixels(); 722 bmp.allocPixels();
723 bmp.eraseColor(color); 723 bmp.eraseColor(color);
724 favicon.AddRepresentation(gfx::ImageSkiaRep(bmp, favicon_scale_factors[i])); 724 favicon.AddRepresentation(
725 gfx::ImageSkiaRep(bmp,
726 ui::GetImageScale(favicon_scale_factors[i])));
725 } 727 }
726 return gfx::Image(favicon); 728 return gfx::Image(favicon);
727 } 729 }
728 730
729 gfx::Image Create1xFaviconFromPNGFile(const std::string& path) { 731 gfx::Image Create1xFaviconFromPNGFile(const std::string& path) {
730 const char* kPNGExtension = ".png"; 732 const char* kPNGExtension = ".png";
731 if (!EndsWith(path, kPNGExtension, false)) 733 if (!EndsWith(path, kPNGExtension, false))
732 return gfx::Image(); 734 return gfx::Image();
733 735
734 base::FilePath full_path; 736 base::FilePath full_path;
(...skipping 21 matching lines...) Expand all
756 758
757 std::wstring IndexedSubfolderName(int i) { 759 std::wstring IndexedSubfolderName(int i) {
758 return base::StringPrintf(L"Subfolder Name %d", i); 760 return base::StringPrintf(L"Subfolder Name %d", i);
759 } 761 }
760 762
761 std::wstring IndexedSubsubfolderName(int i) { 763 std::wstring IndexedSubsubfolderName(int i) {
762 return base::StringPrintf(L"Subsubfolder Name %d", i); 764 return base::StringPrintf(L"Subsubfolder Name %d", i);
763 } 765 }
764 766
765 } // namespace bookmarks_helper 767 } // namespace bookmarks_helper
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698