| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #import "chrome/browser/ui/cocoa/passwords/account_avatar_fetcher_manager.h" | 5 #import "chrome/browser/ui/cocoa/passwords/account_avatar_fetcher_manager.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 8 #import "chrome/browser/ui/cocoa/passwords/credential_item_view.h" | 10 #import "chrome/browser/ui/cocoa/passwords/credential_item_view.h" |
| 9 #include "chrome/browser/ui/passwords/account_avatar_fetcher.h" | 11 #include "chrome/browser/ui/passwords/account_avatar_fetcher.h" |
| 10 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" | 12 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" |
| 11 #include "ui/gfx/image/image_skia.h" | 13 #include "ui/gfx/image/image_skia.h" |
| 12 #include "ui/gfx/image/image_skia_util_mac.h" | 14 #include "ui/gfx/image/image_skia_util_mac.h" |
| 13 | 15 |
| 14 class AccountAvatarFetcherBridge; | 16 class AccountAvatarFetcherBridge; |
| 15 | 17 |
| 16 @interface AccountAvatarFetcherManager() | 18 @interface AccountAvatarFetcherManager() |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 64 |
| 63 - (void)startRequestWithFetcher:(AccountAvatarFetcher*)fetcher { | 65 - (void)startRequestWithFetcher:(AccountAvatarFetcher*)fetcher { |
| 64 fetcher->Start(requestContext_.get()); | 66 fetcher->Start(requestContext_.get()); |
| 65 } | 67 } |
| 66 | 68 |
| 67 - (void)fetchAvatar:(const GURL&)avatarURL forView:(CredentialItemView*)view { | 69 - (void)fetchAvatar:(const GURL&)avatarURL forView:(CredentialItemView*)view { |
| 68 scoped_ptr<AccountAvatarFetcherBridge> bridge( | 70 scoped_ptr<AccountAvatarFetcherBridge> bridge( |
| 69 new AccountAvatarFetcherBridge(self, view)); | 71 new AccountAvatarFetcherBridge(self, view)); |
| 70 AccountAvatarFetcher* fetcher = | 72 AccountAvatarFetcher* fetcher = |
| 71 new AccountAvatarFetcher(avatarURL, bridge->AsWeakPtr()); | 73 new AccountAvatarFetcher(avatarURL, bridge->AsWeakPtr()); |
| 72 bridges_.push_back(bridge.Pass()); | 74 bridges_.push_back(std::move(bridge)); |
| 73 [self startRequestWithFetcher:fetcher]; | 75 [self startRequestWithFetcher:fetcher]; |
| 74 } | 76 } |
| 75 | 77 |
| 76 - (void)updateAvatar:(NSImage*)image | 78 - (void)updateAvatar:(NSImage*)image |
| 77 fromBridge:(AccountAvatarFetcherBridge*)bridge | 79 fromBridge:(AccountAvatarFetcherBridge*)bridge |
| 78 forView:(CredentialItemView*)view { | 80 forView:(CredentialItemView*)view { |
| 79 [view updateAvatar:image]; | 81 [view updateAvatar:image]; |
| 80 auto it = std::find(bridges_.begin(), bridges_.end(), bridge); | 82 auto it = std::find(bridges_.begin(), bridges_.end(), bridge); |
| 81 if (it != bridges_.end()) | 83 if (it != bridges_.end()) |
| 82 bridges_.erase(it); | 84 bridges_.erase(it); |
| 83 } | 85 } |
| 84 | 86 |
| 85 @end | 87 @end |
| OLD | NEW |