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/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 event->restrict_to_profile = profile; | 54 event->restrict_to_profile = profile; |
55 extensions::ExtensionSystem::Get(profile)->event_router()-> | 55 extensions::ExtensionSystem::Get(profile)->event_router()-> |
56 DispatchEventToExtension(extension->id(), event.Pass()); | 56 DispatchEventToExtension(extension->id(), event.Pass()); |
57 } | 57 } |
58 | 58 |
59 // static. | 59 // static. |
60 void AppEventRouter::DispatchOnLaunchedEventWithFileEntry( | 60 void AppEventRouter::DispatchOnLaunchedEventWithFileEntry( |
61 Profile* profile, const Extension* extension, | 61 Profile* profile, const Extension* extension, |
62 const std::string& handler_id, const std::string& mime_type, | 62 const std::string& handler_id, const std::string& mime_type, |
63 const extensions::app_file_handler_util::GrantedFileEntry& file_entry) { | 63 const extensions::app_file_handler_util::GrantedFileEntry& file_entry) { |
64 // TODO(sergeygs): Use the same way of creating an event (using the generated | |
65 // boilerplate) as below in DispatchOnLaunchedEventWithUrl. | |
66 scoped_ptr<base::ListValue> args(new base::ListValue()); | 64 scoped_ptr<base::ListValue> args(new base::ListValue()); |
67 base::DictionaryValue* launch_data = new base::DictionaryValue(); | 65 base::DictionaryValue* launch_data = new base::DictionaryValue(); |
68 launch_data->SetString("id", handler_id); | 66 launch_data->SetString("id", handler_id); |
69 base::DictionaryValue* launch_item = new base::DictionaryValue; | 67 base::DictionaryValue* launch_item = new base::DictionaryValue; |
70 launch_item->SetString("fileSystemId", file_entry.filesystem_id); | 68 launch_item->SetString("fileSystemId", file_entry.filesystem_id); |
71 launch_item->SetString("baseName", file_entry.registered_name); | 69 launch_item->SetString("baseName", file_entry.registered_name); |
72 launch_item->SetString("mimeType", mime_type); | 70 launch_item->SetString("mimeType", mime_type); |
73 launch_item->SetString("entryId", file_entry.id); | 71 launch_item->SetString("entryId", file_entry.id); |
74 base::ListValue* items = new base::ListValue; | 72 base::ListValue* items = new base::ListValue; |
75 items->Append(launch_item); | 73 items->Append(launch_item); |
76 launch_data->Set("items", items); | 74 launch_data->Set("items", items); |
77 args->Append(launch_data); | 75 args->Append(launch_data); |
78 DispatchOnLaunchedEventImpl(extension->id(), args.Pass(), profile); | 76 DispatchOnLaunchedEventImpl(extension->id(), args.Pass(), profile); |
79 } | 77 } |
80 | 78 |
81 // static. | |
82 void AppEventRouter::DispatchOnLaunchedEventWithUrl( | |
83 Profile* profile, | |
84 const Extension* extension, | |
85 const std::string& handler_id, | |
86 const GURL& url, | |
87 const GURL& referrer_url) { | |
88 api::app_runtime::LaunchData launch_data; | |
89 launch_data.id.reset(new std::string(handler_id)); | |
90 launch_data.url.reset(new std::string(url.spec())); | |
91 launch_data.referrer_url.reset(new std::string(referrer_url.spec())); | |
92 scoped_ptr<ListValue> args(new ListValue()); | |
93 args->Append(launch_data.ToValue().release()); | |
94 DispatchOnLaunchedEventImpl(extension->id(), args.Pass(), profile); | |
95 } | |
96 | |
97 } // namespace extensions | 79 } // namespace extensions |
OLD | NEW |