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

Side by Side Diff: chrome/browser/ui/metro_pin_tab_helper_win.cc

Issue 11361131: Pass the ImageSkia by pointer instead of by reference, which will create shallow copy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win_aura Created 8 years, 1 month 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 | « chrome/browser/chromeos/login/wallpaper_manager.cc ('k') | ui/gfx/image/image_skia.h » ('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 (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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 for (std::vector<SkBitmap>::const_iterator iter = bitmaps.begin(); 330 for (std::vector<SkBitmap>::const_iterator iter = bitmaps.begin();
331 iter != bitmaps.end(); 331 iter != bitmaps.end();
332 ++iter) { 332 ++iter) {
333 333
334 // If the new bitmap is too big, ignore it. 334 // If the new bitmap is too big, ignore it.
335 if (iter->height() > kMaxIconSize || iter->width() > kMaxIconSize) 335 if (iter->height() > kMaxIconSize || iter->width() > kMaxIconSize)
336 continue; 336 continue;
337 337
338 // If we don't have a best candidate yet, this is better so just grab it. 338 // If we don't have a best candidate yet, this is better so just grab it.
339 if (best_candidate_.isNull()) { 339 if (best_candidate_.isNull()) {
340 best_candidate_ = gfx::ImageSkia(*iter).DeepCopy(); 340 best_candidate_ = *gfx::ImageSkia(*iter).DeepCopy().get();
341 continue; 341 continue;
342 } 342 }
343 343
344 // If it is smaller than our best one so far, ignore it. 344 // If it is smaller than our best one so far, ignore it.
345 if (iter->height() <= best_candidate_.height() || 345 if (iter->height() <= best_candidate_.height() ||
346 iter->width() <= best_candidate_.width()) { 346 iter->width() <= best_candidate_.width()) {
347 continue; 347 continue;
348 } 348 }
349 349
350 // Othewise it is our new best candidate. 350 // Othewise it is our new best candidate.
351 best_candidate_ = gfx::ImageSkia(*iter).DeepCopy(); 351 best_candidate_ = *gfx::ImageSkia(*iter).DeepCopy().get();
352 } 352 }
353 } 353 }
354 354
355 // If there are no more outstanding requests, pin the page on the FILE thread. 355 // If there are no more outstanding requests, pin the page on the FILE thread.
356 // Once this happens this downloader has done its job, so delete it. 356 // Once this happens this downloader has done its job, so delete it.
357 if (in_progress_requests_.empty()) { 357 if (in_progress_requests_.empty()) {
358 scoped_refptr<PinPageTaskRunner> runner( 358 scoped_refptr<PinPageTaskRunner> runner(
359 new PinPageTaskRunner(title_, url_, best_candidate_)); 359 new PinPageTaskRunner(title_, url_, best_candidate_));
360 runner->Run(); 360 runner->Run();
361 helper_->FaviconDownloaderFinished(); 361 helper_->FaviconDownloaderFinished();
(...skipping 26 matching lines...) Expand all
388 388
389 void MetroPinTabHelper::TogglePinnedToStartScreen() { 389 void MetroPinTabHelper::TogglePinnedToStartScreen() {
390 if (IsPinned()) { 390 if (IsPinned()) {
391 UnPinPageFromStartScreen(); 391 UnPinPageFromStartScreen();
392 return; 392 return;
393 } 393 }
394 394
395 GURL url = web_contents()->GetURL(); 395 GURL url = web_contents()->GetURL();
396 string16 url_str = UTF8ToUTF16(url.spec()); 396 string16 url_str = UTF8ToUTF16(url.spec());
397 string16 title = web_contents()->GetTitle(); 397 string16 title = web_contents()->GetTitle();
398 // TODO(oshima): Use scoped_ptr::Pass to pass it to other thread.
398 gfx::ImageSkia favicon; 399 gfx::ImageSkia favicon;
399 FaviconTabHelper* favicon_tab_helper = FaviconTabHelper::FromWebContents( 400 FaviconTabHelper* favicon_tab_helper = FaviconTabHelper::FromWebContents(
400 web_contents()); 401 web_contents());
401 if (favicon_tab_helper->FaviconIsValid()) 402 if (favicon_tab_helper->FaviconIsValid())
402 favicon = favicon_tab_helper->GetFavicon().AsImageSkia().DeepCopy(); 403 favicon = *favicon_tab_helper->GetFavicon().AsImageSkia().DeepCopy().get();
403 404
404 favicon_downloader_.reset(new FaviconDownloader(this, title, url_str, 405 favicon_downloader_.reset(new FaviconDownloader(this, title, url_str,
405 favicon)); 406 favicon));
406 favicon_downloader_->Start(web_contents()->GetRenderViewHost(), 407 favicon_downloader_->Start(web_contents()->GetRenderViewHost(),
407 favicon_url_candidates_); 408 favicon_url_candidates_);
408 } 409 }
409 410
410 void MetroPinTabHelper::DidNavigateMainFrame( 411 void MetroPinTabHelper::DidNavigateMainFrame(
411 const content::LoadCommittedDetails& /*details*/, 412 const content::LoadCommittedDetails& /*details*/,
412 const content::FrameNavigateParams& /*params*/) { 413 const content::FrameNavigateParams& /*params*/) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 } 461 }
461 462
462 GURL url = web_contents()->GetURL(); 463 GURL url = web_contents()->GetURL();
463 string16 tile_id = GenerateTileId(UTF8ToUTF16(url.spec())); 464 string16 tile_id = GenerateTileId(UTF8ToUTF16(url.spec()));
464 metro_un_pin_from_start_screen(tile_id); 465 metro_un_pin_from_start_screen(tile_id);
465 } 466 }
466 467
467 void MetroPinTabHelper::FaviconDownloaderFinished() { 468 void MetroPinTabHelper::FaviconDownloaderFinished() {
468 favicon_downloader_.reset(); 469 favicon_downloader_.reset();
469 } 470 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/wallpaper_manager.cc ('k') | ui/gfx/image/image_skia.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698