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

Side by Side Diff: chrome/browser/ui/webui/app_launcher_login_handler.cc

Issue 2760133002: ui: Remove a bunch of uses of gfx::Canvas::ExtractImageRep() (Closed)
Patch Set: canvasbounds: nits Created 3 years, 9 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
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/ui/webui/app_launcher_login_handler.h" 5 #include "chrome/browser/ui/webui/app_launcher_login_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 28 matching lines...) Expand all
39 #include "content/public/browser/user_metrics.h" 39 #include "content/public/browser/user_metrics.h"
40 #include "content/public/browser/web_contents.h" 40 #include "content/public/browser/web_contents.h"
41 #include "content/public/browser/web_ui.h" 41 #include "content/public/browser/web_ui.h"
42 #include "content/public/common/page_zoom.h" 42 #include "content/public/common/page_zoom.h"
43 #include "net/base/escape.h" 43 #include "net/base/escape.h"
44 #include "skia/ext/image_operations.h" 44 #include "skia/ext/image_operations.h"
45 #include "ui/base/l10n/l10n_util.h" 45 #include "ui/base/l10n/l10n_util.h"
46 #include "ui/base/webui/web_ui_util.h" 46 #include "ui/base/webui/web_ui_util.h"
47 #include "ui/gfx/canvas.h" 47 #include "ui/gfx/canvas.h"
48 #include "ui/gfx/image/image.h" 48 #include "ui/gfx/image/image.h"
49 #include "ui/gfx/skia_util.h"
49 50
50 using content::OpenURLParams; 51 using content::OpenURLParams;
51 using content::Referrer; 52 using content::Referrer;
52 53
53 namespace { 54 namespace {
54 55
55 SkBitmap GetGAIAPictureForNTP(const gfx::Image& image) { 56 SkBitmap GetGAIAPictureForNTP(const gfx::Image& image) {
56 // This value must match the width and height value of login-status-icon 57 // This value must match the width and height value of login-status-icon
57 // in new_tab.css. 58 // in new_tab.css.
58 const int kLength = 27; 59 const int kLength = 27;
59 SkBitmap bmp = skia::ImageOperations::Resize(*image.ToSkBitmap(), 60 SkBitmap bmp = skia::ImageOperations::Resize(*image.ToSkBitmap(),
60 skia::ImageOperations::RESIZE_BEST, kLength, kLength); 61 skia::ImageOperations::RESIZE_BEST, kLength, kLength);
61 62
62 gfx::Canvas canvas(gfx::Size(kLength, kLength), 1.0f, false);
63 canvas.DrawImageInt(gfx::ImageSkia::CreateFrom1xBitmap(bmp), 0, 0);
64
65 // Draw a gray border on the inside of the icon. 63 // Draw a gray border on the inside of the icon.
66 SkColor color = SkColorSetARGB(83, 0, 0, 0); 64 sk_sp<SkSurface> surface =
67 canvas.DrawRect(gfx::Rect(0, 0, kLength - 1, kLength - 1), color); 65 SkSurface::MakeRasterDirect(bmp.info(), bmp.getPixels(), bmp.rowBytes());
68 66 SkPaint paint;
69 return canvas.ExtractImageRep().sk_bitmap(); 67 paint.setColor(SkColorSetARGB(83, 0, 0, 0));
68 paint.setStyle(SkPaint::kStroke_Style);
69 surface->getCanvas()->drawRect(
70 gfx::RectToSkRect(gfx::Rect(kLength - 1, kLength - 1)), paint);
71 return bmp;
70 } 72 }
71 73
72 // Puts the |content| into an element with the given CSS class. 74 // Puts the |content| into an element with the given CSS class.
73 base::string16 CreateElementWithClass(const base::string16& content, 75 base::string16 CreateElementWithClass(const base::string16& content,
74 const std::string& tag_name, 76 const std::string& tag_name,
75 const std::string& css_class, 77 const std::string& css_class,
76 const std::string& extends_tag) { 78 const std::string& extends_tag) {
77 base::string16 start_tag = base::ASCIIToUTF16("<" + tag_name + 79 base::string16 start_tag = base::ASCIIToUTF16("<" + tag_name +
78 " class='" + css_class + "' is='" + extends_tag + "'>"); 80 " class='" + css_class + "' is='" + extends_tag + "'>");
79 base::string16 end_tag = base::ASCIIToUTF16("</" + tag_name + ">"); 81 base::string16 end_tag = base::ASCIIToUTF16("</" + tag_name + ">");
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 values->SetString("login_status_message", message); 256 values->SetString("login_status_message", message);
255 values->SetString("login_status_url", 257 values->SetString("login_status_url",
256 hide_sync ? std::string() : chrome::kSyncLearnMoreURL); 258 hide_sync ? std::string() : chrome::kSyncLearnMoreURL);
257 values->SetString("login_status_advanced", 259 values->SetString("login_status_advanced",
258 hide_sync ? base::string16() : 260 hide_sync ? base::string16() :
259 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); 261 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED));
260 values->SetString("login_status_dismiss", 262 values->SetString("login_status_dismiss",
261 hide_sync ? base::string16() : 263 hide_sync ? base::string16() :
262 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); 264 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK));
263 } 265 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698