| 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/drive/drive_app_registry.h" | 5 #include "chrome/browser/drive/drive_app_registry.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 if (is_updating_) // There is already an update in progress. | 125 if (is_updating_) // There is already an update in progress. |
| 126 return; | 126 return; |
| 127 is_updating_ = true; | 127 is_updating_ = true; |
| 128 | 128 |
| 129 drive_service_->GetAppList( | 129 drive_service_->GetAppList( |
| 130 base::Bind(&DriveAppRegistry::UpdateAfterGetAppList, | 130 base::Bind(&DriveAppRegistry::UpdateAfterGetAppList, |
| 131 weak_ptr_factory_.GetWeakPtr())); | 131 weak_ptr_factory_.GetWeakPtr())); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void DriveAppRegistry::UpdateAfterGetAppList( | 134 void DriveAppRegistry::UpdateAfterGetAppList( |
| 135 google_apis::GDataErrorCode gdata_error, | 135 google_apis::DriveApiErrorCode gdata_error, |
| 136 scoped_ptr<google_apis::AppList> app_list) { | 136 scoped_ptr<google_apis::AppList> app_list) { |
| 137 DCHECK(thread_checker_.CalledOnValidThread()); | 137 DCHECK(thread_checker_.CalledOnValidThread()); |
| 138 | 138 |
| 139 DCHECK(is_updating_); | 139 DCHECK(is_updating_); |
| 140 is_updating_ = false; | 140 is_updating_ = false; |
| 141 | 141 |
| 142 // Failed to fetch the data from the server. We can do nothing here. | 142 // Failed to fetch the data from the server. We can do nothing here. |
| 143 if (gdata_error != google_apis::HTTP_SUCCESS) | 143 if (gdata_error != google_apis::HTTP_SUCCESS) |
| 144 return; | 144 return; |
| 145 | 145 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 204 |
| 205 drive_service_->UninstallApp(app_id, | 205 drive_service_->UninstallApp(app_id, |
| 206 base::Bind(&DriveAppRegistry::OnAppUninstalled, | 206 base::Bind(&DriveAppRegistry::OnAppUninstalled, |
| 207 weak_ptr_factory_.GetWeakPtr(), | 207 weak_ptr_factory_.GetWeakPtr(), |
| 208 app_id, | 208 app_id, |
| 209 callback)); | 209 callback)); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void DriveAppRegistry::OnAppUninstalled(const std::string& app_id, | 212 void DriveAppRegistry::OnAppUninstalled(const std::string& app_id, |
| 213 const UninstallCallback& callback, | 213 const UninstallCallback& callback, |
| 214 google_apis::GDataErrorCode error) { | 214 google_apis::DriveApiErrorCode error) { |
| 215 if (error == google_apis::HTTP_NO_CONTENT) { | 215 if (error == google_apis::HTTP_NO_CONTENT) { |
| 216 all_apps_.erase(app_id); | 216 all_apps_.erase(app_id); |
| 217 RemoveAppFromSelector(app_id, &mimetype_map_); | 217 RemoveAppFromSelector(app_id, &mimetype_map_); |
| 218 RemoveAppFromSelector(app_id, &extension_map_); | 218 RemoveAppFromSelector(app_id, &extension_map_); |
| 219 } | 219 } |
| 220 callback.Run(error); | 220 callback.Run(error); |
| 221 } | 221 } |
| 222 | 222 |
| 223 // static | 223 // static |
| 224 bool DriveAppRegistry::IsAppUninstallSupported() { | 224 bool DriveAppRegistry::IsAppUninstallSupported() { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 237 | 237 |
| 238 // Go forward while the size is larger or equal to preferred_size. | 238 // Go forward while the size is larger or equal to preferred_size. |
| 239 size_t i = 1; | 239 size_t i = 1; |
| 240 while (i < sorted_icons.size() && sorted_icons[i].first >= preferred_size) | 240 while (i < sorted_icons.size() && sorted_icons[i].first >= preferred_size) |
| 241 ++i; | 241 ++i; |
| 242 return sorted_icons[i - 1].second; | 242 return sorted_icons[i - 1].second; |
| 243 } | 243 } |
| 244 | 244 |
| 245 } // namespace util | 245 } // namespace util |
| 246 } // namespace drive | 246 } // namespace drive |
| OLD | NEW |