| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_UI_APP_LIST_DRIVE_DRIVE_APP_CONVERTER_H_ | 5 #ifndef CHROME_BROWSER_APPS_DRIVE_DRIVE_APP_CONVERTER_H_ |
| 6 #define CHROME_BROWSER_UI_APP_LIST_DRIVE_DRIVE_APP_CONVERTER_H_ | 6 #define CHROME_BROWSER_APPS_DRIVE_DRIVE_APP_CONVERTER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 14 #include "chrome/browser/drive/drive_app_registry.h" | 14 #include "chrome/browser/drive/drive_app_registry.h" |
| 15 #include "chrome/browser/extensions/install_observer.h" | 15 #include "chrome/browser/extensions/install_observer.h" |
| 16 #include "chrome/common/web_application_info.h" | 16 #include "chrome/common/web_application_info.h" |
| 17 | 17 |
| 18 class Profile; |
| 19 |
| 18 namespace extensions { | 20 namespace extensions { |
| 19 class CrxInstaller; | 21 class CrxInstaller; |
| 20 class Extension; | 22 class Extension; |
| 21 } | 23 } |
| 22 | 24 |
| 23 class Profile; | |
| 24 | |
| 25 // DriveAppConverter creates and installs a local URL app for the given | 25 // DriveAppConverter creates and installs a local URL app for the given |
| 26 // DriveAppInfo into the given profile. | 26 // DriveAppInfo into the given profile. |
| 27 class DriveAppConverter : public extensions::InstallObserver { | 27 class DriveAppConverter : public extensions::InstallObserver { |
| 28 public: | 28 public: |
| 29 typedef base::Callback<void(const DriveAppConverter*, bool success)> | 29 typedef base::Callback<void(const DriveAppConverter*, bool success)> |
| 30 FinishedCallback; | 30 FinishedCallback; |
| 31 | 31 |
| 32 DriveAppConverter(Profile* profile, | 32 DriveAppConverter(Profile* profile, |
| 33 const drive::DriveAppInfo& app_info, | 33 const drive::DriveAppInfo& app_info, |
| 34 const FinishedCallback& finished_callback); | 34 const FinishedCallback& finished_callback); |
| 35 virtual ~DriveAppConverter(); | 35 virtual ~DriveAppConverter(); |
| 36 | 36 |
| 37 void Start(); | 37 void Start(); |
| 38 bool IsStarted() const; |
| 38 | 39 |
| 39 const drive::DriveAppInfo& app_info() const { return app_info_; } | 40 const drive::DriveAppInfo& app_info() const { return app_info_; } |
| 40 const extensions::Extension* app() const { return app_; } | 41 const extensions::Extension* app() const { return app_; } |
| 42 bool is_new_install() const { return is_new_install_; } |
| 41 | 43 |
| 42 private: | 44 private: |
| 43 class IconFetcher; | 45 class IconFetcher; |
| 44 | 46 |
| 45 // Callbacks from IconFetcher. | 47 // Callbacks from IconFetcher. |
| 46 void OnIconFetchComplete(const IconFetcher* fetcher); | 48 void OnIconFetchComplete(const IconFetcher* fetcher); |
| 47 | 49 |
| 48 void StartInstall(); | 50 void StartInstall(); |
| 49 void PostInstallCleanUp(); | 51 void PostInstallCleanUp(); |
| 50 | 52 |
| 51 // extensions::InstallObserver: | 53 // extensions::InstallObserver: |
| 52 virtual void OnFinishCrxInstall(const std::string& extension_id, | 54 virtual void OnFinishCrxInstall(const std::string& extension_id, |
| 53 bool success) OVERRIDE; | 55 bool success) OVERRIDE; |
| 54 | 56 |
| 55 Profile* profile_; | 57 Profile* profile_; |
| 56 const drive::DriveAppInfo app_info_; | 58 const drive::DriveAppInfo app_info_; |
| 57 | 59 |
| 58 WebApplicationInfo web_app_; | 60 WebApplicationInfo web_app_; |
| 59 const extensions::Extension* app_; | 61 const extensions::Extension* app_; |
| 62 bool is_new_install_; |
| 60 | 63 |
| 61 ScopedVector<IconFetcher> fetchers_; | 64 ScopedVector<IconFetcher> fetchers_; |
| 62 scoped_refptr<extensions::CrxInstaller> crx_installer_; | 65 scoped_refptr<extensions::CrxInstaller> crx_installer_; |
| 63 | 66 |
| 64 FinishedCallback finished_callback_; | 67 FinishedCallback finished_callback_; |
| 65 | 68 |
| 66 DISALLOW_COPY_AND_ASSIGN(DriveAppConverter); | 69 DISALLOW_COPY_AND_ASSIGN(DriveAppConverter); |
| 67 }; | 70 }; |
| 68 | 71 |
| 69 #endif // CHROME_BROWSER_UI_APP_LIST_DRIVE_DRIVE_APP_CONVERTER_H_ | 72 #endif // CHROME_BROWSER_APPS_DRIVE_DRIVE_APP_CONVERTER_H_ |
| OLD | NEW |