Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "apps/launcher.h" | 5 #include "apps/launcher.h" |
| 6 | 6 |
| 7 #include "apps/browser/api/app_runtime/app_runtime_api.h" | 7 #include "apps/browser/api/app_runtime/app_runtime_api.h" |
| 8 #include "apps/browser/file_handler_util.h" | 8 #include "apps/browser/file_handler_util.h" |
| 9 #include "apps/common/api/app_runtime.h" | 9 #include "apps/common/api/app_runtime.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 } | 82 } |
| 83 | 83 |
| 84 // Helper method to launch the platform app |extension| with no data. This | 84 // Helper method to launch the platform app |extension| with no data. This |
| 85 // should be called in the fallback case, where it has been impossible to | 85 // should be called in the fallback case, where it has been impossible to |
| 86 // load or obtain file launch data. | 86 // load or obtain file launch data. |
| 87 void LaunchPlatformAppWithNoData(Profile* profile, const Extension* extension) { | 87 void LaunchPlatformAppWithNoData(Profile* profile, const Extension* extension) { |
| 88 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 88 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 89 AppEventRouter::DispatchOnLaunchedEvent(profile, extension); | 89 AppEventRouter::DispatchOnLaunchedEvent(profile, extension); |
| 90 } | 90 } |
| 91 | 91 |
| 92 // Class to handle launching of platform apps to open a specific path. | 92 // Class to handle launching of platform apps to open specific paths. |
| 93 // An instance of this class is created for each launch. The lifetime of these | 93 // An instance of this class is created for each launch. The lifetime of these |
| 94 // instances is managed by reference counted pointers. As long as an instance | 94 // instances is managed by reference counted pointers. As long as an instance |
| 95 // has outstanding tasks on a message queue it will be retained; once all | 95 // has outstanding tasks on a message queue it will be retained; once all |
| 96 // outstanding tasks are completed it will be deleted. | 96 // outstanding tasks are completed it will be deleted. |
| 97 class PlatformAppPathLauncher | 97 class PlatformAppPathLauncher |
| 98 : public base::RefCountedThreadSafe<PlatformAppPathLauncher> { | 98 : public base::RefCountedThreadSafe<PlatformAppPathLauncher> { |
| 99 public: | 99 public: |
| 100 PlatformAppPathLauncher(Profile* profile, | 100 PlatformAppPathLauncher(Profile* profile, |
| 101 const Extension* extension, | 101 const Extension* extension, |
| 102 const std::vector<base::FilePath>& file_paths) | |
| 103 : profile_(profile), extension_(extension), file_paths_(file_paths) {} | |
| 104 | |
| 105 PlatformAppPathLauncher(Profile* profile, | |
| 106 const Extension* extension, | |
| 102 const base::FilePath& file_path) | 107 const base::FilePath& file_path) |
| 103 : profile_(profile), extension_(extension), file_path_(file_path) {} | 108 : profile_(profile), extension_(extension) { |
| 109 if (!file_path.empty()) | |
| 110 file_paths_.push_back(file_path); | |
| 111 } | |
| 104 | 112 |
| 105 void Launch() { | 113 void Launch() { |
| 106 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 114 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 107 if (file_path_.empty()) { | 115 if (file_paths_.empty()) { |
| 108 LaunchPlatformAppWithNoData(profile_, extension_); | 116 LaunchPlatformAppWithNoData(profile_, extension_); |
| 109 return; | 117 return; |
| 110 } | 118 } |
| 111 | 119 |
| 112 DCHECK(file_path_.IsAbsolute()); | 120 for (size_t i = 0; i < file_paths_.size(); ++i) { |
| 121 DCHECK(file_paths_[i].IsAbsolute()); | |
| 122 } | |
| 113 | 123 |
| 114 if (HasFileSystemWritePermission(extension_)) { | 124 if (HasFileSystemWritePermission(extension_)) { |
| 115 std::vector<base::FilePath> paths; | |
| 116 paths.push_back(file_path_); | |
| 117 CheckWritableFiles( | 125 CheckWritableFiles( |
| 118 paths, | 126 file_paths_, |
| 119 profile_, | 127 profile_, |
| 120 false, | 128 false, |
| 121 base::Bind(&PlatformAppPathLauncher::OnFileValid, this), | 129 base::Bind(&PlatformAppPathLauncher::OnFileValid, this), |
| 122 base::Bind(&PlatformAppPathLauncher::OnFileInvalid, this)); | 130 base::Bind(&PlatformAppPathLauncher::OnFileInvalid, this)); |
| 123 return; | 131 return; |
| 124 } | 132 } |
| 125 | 133 |
| 126 OnFileValid(); | 134 OnFileValid(); |
| 127 } | 135 } |
| 128 | 136 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 141 } | 149 } |
| 142 | 150 |
| 143 private: | 151 private: |
| 144 friend class base::RefCountedThreadSafe<PlatformAppPathLauncher>; | 152 friend class base::RefCountedThreadSafe<PlatformAppPathLauncher>; |
| 145 | 153 |
| 146 virtual ~PlatformAppPathLauncher() {} | 154 virtual ~PlatformAppPathLauncher() {} |
| 147 | 155 |
| 148 void MakePathAbsolute(const base::FilePath& current_directory) { | 156 void MakePathAbsolute(const base::FilePath& current_directory) { |
| 149 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 157 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 150 | 158 |
| 151 if (!DoMakePathAbsolute(current_directory, &file_path_)) { | 159 for (std::vector<base::FilePath>::iterator it = file_paths_.begin(); |
| 152 LOG(WARNING) << "Cannot make absolute path from " << file_path_.value(); | 160 it != file_paths_.end(); |
| 153 file_path_ = base::FilePath(); | 161 ++it) { |
| 162 if (!DoMakePathAbsolute(current_directory, &*it)) { | |
| 163 LOG(WARNING) << "Cannot make absolute path from " << it->value(); | |
| 164 BrowserThread::PostTask( | |
| 165 BrowserThread::UI, | |
| 166 FROM_HERE, | |
| 167 base::Bind(&PlatformAppPathLauncher::LaunchWithNoLaunchData, this)); | |
| 168 return; | |
| 169 } | |
| 154 } | 170 } |
| 155 | 171 |
| 156 BrowserThread::PostTask(BrowserThread::UI, | 172 BrowserThread::PostTask(BrowserThread::UI, |
| 157 FROM_HERE, | 173 FROM_HERE, |
| 158 base::Bind(&PlatformAppPathLauncher::Launch, this)); | 174 base::Bind(&PlatformAppPathLauncher::Launch, this)); |
| 159 } | 175 } |
| 160 | 176 |
| 161 void OnFileValid() { | 177 void OnFileValid() { |
| 178 mime_types_.resize(file_paths_.size()); | |
| 162 #if defined(OS_CHROMEOS) | 179 #if defined(OS_CHROMEOS) |
| 163 if (file_manager::util::IsUnderNonNativeLocalPath(profile_, file_path_)) { | 180 GetNextNonNativeMimeType(); |
| 164 file_manager::util::GetNonNativeLocalPathMimeType( | 181 #else |
| 165 profile_, | 182 GetMimeTypesAndLaunch(); |
|
kinaba
2014/06/04 02:29:59
PostTask(FILE) is needed, I guess.
benwells
2014/06/04 02:55:38
Yes, good catch. Looking back at the last patch to
hirono
2014/06/04 04:02:23
Fixed. Thank you!
| |
| 166 file_path_, | |
| 167 base::Bind(&PlatformAppPathLauncher::OnGotMimeType, this)); | |
| 168 return; | |
| 169 } | |
| 170 #endif | 183 #endif |
| 171 | |
| 172 BrowserThread::PostTask( | |
| 173 BrowserThread::FILE, | |
| 174 FROM_HERE, | |
| 175 base::Bind(&PlatformAppPathLauncher::GetMimeTypeAndLaunch, this)); | |
| 176 } | 184 } |
| 177 | 185 |
| 178 void OnFileInvalid(const base::FilePath& /* error_path */) { | 186 void OnFileInvalid(const base::FilePath& /* error_path */) { |
| 179 LaunchWithNoLaunchData(); | 187 LaunchWithNoLaunchData(); |
| 180 } | 188 } |
| 181 | 189 |
| 182 void GetMimeTypeAndLaunch() { | 190 #if defined(OS_CHROMEOS) |
| 183 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 191 void GetNextNonNativeMimeType() { |
| 192 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 184 | 193 |
| 185 // If the file doesn't exist, or is a directory, launch with no launch data. | 194 bool any_native_files = false; |
| 186 if (!base::PathExists(file_path_) || | 195 for (size_t i = 0; i < mime_types_.size(); ++i) { |
| 187 base::DirectoryExists(file_path_)) { | 196 if (!mime_types_[i].empty()) |
| 188 LOG(WARNING) << "No file exists with path " << file_path_.value(); | 197 continue; |
| 189 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 198 const base::FilePath& file_path = file_paths_[i]; |
| 190 &PlatformAppPathLauncher::LaunchWithNoLaunchData, this)); | 199 if (file_manager::util::IsUnderNonNativeLocalPath(profile_, file_path)) { |
| 200 file_manager::util::GetNonNativeLocalPathMimeType( | |
| 201 profile_, | |
| 202 file_path, | |
| 203 base::Bind(&PlatformAppPathLauncher::OnGotMimeType, this, i)); | |
| 204 return; | |
| 205 } | |
| 206 any_native_files = true; | |
| 207 } | |
| 208 | |
| 209 // If there are any native files, we need to call GetMimeTypesAndLaunch to | |
| 210 // obtain mime types for the files. | |
| 211 if (any_native_files) { | |
| 212 BrowserThread::PostTask( | |
| 213 BrowserThread::FILE, | |
| 214 FROM_HERE, | |
| 215 base::Bind(&PlatformAppPathLauncher::GetMimeTypesAndLaunch, this)); | |
| 191 return; | 216 return; |
| 192 } | 217 } |
| 193 | 218 |
| 194 std::string mime_type; | 219 // Otherwise, we can call LaunchWithMimeTypes directly. |
| 195 if (!net::GetMimeTypeFromFile(file_path_, &mime_type)) { | 220 LaunchWithMimeTypes(); |
| 196 // If MIME type of the file can't be determined by its path, | |
| 197 // try to sniff it by its content. | |
| 198 std::vector<char> content(net::kMaxBytesToSniff); | |
| 199 int bytes_read = base::ReadFile(file_path_, &content[0], content.size()); | |
| 200 if (bytes_read >= 0) { | |
| 201 net::SniffMimeType(&content[0], | |
| 202 bytes_read, | |
| 203 net::FilePathToFileURL(file_path_), | |
| 204 std::string(), // type_hint (passes no hint) | |
| 205 &mime_type); | |
| 206 } | |
| 207 if (mime_type.empty()) | |
| 208 mime_type = kFallbackMimeType; | |
| 209 } | |
| 210 | |
| 211 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | |
| 212 &PlatformAppPathLauncher::LaunchWithMimeType, this, mime_type)); | |
| 213 } | 221 } |
| 214 | 222 |
| 215 #if defined(OS_CHROMEOS) | 223 void OnGotMimeType(size_t index, bool success, const std::string& mime_type) { |
| 216 void OnGotMimeType(bool success, const std::string& mime_type) { | |
| 217 if (!success) { | 224 if (!success) { |
| 218 LaunchWithNoLaunchData(); | 225 LaunchWithNoLaunchData(); |
| 219 return; | 226 return; |
| 220 } | 227 } |
| 221 LaunchWithMimeType(mime_type.empty() ? kFallbackMimeType : mime_type); | 228 mime_types_[index] = mime_type.empty() ? kFallbackMimeType : mime_type; |
| 229 GetNextNonNativeMimeType(); | |
| 222 } | 230 } |
| 223 #endif | 231 #endif |
| 224 | 232 |
| 233 void GetMimeTypesAndLaunch() { | |
| 234 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | |
| 235 | |
| 236 for (size_t i = 0; i < mime_types_.size(); ++i) { | |
| 237 if (!this->mime_types_[i].empty()) | |
| 238 continue; | |
| 239 const base::FilePath& file_path = file_paths_[i]; | |
| 240 | |
| 241 // If the file doesn't exist, or is a directory, launch with no launch | |
| 242 // data. | |
| 243 if (!base::PathExists(file_path) || base::DirectoryExists(file_path)) { | |
| 244 LOG(WARNING) << "No file exists with path " << file_path.value(); | |
| 245 BrowserThread::PostTask( | |
| 246 BrowserThread::UI, | |
| 247 FROM_HERE, | |
| 248 base::Bind(&PlatformAppPathLauncher::LaunchWithNoLaunchData, this)); | |
| 249 return; | |
| 250 } | |
| 251 | |
| 252 std::string mime_type; | |
| 253 if (!net::GetMimeTypeFromFile(file_path, &mime_type)) { | |
| 254 // If MIME type of the file can't be determined by its path, | |
| 255 // try to sniff it by its content. | |
| 256 std::vector<char> content(net::kMaxBytesToSniff); | |
| 257 int bytes_read = base::ReadFile(file_path, &content[0], content.size()); | |
| 258 if (bytes_read >= 0) { | |
| 259 net::SniffMimeType(&content[0], | |
| 260 bytes_read, | |
| 261 net::FilePathToFileURL(file_path), | |
| 262 std::string(), // type_hint (passes no hint) | |
| 263 &mime_type); | |
| 264 } | |
| 265 if (mime_type.empty()) | |
| 266 mime_type = kFallbackMimeType; | |
| 267 } | |
| 268 mime_types_[i] = mime_type; | |
| 269 } | |
| 270 | |
| 271 BrowserThread::PostTask( | |
| 272 BrowserThread::UI, | |
| 273 FROM_HERE, | |
| 274 base::Bind(&PlatformAppPathLauncher::LaunchWithMimeTypes, this)); | |
| 275 } | |
| 276 | |
| 225 void LaunchWithNoLaunchData() { | 277 void LaunchWithNoLaunchData() { |
| 226 // This method is required as an entry point on the UI thread. | 278 // This method is required as an entry point on the UI thread. |
| 227 LaunchPlatformAppWithNoData(profile_, extension_); | 279 LaunchPlatformAppWithNoData(profile_, extension_); |
| 228 } | 280 } |
| 229 | 281 |
| 230 void LaunchWithMimeType(const std::string& mime_type) { | 282 void LaunchWithMimeTypes() { |
| 283 DCHECK(file_paths_.size() == mime_types_.size()); | |
| 284 | |
| 231 // Find file handler from the platform app for the file being opened. | 285 // Find file handler from the platform app for the file being opened. |
| 232 const extensions::FileHandlerInfo* handler = NULL; | 286 const extensions::FileHandlerInfo* handler = NULL; |
| 233 if (!handler_id_.empty()) | 287 if (!handler_id_.empty()) { |
| 234 handler = FileHandlerForId(*extension_, handler_id_); | 288 handler = FileHandlerForId(*extension_, handler_id_); |
| 235 else | 289 if (handler) { |
| 236 handler = FirstFileHandlerForFile(*extension_, mime_type, file_path_); | 290 for (size_t i = 0; i < file_paths_.size(); ++i) { |
| 237 if (handler && !FileHandlerCanHandleFile(*handler, mime_type, file_path_)) { | 291 if (!FileHandlerCanHandleFile( |
| 238 LOG(WARNING) << "Extension does not provide a valid file handler for " | 292 *handler, mime_types_[i], file_paths_[i])) { |
| 239 << file_path_.value(); | 293 LOG(WARNING) |
| 240 LaunchWithNoLaunchData(); | 294 << "Extension does not provide a valid file handler for " |
| 241 return; | 295 << file_paths_[i].value(); |
| 296 handler = NULL; | |
| 297 break; | |
| 298 } | |
| 299 } | |
| 300 } | |
| 301 } else { | |
| 302 std::set<std::pair<base::FilePath, std::string> > path_and_file_type_set; | |
| 303 for (size_t i = 0; i < file_paths_.size(); ++i) { | |
| 304 path_and_file_type_set.insert( | |
| 305 std::make_pair(file_paths_[i], mime_types_[i])); | |
| 306 } | |
| 307 const std::vector<const extensions::FileHandlerInfo*>& handlers = | |
| 308 extensions::app_file_handler_util::FindFileHandlersForFiles( | |
| 309 *extension_, path_and_file_type_set); | |
| 310 if (!handlers.empty()) | |
| 311 handler = handlers[0]; | |
| 242 } | 312 } |
| 243 | 313 |
| 244 // If this app doesn't have a file handler that supports the file, launch | 314 // If this app doesn't have a file handler that supports the file, launch |
| 245 // with no launch data. | 315 // with no launch data. |
| 246 if (!handler) { | 316 if (!handler) { |
| 247 LOG(WARNING) << "Extension does not provide a valid file handler for " | 317 LOG(WARNING) << "Extension does not provide a valid file handler."; |
| 248 << file_path_.value(); | |
| 249 LaunchWithNoLaunchData(); | 318 LaunchWithNoLaunchData(); |
| 250 return; | 319 return; |
| 251 } | 320 } |
| 252 | 321 |
| 253 if (handler_id_.empty()) | 322 if (handler_id_.empty()) |
| 254 handler_id_ = handler->id; | 323 handler_id_ = handler->id; |
| 255 | 324 |
| 256 // Access needs to be granted to the file for the process associated with | 325 // Access needs to be granted to the file for the process associated with |
| 257 // the extension. To do this the ExtensionHost is needed. This might not be | 326 // the extension. To do this the ExtensionHost is needed. This might not be |
| 258 // available, or it might be in the process of being unloaded, in which case | 327 // available, or it might be in the process of being unloaded, in which case |
| 259 // the lazy background task queue is used to load the extension and then | 328 // the lazy background task queue is used to load the extension and then |
| 260 // call back to us. | 329 // call back to us. |
| 261 extensions::LazyBackgroundTaskQueue* queue = | 330 extensions::LazyBackgroundTaskQueue* const queue = |
| 262 ExtensionSystem::Get(profile_)->lazy_background_task_queue(); | 331 ExtensionSystem::Get(profile_)->lazy_background_task_queue(); |
| 263 if (queue->ShouldEnqueueTask(profile_, extension_)) { | 332 if (queue->ShouldEnqueueTask(profile_, extension_)) { |
| 264 queue->AddPendingTask(profile_, extension_->id(), base::Bind( | 333 queue->AddPendingTask( |
| 265 &PlatformAppPathLauncher::GrantAccessToFileAndLaunch, | 334 profile_, |
| 266 this, mime_type)); | 335 extension_->id(), |
| 336 base::Bind(&PlatformAppPathLauncher::GrantAccessToFilesAndLaunch, | |
| 337 this)); | |
| 267 return; | 338 return; |
| 268 } | 339 } |
| 269 | 340 |
| 270 extensions::ProcessManager* process_manager = | 341 extensions::ProcessManager* const process_manager = |
| 271 ExtensionSystem::Get(profile_)->process_manager(); | 342 ExtensionSystem::Get(profile_)->process_manager(); |
| 272 ExtensionHost* host = | 343 ExtensionHost* const host = |
| 273 process_manager->GetBackgroundHostForExtension(extension_->id()); | 344 process_manager->GetBackgroundHostForExtension(extension_->id()); |
| 274 DCHECK(host); | 345 DCHECK(host); |
| 275 GrantAccessToFileAndLaunch(mime_type, host); | 346 GrantAccessToFilesAndLaunch(host); |
| 276 } | 347 } |
| 277 | 348 |
| 278 void GrantAccessToFileAndLaunch(const std::string& mime_type, | 349 void GrantAccessToFilesAndLaunch(ExtensionHost* host) { |
| 279 ExtensionHost* host) { | |
| 280 // If there was an error loading the app page, |host| will be NULL. | 350 // If there was an error loading the app page, |host| will be NULL. |
| 281 if (!host) { | 351 if (!host) { |
| 282 LOG(ERROR) << "Could not load app page for " << extension_->id(); | 352 LOG(ERROR) << "Could not load app page for " << extension_->id(); |
| 283 return; | 353 return; |
| 284 } | 354 } |
| 285 | 355 |
| 286 GrantedFileEntry file_entry = | 356 std::vector<GrantedFileEntry> file_entries; |
| 287 CreateFileEntry(profile_, | 357 for (size_t i = 0; i < file_paths_.size(); ++i) { |
| 288 extension_, | 358 file_entries.push_back( |
| 289 host->render_process_host()->GetID(), | 359 CreateFileEntry(profile_, |
| 290 file_path_, | 360 extension_, |
| 291 false); | 361 host->render_process_host()->GetID(), |
| 292 AppEventRouter::DispatchOnLaunchedEventWithFileEntry( | 362 file_paths_[i], |
| 293 profile_, extension_, handler_id_, mime_type, file_entry); | 363 false)); |
| 364 } | |
| 365 | |
| 366 AppEventRouter::DispatchOnLaunchedEventWithFileEntries( | |
| 367 profile_, extension_, handler_id_, mime_types_, file_entries); | |
| 294 } | 368 } |
| 295 | 369 |
| 296 // The profile the app should be run in. | 370 // The profile the app should be run in. |
| 297 Profile* profile_; | 371 Profile* profile_; |
| 298 // The extension providing the app. | 372 // The extension providing the app. |
| 299 // TODO(benwells): Hold onto the extension ID instead of a pointer as it | 373 // TODO(benwells): Hold onto the extension ID instead of a pointer as it |
| 300 // is possible the extension will be unloaded while we're doing our thing. | 374 // is possible the extension will be unloaded while we're doing our thing. |
| 301 // See http://crbug.com/372270 for details. | 375 // See http://crbug.com/372270 for details. |
| 302 const Extension* extension_; | 376 const Extension* extension_; |
| 303 // The path to be passed through to the app. | 377 // The path to be passed through to the app. |
| 304 base::FilePath file_path_; | 378 std::vector<base::FilePath> file_paths_; |
| 379 std::vector<std::string> mime_types_; | |
| 305 // The ID of the file handler used to launch the app. | 380 // The ID of the file handler used to launch the app. |
| 306 std::string handler_id_; | 381 std::string handler_id_; |
| 307 | 382 |
| 308 DISALLOW_COPY_AND_ASSIGN(PlatformAppPathLauncher); | 383 DISALLOW_COPY_AND_ASSIGN(PlatformAppPathLauncher); |
| 309 }; | 384 }; |
| 310 | 385 |
| 311 } // namespace | 386 } // namespace |
| 312 | 387 |
| 313 void LaunchPlatformAppWithCommandLine(Profile* profile, | 388 void LaunchPlatformAppWithCommandLine(Profile* profile, |
| 314 const Extension* extension, | 389 const Extension* extension, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 launcher->Launch(); | 437 launcher->Launch(); |
| 363 } | 438 } |
| 364 | 439 |
| 365 void LaunchPlatformApp(Profile* profile, const Extension* extension) { | 440 void LaunchPlatformApp(Profile* profile, const Extension* extension) { |
| 366 LaunchPlatformAppWithCommandLine(profile, | 441 LaunchPlatformAppWithCommandLine(profile, |
| 367 extension, | 442 extension, |
| 368 CommandLine(CommandLine::NO_PROGRAM), | 443 CommandLine(CommandLine::NO_PROGRAM), |
| 369 base::FilePath()); | 444 base::FilePath()); |
| 370 } | 445 } |
| 371 | 446 |
| 372 void LaunchPlatformAppWithFileHandler(Profile* profile, | 447 void LaunchPlatformAppWithFileHandler( |
| 373 const Extension* extension, | 448 Profile* profile, |
| 374 const std::string& handler_id, | 449 const Extension* extension, |
| 375 const base::FilePath& file_path) { | 450 const std::string& handler_id, |
| 451 const std::vector<base::FilePath>& file_paths) { | |
| 376 scoped_refptr<PlatformAppPathLauncher> launcher = | 452 scoped_refptr<PlatformAppPathLauncher> launcher = |
| 377 new PlatformAppPathLauncher(profile, extension, file_path); | 453 new PlatformAppPathLauncher(profile, extension, file_paths); |
| 378 launcher->LaunchWithHandler(handler_id); | 454 launcher->LaunchWithHandler(handler_id); |
| 379 } | 455 } |
| 380 | 456 |
| 381 void RestartPlatformApp(Profile* profile, const Extension* extension) { | 457 void RestartPlatformApp(Profile* profile, const Extension* extension) { |
| 382 EventRouter* event_router = EventRouter::Get(profile); | 458 EventRouter* event_router = EventRouter::Get(profile); |
| 383 bool listening_to_restart = event_router-> | 459 bool listening_to_restart = event_router-> |
| 384 ExtensionHasEventListener(extension->id(), | 460 ExtensionHasEventListener(extension->id(), |
| 385 app_runtime::OnRestarted::kEventName); | 461 app_runtime::OnRestarted::kEventName); |
| 386 | 462 |
| 387 if (listening_to_restart) { | 463 if (listening_to_restart) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 404 void LaunchPlatformAppWithUrl(Profile* profile, | 480 void LaunchPlatformAppWithUrl(Profile* profile, |
| 405 const Extension* extension, | 481 const Extension* extension, |
| 406 const std::string& handler_id, | 482 const std::string& handler_id, |
| 407 const GURL& url, | 483 const GURL& url, |
| 408 const GURL& referrer_url) { | 484 const GURL& referrer_url) { |
| 409 AppEventRouter::DispatchOnLaunchedEventWithUrl( | 485 AppEventRouter::DispatchOnLaunchedEventWithUrl( |
| 410 profile, extension, handler_id, url, referrer_url); | 486 profile, extension, handler_id, url, referrer_url); |
| 411 } | 487 } |
| 412 | 488 |
| 413 } // namespace apps | 489 } // namespace apps |
| OLD | NEW |