| 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/platform_app_launcher.h" | 5 #include "chrome/browser/extensions/platform_app_launcher.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 return; | 174 return; |
| 175 } | 175 } |
| 176 | 176 |
| 177 service->file_system()->GetFileByPath( | 177 service->file_system()->GetFileByPath( |
| 178 drive::util::ExtractDrivePath(file_path_), | 178 drive::util::ExtractDrivePath(file_path_), |
| 179 base::Bind(&PlatformAppPathLauncher::OnGotDriveFile, this)); | 179 base::Bind(&PlatformAppPathLauncher::OnGotDriveFile, this)); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void OnGotDriveFile(drive::FileError error, | 182 void OnGotDriveFile(drive::FileError error, |
| 183 const base::FilePath& file_path, | 183 const base::FilePath& file_path, |
| 184 const std::string& mime_type, | 184 scoped_ptr<drive::ResourceEntry> entry) { |
| 185 drive::DriveFileType file_type) { | |
| 186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 185 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 187 | 186 |
| 188 if (error != drive::FILE_ERROR_OK || file_type != drive::REGULAR_FILE) { | 187 if (error != drive::FILE_ERROR_OK || |
| 188 !entry || entry->file_specific_info().is_hosted_document()) { |
| 189 LaunchWithNoLaunchData(); | 189 LaunchWithNoLaunchData(); |
| 190 return; | 190 return; |
| 191 } | 191 } |
| 192 | 192 |
| 193 const std::string& mime_type = |
| 194 entry->file_specific_info().content_mime_type(); |
| 193 LaunchWithMimeType(mime_type.empty() ? kFallbackMimeType : mime_type); | 195 LaunchWithMimeType(mime_type.empty() ? kFallbackMimeType : mime_type); |
| 194 } | 196 } |
| 195 #endif // defined(OS_CHROMEOS) | 197 #endif // defined(OS_CHROMEOS) |
| 196 | 198 |
| 197 void LaunchWithNoLaunchData() { | 199 void LaunchWithNoLaunchData() { |
| 198 // This method is required as an entry point on the UI thread. | 200 // This method is required as an entry point on the UI thread. |
| 199 LaunchPlatformAppWithNoData(profile_, extension_); | 201 LaunchPlatformAppWithNoData(profile_, extension_); |
| 200 } | 202 } |
| 201 | 203 |
| 202 void LaunchWithMimeType(const std::string& mime_type) { | 204 void LaunchWithMimeType(const std::string& mime_type) { |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 void RestartPlatformAppWithFileEntries( | 415 void RestartPlatformAppWithFileEntries( |
| 414 Profile* profile, | 416 Profile* profile, |
| 415 const Extension* extension, | 417 const Extension* extension, |
| 416 const std::vector<SavedFileEntry>& file_entries) { | 418 const std::vector<SavedFileEntry>& file_entries) { |
| 417 scoped_refptr<SavedFileEntryLauncher> launcher = new SavedFileEntryLauncher( | 419 scoped_refptr<SavedFileEntryLauncher> launcher = new SavedFileEntryLauncher( |
| 418 profile, extension, file_entries); | 420 profile, extension, file_entries); |
| 419 launcher->Launch(); | 421 launcher->Launch(); |
| 420 } | 422 } |
| 421 | 423 |
| 422 } // namespace extensions | 424 } // namespace extensions |
| OLD | NEW |