OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/app_runtime/app_runtime_api.h" | 5 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/string16.h" | 8 #include "base/string16.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/browser/extensions/event_router.h" | 12 #include "chrome/browser/extensions/event_router.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
16 #include "webkit/glue/web_intent_data.h" | 16 #include "webkit/glue/web_intent_data.h" |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 const char kOnLaunchedEvent[] = "app.runtime.onLaunched"; | 20 const char kOnLaunchedEvent[] = "app.runtime.onLaunched"; |
21 const char kOnRestartedEvent[] = "app.runtime.onRestarted"; | |
21 | 22 |
22 } // anonymous namespace | 23 } // anonymous namespace |
23 | 24 |
24 namespace extensions { | 25 namespace extensions { |
25 | 26 |
26 // static. | 27 // static. |
27 void AppEventRouter::DispatchOnLaunchedEvent( | 28 void AppEventRouter::DispatchOnLaunchedEvent( |
28 Profile* profile, const Extension* extension) { | 29 Profile* profile, const Extension* extension) { |
29 scoped_ptr<ListValue> arguments(new ListValue()); | 30 scoped_ptr<ListValue> arguments(new ListValue()); |
30 profile->GetExtensionEventRouter()->DispatchEventToExtension( | 31 profile->GetExtensionEventRouter()->DispatchEventToExtension( |
31 extension->id(), kOnLaunchedEvent, arguments.Pass(), NULL, GURL()); | 32 extension->id(), kOnLaunchedEvent, arguments.Pass(), NULL, GURL()); |
32 } | 33 } |
33 | 34 |
34 // static. | 35 // static. |
36 void AppEventRouter::DispatchOnRestartEvent( | |
Mihai Parparita -not on Chrome
2012/09/04 04:14:48
Nit: should be called DispatchOnRestartedEvent.
koz (OOO until 15th September)
2012/09/04 07:10:20
Done.
| |
37 Profile* profile, const Extension* extension) { | |
38 scoped_ptr<ListValue> arguments(new ListValue()); | |
39 profile->GetExtensionEventRouter()->DispatchEventToExtension( | |
40 extension->id(), kOnRestartedEvent, arguments.Pass(), NULL, GURL()); | |
41 } | |
42 | |
43 // static. | |
35 void AppEventRouter::DispatchOnLaunchedEventWithFileEntry( | 44 void AppEventRouter::DispatchOnLaunchedEventWithFileEntry( |
36 Profile* profile, const Extension* extension, const string16& action, | 45 Profile* profile, const Extension* extension, const string16& action, |
37 const std::string& file_system_id, const std::string& base_name) { | 46 const std::string& file_system_id, const std::string& base_name) { |
38 scoped_ptr<ListValue> args(new ListValue()); | 47 scoped_ptr<ListValue> args(new ListValue()); |
39 DictionaryValue* launch_data = new DictionaryValue(); | 48 DictionaryValue* launch_data = new DictionaryValue(); |
40 DictionaryValue* intent = new DictionaryValue(); | 49 DictionaryValue* intent = new DictionaryValue(); |
41 intent->SetString("action", UTF16ToUTF8(action)); | 50 intent->SetString("action", UTF16ToUTF8(action)); |
42 intent->SetString("type", "chrome-extension://fileentry"); | 51 intent->SetString("type", "chrome-extension://fileentry"); |
43 launch_data->Set("intent", intent); | 52 launch_data->Set("intent", intent); |
44 args->Append(launch_data); | 53 args->Append(launch_data); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 break; | 98 break; |
90 default: | 99 default: |
91 NOTREACHED(); | 100 NOTREACHED(); |
92 break; | 101 break; |
93 } | 102 } |
94 profile->GetExtensionEventRouter()->DispatchEventToExtension( | 103 profile->GetExtensionEventRouter()->DispatchEventToExtension( |
95 extension->id(), kOnLaunchedEvent, args.Pass(), NULL, GURL()); | 104 extension->id(), kOnLaunchedEvent, args.Pass(), NULL, GURL()); |
96 } | 105 } |
97 | 106 |
98 } // namespace extensions | 107 } // namespace extensions |
OLD | NEW |