Index: chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc |
diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc |
index e102016542c0694d3755aa4e3f82c48b56f2a053..e3fa0ddaa0aca37674725bd7d2631cd204ebda49 100644 |
--- a/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc |
+++ b/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc |
@@ -9,6 +9,7 @@ |
#include "base/values.h" |
#include "chrome/browser/chromeos/drive/drive_integration_service.h" |
#include "chrome/browser/chromeos/drive/logging.h" |
+#include "chrome/browser/chromeos/extensions/file_manager/file_manager_installer.h" |
#include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" |
#include "chrome/browser/chromeos/settings/cros_settings.h" |
#include "chrome/browser/lifetime/application_lifetime.h" |
@@ -198,4 +199,54 @@ bool ZoomFunction::RunImpl() { |
return true; |
} |
+InstallWebstoreItemFunction::InstallWebstoreItemFunction() { |
+} |
+ |
+InstallWebstoreItemFunction::~InstallWebstoreItemFunction() { |
+} |
+ |
+bool InstallWebstoreItemFunction::RunImpl() { |
+ if (args_->GetSize() < 1) { |
hashimoto
2013/08/30 09:09:37
nit: No need to have '{'?
yoshiki
2013/08/30 09:51:46
Removed.
|
+ return false; |
+ } |
+ |
+ if (!args_->GetString(0, &webstore_item_id_) || webstore_item_id_.empty()) |
+ return false; |
+ |
+ extensions::WebstoreStandaloneInstaller::Callback callback = |
+ base::Bind(&InstallWebstoreItemFunction::OnInstallComplete, |
+ base::Unretained(this)); |
+ |
+ scoped_refptr<FileManagerInstaller> installer( |
+ new FileManagerInstaller( |
+ GetAssociatedWebContents(), // web_contents(), |
+ webstore_item_id_, |
+ profile(), |
+ callback)); |
+ // installer will be AddRef()'d in BeginInstall(). |
+ installer->BeginInstall(); |
+ |
+ AddRef(); // Balanced in Release() in OnInstallComplete. |
hashimoto
2013/08/30 09:09:37
How about binding |this| to the callback without b
yoshiki
2013/08/30 09:51:46
Nice. Done.
|
+ return true; |
+} |
+ |
+void InstallWebstoreItemFunction::OnInstallComplete(bool success, |
+ const std::string& error) { |
hashimoto
2013/08/30 09:09:37
nit: indent.
yoshiki
2013/08/30 09:51:46
Done.
|
+ if (success) { |
+ drive::util::Log(logging::LOG_INFO, |
+ "App install succeeded. (item id: %s)", |
+ webstore_item_id_.c_str()); |
+ } else { |
+ drive::util::Log(logging::LOG_ERROR, |
+ "App install failed. (item id: %s, reason: %s)", |
+ webstore_item_id_.c_str(), |
+ error.c_str()); |
+ error_ = error; |
+ } |
+ |
+ SendResponse(success); |
+ |
+ Release(); // Matches the AddRef in RunImpl. |
+} |
+ |
} // namespace file_manager |