OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/apps/drive/drive_app_converter.h" | 5 #include "chrome/browser/apps/drive/drive_app_converter.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 if (drive_app_info_.app_name.empty() || | 111 if (drive_app_info_.app_name.empty() || |
112 !drive_app_info_.create_url.is_valid()) { | 112 !drive_app_info_.create_url.is_valid()) { |
113 base::ResetAndReturn(&finished_callback_).Run(this, false); | 113 base::ResetAndReturn(&finished_callback_).Run(this, false); |
114 return; | 114 return; |
115 } | 115 } |
116 | 116 |
117 web_app_.title = base::UTF8ToUTF16(drive_app_info_.app_name); | 117 web_app_.title = base::UTF8ToUTF16(drive_app_info_.app_name); |
118 web_app_.app_url = drive_app_info_.create_url; | 118 web_app_.app_url = drive_app_info_.create_url; |
119 | 119 |
120 const std::set<int> allowed_sizes(extension_misc::kExtensionIconSizes, | |
121 extension_misc::kExtensionIconSizes + | |
122 extension_misc::kNumExtensionIconSizes); | |
123 std::set<int> pending_sizes; | 120 std::set<int> pending_sizes; |
124 for (size_t i = 0; i < drive_app_info_.app_icons.size(); ++i) { | 121 for (size_t i = 0; i < drive_app_info_.app_icons.size(); ++i) { |
125 const int icon_size = drive_app_info_.app_icons[i].first; | 122 const int icon_size = drive_app_info_.app_icons[i].first; |
126 if (allowed_sizes.find(icon_size) == allowed_sizes.end() || | 123 if (pending_sizes.find(icon_size) != pending_sizes.end()) |
127 pending_sizes.find(icon_size) != pending_sizes.end()) { | |
128 continue; | 124 continue; |
129 } | |
130 | 125 |
131 pending_sizes.insert(icon_size); | 126 pending_sizes.insert(icon_size); |
132 const GURL& icon_url = drive_app_info_.app_icons[i].second; | 127 const GURL& icon_url = drive_app_info_.app_icons[i].second; |
133 IconFetcher* fetcher = new IconFetcher(this, icon_url, icon_size); | 128 IconFetcher* fetcher = new IconFetcher(this, icon_url, icon_size); |
134 fetchers_.push_back(fetcher); // Pass ownership to |fetchers|. | 129 fetchers_.push_back(fetcher); // Pass ownership to |fetchers|. |
135 fetcher->Start(); | 130 fetcher->Start(); |
136 } | 131 } |
137 | 132 |
138 if (fetchers_.empty()) | 133 if (fetchers_.empty()) |
139 StartInstall(); | 134 StartInstall(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 return; | 189 return; |
195 } | 190 } |
196 | 191 |
197 extension_ = crx_installer_->extension(); | 192 extension_ = crx_installer_->extension(); |
198 is_new_install_ = success && !crx_installer_->current_version().IsValid(); | 193 is_new_install_ = success && !crx_installer_->current_version().IsValid(); |
199 PostInstallCleanUp(); | 194 PostInstallCleanUp(); |
200 | 195 |
201 base::ResetAndReturn(&finished_callback_).Run(this, success); | 196 base::ResetAndReturn(&finished_callback_).Run(this, success); |
202 // |finished_callback_| could delete this. | 197 // |finished_callback_| could delete this. |
203 } | 198 } |
OLD | NEW |