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