| 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> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 requestContext_ = requestContext; | 60 requestContext_ = requestContext; |
| 61 } | 61 } |
| 62 return self; | 62 return self; |
| 63 } | 63 } |
| 64 | 64 |
| 65 - (void)startRequestWithFetcher:(AccountAvatarFetcher*)fetcher { | 65 - (void)startRequestWithFetcher:(AccountAvatarFetcher*)fetcher { |
| 66 fetcher->Start(requestContext_.get()); | 66 fetcher->Start(requestContext_.get()); |
| 67 } | 67 } |
| 68 | 68 |
| 69 - (void)fetchAvatar:(const GURL&)avatarURL forView:(CredentialItemButton*)view { | 69 - (void)fetchAvatar:(const GURL&)avatarURL forView:(CredentialItemButton*)view { |
| 70 scoped_ptr<AccountAvatarFetcherBridge> bridge( | 70 std::unique_ptr<AccountAvatarFetcherBridge> bridge( |
| 71 new AccountAvatarFetcherBridge(self, view)); | 71 new AccountAvatarFetcherBridge(self, view)); |
| 72 AccountAvatarFetcher* fetcher = | 72 AccountAvatarFetcher* fetcher = |
| 73 new AccountAvatarFetcher(avatarURL, bridge->AsWeakPtr()); | 73 new AccountAvatarFetcher(avatarURL, bridge->AsWeakPtr()); |
| 74 bridges_.push_back(std::move(bridge)); | 74 bridges_.push_back(std::move(bridge)); |
| 75 [self startRequestWithFetcher:fetcher]; | 75 [self startRequestWithFetcher:fetcher]; |
| 76 } | 76 } |
| 77 | 77 |
| 78 - (void)updateAvatar:(NSImage*)image | 78 - (void)updateAvatar:(NSImage*)image |
| 79 fromBridge:(AccountAvatarFetcherBridge*)bridge | 79 fromBridge:(AccountAvatarFetcherBridge*)bridge |
| 80 forView:(CredentialItemButton*)view { | 80 forView:(CredentialItemButton*)view { |
| 81 [view setImage:image]; | 81 [view setImage:image]; |
| 82 auto it = std::find(bridges_.begin(), bridges_.end(), bridge); | 82 auto it = std::find(bridges_.begin(), bridges_.end(), bridge); |
| 83 if (it != bridges_.end()) | 83 if (it != bridges_.end()) |
| 84 bridges_.erase(it); | 84 bridges_.erase(it); |
| 85 } | 85 } |
| 86 | 86 |
| 87 @end | 87 @end |
| OLD | NEW |