| 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/app_api.h" | 5 #include "chrome/browser/extensions/api/app/app_api.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" |
| 7 #include "base/values.h" | 8 #include "base/values.h" |
| 8 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/app_notification_manager.h" | 11 #include "chrome/browser/extensions/app_notification_manager.h" |
| 10 #include "chrome/browser/extensions/extension_event_router.h" | 12 #include "chrome/browser/extensions/extension_event_router.h" |
| 11 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
| 14 #include "chrome/common/extensions/extension.h" | 16 #include "chrome/common/extensions/extension.h" |
| 15 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
| 16 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
| 17 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 18 | 20 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 return true; | 116 return true; |
| 115 } | 117 } |
| 116 | 118 |
| 117 // static. | 119 // static. |
| 118 void AppEventRouter::DispatchOnLaunchedEvent( | 120 void AppEventRouter::DispatchOnLaunchedEvent( |
| 119 Profile* profile, const Extension* extension) { | 121 Profile* profile, const Extension* extension) { |
| 120 profile->GetExtensionEventRouter()->DispatchEventToExtension( | 122 profile->GetExtensionEventRouter()->DispatchEventToExtension( |
| 121 extension->id(), kOnLaunchedEvent, "[]", NULL, GURL()); | 123 extension->id(), kOnLaunchedEvent, "[]", NULL, GURL()); |
| 122 } | 124 } |
| 123 | 125 |
| 126 // static. |
| 127 void AppEventRouter::DispatchOnLaunchedEventWithFileEntry( |
| 128 Profile* profile, const Extension* extension, const string16& action, |
| 129 const std::string& file_system_id, const FilePath& base_name) { |
| 130 ListValue args; |
| 131 DictionaryValue* launch_data = new DictionaryValue(); |
| 132 DictionaryValue* intent = new DictionaryValue(); |
| 133 intent->SetString("action", UTF16ToUTF8(action)); |
| 134 launch_data->Set("intent", intent); |
| 135 intent->SetString("type", "chrome-extension://fileentry"); |
| 136 args.Append(launch_data); |
| 137 args.Append(Value::CreateStringValue(file_system_id)); |
| 138 #if defined(OS_WIN) |
| 139 args.Append(Value::CreateStringValue(UTF16ToUTF8(base_name.value()))); |
| 140 #else |
| 141 args.Append(Value::CreateStringValue(base_name.value())); |
| 142 #endif |
| 143 std::string json_args; |
| 144 base::JSONWriter::Write(&args, &json_args); |
| 145 profile->GetExtensionEventRouter()->DispatchEventToExtension( |
| 146 extension->id(), kOnLaunchedEvent, json_args, NULL, GURL()); |
| 147 } |
| 148 |
| 124 } // namespace extensions | 149 } // namespace extensions |
| OLD | NEW |