Chromium Code Reviews| Index: chrome/browser/extensions/startup_helper.cc |
| diff --git a/chrome/browser/extensions/startup_helper.cc b/chrome/browser/extensions/startup_helper.cc |
| index b0c90bcc804918565bd00f1f4ccda4aebb86ee64..cffdc0787a8f6813b4a8353d63b6c7758afc7cfa 100644 |
| --- a/chrome/browser/extensions/startup_helper.cc |
| +++ b/chrome/browser/extensions/startup_helper.cc |
| @@ -4,13 +4,18 @@ |
| #include "chrome/browser/extensions/startup_helper.h" |
| +#include "base/bind.h" |
| #include "base/command_line.h" |
| +#include "base/message_loop.h" |
| #include "base/string_util.h" |
| #include "base/stringprintf.h" |
| #include "base/utf_string_conversions.h" |
| #include "chrome/browser/extensions/extension_service.h" |
| +#include "chrome/browser/extensions/webstore_inline_installer.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/common/chrome_switches.h" |
| +#include "content/public/browser/web_contents.h" |
| +#include "ipc/ipc_message.h" |
| namespace { |
| @@ -76,6 +81,46 @@ bool StartupHelper::UninstallExtension(const CommandLine& cmd_line, |
| extension_id); |
| } |
| +namespace { |
| + |
| +class AppInstallHelper { |
| + public: |
| + AppInstallHelper(); |
| + virtual ~AppInstallHelper(); |
| + |
| + WebstoreInlineInstaller::Callback Callback(); |
| + void OnAppInstallComplete(bool success, const std::string& error); |
| +}; |
| + |
| +AppInstallHelper::AppInstallHelper() {} |
| + |
| +AppInstallHelper::~AppInstallHelper() {} |
| + |
| +WebstoreInlineInstaller::Callback AppInstallHelper::Callback() { |
| + return base::Bind(&AppInstallHelper::OnAppInstallComplete, |
|
Mihai Parparita -not on Chrome
2012/09/07 22:01:36
Why not do this inline in te WebstoreInlineInstall
asargent_no_longer_on_chrome
2012/09/14 23:24:35
Done.
|
| + base::Unretained(this)); |
| +} |
| +void AppInstallHelper::OnAppInstallComplete(bool success, |
| + const std::string& error) { |
|
Mihai Parparita -not on Chrome
2012/09/07 22:01:36
It would be nice to somehow propagate this error b
asargent_no_longer_on_chrome
2012/09/14 23:24:35
Done.
|
| + MessageLoop::current()->Quit(); |
| +} |
| + |
| +} // namespace |
| + |
| +bool StartupHelper::InstallAppFromID(const std::string& id, Profile* profile) { |
| + scoped_ptr<content::WebContents> web_contents( |
|
Mihai Parparita -not on Chrome
2012/09/07 22:01:36
Add a TODO about removing the need for this WebCon
asargent_no_longer_on_chrome
2012/09/14 23:24:35
Done.
|
| + content::WebContents::Create(profile, NULL, MSG_ROUTING_NONE, NULL)); |
| + |
| + AppInstallHelper helper; |
| + scoped_refptr<WebstoreInlineInstaller> installer( |
| + new WebstoreInlineInstaller( |
| + web_contents.get(), id, false, GURL(), helper.Callback())); |
| + installer->BeginInstall(); |
| + |
| + MessageLoop::current()->Run(); |
| + return false; |
| +} |
| + |
| StartupHelper::~StartupHelper() { |
| if (pack_job_.get()) |
| pack_job_->ClearClient(); |