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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 const Extension* extension) { | 184 const Extension* extension) { |
185 if (!dispatch_chrome_updated_event_) | 185 if (!dispatch_chrome_updated_event_) |
186 return; | 186 return; |
187 | 187 |
188 // Dispatch the onInstalled event with reason "chrome_update". | 188 // Dispatch the onInstalled event with reason "chrome_update". |
189 base::MessageLoop::current()->PostTask( | 189 base::MessageLoop::current()->PostTask( |
190 FROM_HERE, | 190 FROM_HERE, |
191 base::Bind(&RuntimeEventRouter::DispatchOnInstalledEvent, | 191 base::Bind(&RuntimeEventRouter::DispatchOnInstalledEvent, |
192 browser_context_, | 192 browser_context_, |
193 extension->id(), | 193 extension->id(), |
194 Version(), | 194 base::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, | 202 bool from_ephemeral, |
203 const std::string& old_name) { | 203 const std::string& old_name) { |
204 // Ephemeral apps are not considered to be installed and do not receive | 204 // Ephemeral apps are not considered to be installed and do not receive |
205 // the onInstalled() event. | 205 // the onInstalled() event. |
206 if (util::IsEphemeralApp(extension->id(), browser_context_)) | 206 if (util::IsEphemeralApp(extension->id(), browser_context_)) |
207 return; | 207 return; |
208 | 208 |
209 Version old_version = delegate_->GetPreviousExtensionVersion(extension); | 209 base::Version old_version = delegate_->GetPreviousExtensionVersion(extension); |
210 | 210 |
211 // Dispatch the onInstalled event. | 211 // Dispatch the onInstalled event. |
212 base::MessageLoop::current()->PostTask( | 212 base::MessageLoop::current()->PostTask( |
213 FROM_HERE, | 213 FROM_HERE, |
214 base::Bind(&RuntimeEventRouter::DispatchOnInstalledEvent, | 214 base::Bind(&RuntimeEventRouter::DispatchOnInstalledEvent, |
215 browser_context_, | 215 browser_context_, |
216 extension->id(), | 216 extension->id(), |
217 old_version, | 217 old_version, |
218 false)); | 218 false)); |
219 } | 219 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 void RuntimeEventRouter::DispatchOnStartupEvent( | 280 void RuntimeEventRouter::DispatchOnStartupEvent( |
281 content::BrowserContext* context, | 281 content::BrowserContext* context, |
282 const std::string& extension_id) { | 282 const std::string& extension_id) { |
283 DispatchOnStartupEventImpl(context, extension_id, true, NULL); | 283 DispatchOnStartupEventImpl(context, extension_id, true, NULL); |
284 } | 284 } |
285 | 285 |
286 // static | 286 // static |
287 void RuntimeEventRouter::DispatchOnInstalledEvent( | 287 void RuntimeEventRouter::DispatchOnInstalledEvent( |
288 content::BrowserContext* context, | 288 content::BrowserContext* context, |
289 const std::string& extension_id, | 289 const std::string& extension_id, |
290 const Version& old_version, | 290 const base::Version& old_version, |
291 bool chrome_updated) { | 291 bool chrome_updated) { |
292 if (!ExtensionsBrowserClient::Get()->IsValidContext(context)) | 292 if (!ExtensionsBrowserClient::Get()->IsValidContext(context)) |
293 return; | 293 return; |
294 ExtensionSystem* system = ExtensionSystem::Get(context); | 294 ExtensionSystem* system = ExtensionSystem::Get(context); |
295 if (!system) | 295 if (!system) |
296 return; | 296 return; |
297 | 297 |
298 scoped_ptr<base::ListValue> event_args(new base::ListValue()); | 298 scoped_ptr<base::ListValue> event_args(new base::ListValue()); |
299 base::DictionaryValue* info = new base::DictionaryValue(); | 299 base::DictionaryValue* info = new base::DictionaryValue(); |
300 event_args->Append(info); | 300 event_args->Append(info); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 content::ChildProcessSecurityPolicy* policy = | 526 content::ChildProcessSecurityPolicy* policy = |
527 content::ChildProcessSecurityPolicy::GetInstance(); | 527 content::ChildProcessSecurityPolicy::GetInstance(); |
528 policy->GrantReadFileSystem(renderer_id, filesystem_id); | 528 policy->GrantReadFileSystem(renderer_id, filesystem_id); |
529 base::DictionaryValue* dict = new base::DictionaryValue(); | 529 base::DictionaryValue* dict = new base::DictionaryValue(); |
530 dict->SetString("fileSystemId", filesystem_id); | 530 dict->SetString("fileSystemId", filesystem_id); |
531 dict->SetString("baseName", relative_path); | 531 dict->SetString("baseName", relative_path); |
532 return RespondNow(OneArgument(dict)); | 532 return RespondNow(OneArgument(dict)); |
533 } | 533 } |
534 | 534 |
535 } // namespace extensions | 535 } // namespace extensions |
OLD | NEW |