| 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/extensions/api/runtime/chrome_runtime_api_delegate.h" | 5 #include "chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 163 |
| 164 void ChromeRuntimeAPIDelegate::RemoveUpdateObserver( | 164 void ChromeRuntimeAPIDelegate::RemoveUpdateObserver( |
| 165 extensions::UpdateObserver* observer) { | 165 extensions::UpdateObserver* observer) { |
| 166 if (registered_for_updates_) { | 166 if (registered_for_updates_) { |
| 167 ExtensionSystem::Get(browser_context_) | 167 ExtensionSystem::Get(browser_context_) |
| 168 ->extension_service() | 168 ->extension_service() |
| 169 ->RemoveUpdateObserver(observer); | 169 ->RemoveUpdateObserver(observer); |
| 170 } | 170 } |
| 171 } | 171 } |
| 172 | 172 |
| 173 base::Version ChromeRuntimeAPIDelegate::GetPreviousExtensionVersion( | |
| 174 const Extension* extension) { | |
| 175 // Get the previous version to check if this is an upgrade. | |
| 176 ExtensionService* service = | |
| 177 ExtensionSystem::Get(browser_context_)->extension_service(); | |
| 178 const Extension* old = service->GetExtensionById(extension->id(), true); | |
| 179 if (old) | |
| 180 return *old->version(); | |
| 181 return base::Version(); | |
| 182 } | |
| 183 | |
| 184 void ChromeRuntimeAPIDelegate::ReloadExtension( | 173 void ChromeRuntimeAPIDelegate::ReloadExtension( |
| 185 const std::string& extension_id) { | 174 const std::string& extension_id) { |
| 186 std::pair<base::TimeTicks, int>& reload_info = | 175 std::pair<base::TimeTicks, int>& reload_info = |
| 187 last_reload_time_[extension_id]; | 176 last_reload_time_[extension_id]; |
| 188 base::TimeTicks now = base::TimeTicks::Now(); | 177 base::TimeTicks now = base::TimeTicks::Now(); |
| 189 if (reload_info.first.is_null() || | 178 if (reload_info.first.is_null() || |
| 190 (now - reload_info.first).InMilliseconds() > kFastReloadTime) { | 179 (now - reload_info.first).InMilliseconds() > kFastReloadTime) { |
| 191 reload_info.second = 0; | 180 reload_info.second = 0; |
| 192 } else { | 181 } else { |
| 193 reload_info.second++; | 182 reload_info.second++; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 const UpdateCheckResult& result) { | 377 const UpdateCheckResult& result) { |
| 389 auto it = update_check_info_.find(extension_id); | 378 auto it = update_check_info_.find(extension_id); |
| 390 if (it == update_check_info_.end()) | 379 if (it == update_check_info_.end()) |
| 391 return; | 380 return; |
| 392 std::vector<UpdateCheckCallback> callbacks; | 381 std::vector<UpdateCheckCallback> callbacks; |
| 393 it->second.callbacks.swap(callbacks); | 382 it->second.callbacks.swap(callbacks); |
| 394 for (const auto& callback : callbacks) { | 383 for (const auto& callback : callbacks) { |
| 395 callback.Run(result); | 384 callback.Run(result); |
| 396 } | 385 } |
| 397 } | 386 } |
| OLD | NEW |