| 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/json/json_writer.h" |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 Profile* profile, const Extension* extension) { | 123 Profile* profile, const Extension* extension) { |
| 124 // TODO(benwells): remove this logging. | 124 // TODO(benwells): remove this logging. |
| 125 LOG(ERROR) << "Dispatching onLaunched with no data."; | 125 LOG(ERROR) << "Dispatching onLaunched with no data."; |
| 126 profile->GetExtensionEventRouter()->DispatchEventToExtension( | 126 profile->GetExtensionEventRouter()->DispatchEventToExtension( |
| 127 extension->id(), kOnLaunchedEvent, "[]", NULL, GURL()); | 127 extension->id(), kOnLaunchedEvent, "[]", NULL, GURL()); |
| 128 } | 128 } |
| 129 | 129 |
| 130 // static. | 130 // static. |
| 131 void AppEventRouter::DispatchOnLaunchedEventWithFileEntry( | 131 void AppEventRouter::DispatchOnLaunchedEventWithFileEntry( |
| 132 Profile* profile, const Extension* extension, const string16& action, | 132 Profile* profile, const Extension* extension, const string16& action, |
| 133 const std::string& file_system_id, const FilePath& base_name) { | 133 const std::string& file_system_id, const std::string& base_name) { |
| 134 // TODO(benwells): remove this logging. | 134 // TODO(benwells): remove this logging. |
| 135 LOG(ERROR) << "Dispatching onLaunched with file entry."; | 135 LOG(ERROR) << "Dispatching onLaunched with file entry."; |
| 136 ListValue args; | 136 ListValue args; |
| 137 DictionaryValue* launch_data = new DictionaryValue(); | 137 DictionaryValue* launch_data = new DictionaryValue(); |
| 138 DictionaryValue* intent = new DictionaryValue(); | 138 DictionaryValue* intent = new DictionaryValue(); |
| 139 intent->SetString("action", UTF16ToUTF8(action)); | 139 intent->SetString("action", UTF16ToUTF8(action)); |
| 140 intent->SetString("type", "chrome-extension://fileentry"); | 140 intent->SetString("type", "chrome-extension://fileentry"); |
| 141 launch_data->Set("intent", intent); | 141 launch_data->Set("intent", intent); |
| 142 args.Append(launch_data); | 142 args.Append(launch_data); |
| 143 DictionaryValue* intent_data = new DictionaryValue(); | 143 DictionaryValue* intent_data = new DictionaryValue(); |
| 144 intent_data->SetString("format", "fileEntry"); | 144 intent_data->SetString("format", "fileEntry"); |
| 145 intent_data->SetString("fileSystemId", file_system_id); | 145 intent_data->SetString("fileSystemId", file_system_id); |
| 146 intent_data->SetString("baseName", base_name.value()); | 146 intent_data->SetString("baseName", base_name); |
| 147 args.Append(intent_data); | 147 args.Append(intent_data); |
| 148 std::string json_args; | 148 std::string json_args; |
| 149 base::JSONWriter::Write(&args, &json_args); | 149 base::JSONWriter::Write(&args, &json_args); |
| 150 profile->GetExtensionEventRouter()->DispatchEventToExtension( | 150 profile->GetExtensionEventRouter()->DispatchEventToExtension( |
| 151 extension->id(), kOnLaunchedEvent, json_args, NULL, GURL()); | 151 extension->id(), kOnLaunchedEvent, json_args, NULL, GURL()); |
| 152 } | 152 } |
| 153 | 153 |
| 154 // static. | 154 // static. |
| 155 void AppEventRouter::DispatchOnLaunchedEventWithWebIntent( | 155 void AppEventRouter::DispatchOnLaunchedEventWithWebIntent( |
| 156 Profile* profile, const Extension* extension, | 156 Profile* profile, const Extension* extension, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 187 NOTREACHED(); | 187 NOTREACHED(); |
| 188 break; | 188 break; |
| 189 } | 189 } |
| 190 std::string json_args; | 190 std::string json_args; |
| 191 base::JSONWriter::Write(&args, &json_args); | 191 base::JSONWriter::Write(&args, &json_args); |
| 192 profile->GetExtensionEventRouter()->DispatchEventToExtension( | 192 profile->GetExtensionEventRouter()->DispatchEventToExtension( |
| 193 extension->id(), kOnLaunchedEvent, json_args, NULL, GURL()); | 193 extension->id(), kOnLaunchedEvent, json_args, NULL, GURL()); |
| 194 } | 194 } |
| 195 | 195 |
| 196 } // namespace extensions | 196 } // namespace extensions |
| OLD | NEW |