| 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 "extensions/browser/api/runtime/runtime_api.h" | 5 #include "extensions/browser/api/runtime/runtime_api.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 browser_context_, | 192 browser_context_, |
| 193 extension->id(), | 193 extension->id(), |
| 194 Version(), | 194 Version(), |
| 195 true)); | 195 true)); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void RuntimeAPI::OnExtensionWillBeInstalled( | 198 void RuntimeAPI::OnExtensionWillBeInstalled( |
| 199 content::BrowserContext* browser_context, | 199 content::BrowserContext* browser_context, |
| 200 const Extension* extension, | 200 const Extension* extension, |
| 201 bool is_update, | 201 bool is_update, |
| 202 bool from_ephemeral, | |
| 203 const std::string& old_name) { | 202 const std::string& old_name) { |
| 204 // Ephemeral apps are not considered to be installed and do not receive | |
| 205 // the onInstalled() event. | |
| 206 if (util::IsEphemeralApp(extension->id(), browser_context_)) | |
| 207 return; | |
| 208 | |
| 209 Version old_version = delegate_->GetPreviousExtensionVersion(extension); | 203 Version old_version = delegate_->GetPreviousExtensionVersion(extension); |
| 210 | 204 |
| 211 // Dispatch the onInstalled event. | 205 // Dispatch the onInstalled event. |
| 212 base::MessageLoop::current()->PostTask( | 206 base::MessageLoop::current()->PostTask( |
| 213 FROM_HERE, | 207 FROM_HERE, |
| 214 base::Bind(&RuntimeEventRouter::DispatchOnInstalledEvent, | 208 base::Bind(&RuntimeEventRouter::DispatchOnInstalledEvent, |
| 215 browser_context_, | 209 browser_context_, |
| 216 extension->id(), | 210 extension->id(), |
| 217 old_version, | 211 old_version, |
| 218 false)); | 212 false)); |
| 219 } | 213 } |
| 220 | 214 |
| 221 void RuntimeAPI::OnExtensionUninstalled( | 215 void RuntimeAPI::OnExtensionUninstalled( |
| 222 content::BrowserContext* browser_context, | 216 content::BrowserContext* browser_context, |
| 223 const Extension* extension, | 217 const Extension* extension, |
| 224 UninstallReason reason) { | 218 UninstallReason reason) { |
| 225 // Ephemeral apps are not considered to be installed, so the uninstall URL | |
| 226 // is not invoked when they are removed. | |
| 227 if (util::IsEphemeralApp(extension->id(), browser_context_)) | |
| 228 return; | |
| 229 | |
| 230 RuntimeEventRouter::OnExtensionUninstalled( | 219 RuntimeEventRouter::OnExtensionUninstalled( |
| 231 browser_context_, extension->id(), reason); | 220 browser_context_, extension->id(), reason); |
| 232 } | 221 } |
| 233 | 222 |
| 234 void RuntimeAPI::Shutdown() { | 223 void RuntimeAPI::Shutdown() { |
| 235 delegate_->RemoveUpdateObserver(this); | 224 delegate_->RemoveUpdateObserver(this); |
| 236 } | 225 } |
| 237 | 226 |
| 238 void RuntimeAPI::OnAppUpdateAvailable(const Extension* extension) { | 227 void RuntimeAPI::OnAppUpdateAvailable(const Extension* extension) { |
| 239 RuntimeEventRouter::DispatchOnUpdateAvailableEvent( | 228 RuntimeEventRouter::DispatchOnUpdateAvailableEvent( |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 content::ChildProcessSecurityPolicy* policy = | 515 content::ChildProcessSecurityPolicy* policy = |
| 527 content::ChildProcessSecurityPolicy::GetInstance(); | 516 content::ChildProcessSecurityPolicy::GetInstance(); |
| 528 policy->GrantReadFileSystem(renderer_id, filesystem_id); | 517 policy->GrantReadFileSystem(renderer_id, filesystem_id); |
| 529 base::DictionaryValue* dict = new base::DictionaryValue(); | 518 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 530 dict->SetString("fileSystemId", filesystem_id); | 519 dict->SetString("fileSystemId", filesystem_id); |
| 531 dict->SetString("baseName", relative_path); | 520 dict->SetString("baseName", relative_path); |
| 532 return RespondNow(OneArgument(dict)); | 521 return RespondNow(OneArgument(dict)); |
| 533 } | 522 } |
| 534 | 523 |
| 535 } // namespace extensions | 524 } // namespace extensions |
| OLD | NEW |