OLD | NEW |
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/metro_pin_tab_helper_win.h" | 5 #include "chrome/browser/ui/metro_pin_tab_helper_win.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 const int kCaptionHeight = 20; | 78 const int kCaptionHeight = 20; |
79 const double kBoxFade = 0.75; | 79 const double kBoxFade = 0.75; |
80 | 80 |
81 if (bitmap.isNull()) | 81 if (bitmap.isNull()) |
82 return false; | 82 return false; |
83 | 83 |
84 // Fill the tile logo with the dominant color of the favicon bitmap. | 84 // Fill the tile logo with the dominant color of the favicon bitmap. |
85 SkColor dominant_color = color_utils::CalculateKMeanColorOfBitmap(bitmap); | 85 SkColor dominant_color = color_utils::CalculateKMeanColorOfBitmap(bitmap); |
86 SkPaint paint; | 86 SkPaint paint; |
87 paint.setColor(dominant_color); | 87 paint.setColor(dominant_color); |
88 gfx::Canvas canvas(gfx::Size(kLogoWidth, kLogoHeight), ui::SCALE_FACTOR_100P, | 88 gfx::Canvas canvas(gfx::Size(kLogoWidth, kLogoHeight), 1.0f, |
89 true); | 89 true); |
90 canvas.DrawRect(gfx::Rect(0, 0, kLogoWidth, kLogoHeight), paint); | 90 canvas.DrawRect(gfx::Rect(0, 0, kLogoWidth, kLogoHeight), paint); |
91 | 91 |
92 // Now paint a faded square for the favicon to go in. | 92 // Now paint a faded square for the favicon to go in. |
93 color_utils::HSL shift = {-1, -1, kBoxFade}; | 93 color_utils::HSL shift = {-1, -1, kBoxFade}; |
94 paint.setColor(color_utils::HSLShift(dominant_color, shift)); | 94 paint.setColor(color_utils::HSLShift(dominant_color, shift)); |
95 int box_left = (kLogoWidth - kBoxWidth) / 2; | 95 int box_left = (kLogoWidth - kBoxWidth) / 2; |
96 int box_top = (kLogoHeight - kCaptionHeight - kBoxHeight) / 2; | 96 int box_top = (kLogoHeight - kCaptionHeight - kBoxHeight) / 2; |
97 canvas.DrawRect(gfx::Rect(box_left, box_top, kBoxWidth, kBoxHeight), paint); | 97 canvas.DrawRect(gfx::Rect(box_left, box_top, kBoxWidth, kBoxHeight), paint); |
98 | 98 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 GURL url = web_contents()->GetURL(); | 376 GURL url = web_contents()->GetURL(); |
377 string16 url_str = UTF8ToUTF16(url.spec()); | 377 string16 url_str = UTF8ToUTF16(url.spec()); |
378 string16 title = web_contents()->GetTitle(); | 378 string16 title = web_contents()->GetTitle(); |
379 // TODO(oshima): Use scoped_ptr::Pass to pass it to other thread. | 379 // TODO(oshima): Use scoped_ptr::Pass to pass it to other thread. |
380 SkBitmap favicon; | 380 SkBitmap favicon; |
381 FaviconTabHelper* favicon_tab_helper = FaviconTabHelper::FromWebContents( | 381 FaviconTabHelper* favicon_tab_helper = FaviconTabHelper::FromWebContents( |
382 web_contents()); | 382 web_contents()); |
383 if (favicon_tab_helper->FaviconIsValid()) { | 383 if (favicon_tab_helper->FaviconIsValid()) { |
384 // Only the 1x bitmap data is needed. | 384 // Only the 1x bitmap data is needed. |
385 favicon = favicon_tab_helper->GetFavicon().AsImageSkia().GetRepresentation( | 385 favicon = favicon_tab_helper->GetFavicon().AsImageSkia().GetRepresentation( |
386 ui::SCALE_FACTOR_100P).sk_bitmap(); | 386 1.0f).sk_bitmap(); |
387 } | 387 } |
388 | 388 |
389 favicon_chooser_.reset(new FaviconChooser(this, title, url_str, favicon)); | 389 favicon_chooser_.reset(new FaviconChooser(this, title, url_str, favicon)); |
390 | 390 |
391 if (favicon_url_candidates_.empty()) { | 391 if (favicon_url_candidates_.empty()) { |
392 favicon_chooser_->UseChosenCandidate(); | 392 favicon_chooser_->UseChosenCandidate(); |
393 return; | 393 return; |
394 } | 394 } |
395 | 395 |
396 // Request all the candidates. | 396 // Request all the candidates. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 | 454 |
455 GURL url = web_contents()->GetURL(); | 455 GURL url = web_contents()->GetURL(); |
456 string16 tile_id = GenerateTileId(UTF8ToUTF16(url.spec())); | 456 string16 tile_id = GenerateTileId(UTF8ToUTF16(url.spec())); |
457 metro_un_pin_from_start_screen(tile_id, | 457 metro_un_pin_from_start_screen(tile_id, |
458 base::Bind(&PinPageReportUmaCallback)); | 458 base::Bind(&PinPageReportUmaCallback)); |
459 } | 459 } |
460 | 460 |
461 void MetroPinTabHelper::FaviconDownloaderFinished() { | 461 void MetroPinTabHelper::FaviconDownloaderFinished() { |
462 favicon_chooser_.reset(); | 462 favicon_chooser_.reset(); |
463 } | 463 } |
OLD | NEW |