| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chromeos/file_manager/app_installer.h" | 5 #include "chrome/browser/chromeos/file_manager/app_installer.h" |
| 6 | 6 |
| 7 #include "chrome/common/extensions/webstore_install_result.h" | 7 #include "chrome/common/extensions/webstore_install_result.h" |
| 8 #include "content/public/browser/web_contents.h" | 8 #include "content/public/browser/web_contents.h" |
| 9 #include "content/public/browser/web_contents_observer.h" | 9 #include "content/public/browser/web_contents_observer.h" |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 private: | 30 private: |
| 31 AppInstaller* parent_; | 31 AppInstaller* parent_; |
| 32 | 32 |
| 33 DISALLOW_IMPLICIT_CONSTRUCTORS(WebContentsObserver); | 33 DISALLOW_IMPLICIT_CONSTRUCTORS(WebContentsObserver); |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 AppInstaller::AppInstaller(content::WebContents* web_contents, | 36 AppInstaller::AppInstaller(content::WebContents* web_contents, |
| 37 const std::string& item_id, | 37 const std::string& item_id, |
| 38 Profile* profile, | 38 Profile* profile, |
| 39 bool silent_installation, |
| 39 const Callback& callback) | 40 const Callback& callback) |
| 40 : extensions::WebstoreStandaloneInstaller(item_id, profile, callback), | 41 : extensions::WebstoreStandaloneInstaller(item_id, profile, callback), |
| 42 silent_installation_(silent_installation), |
| 41 callback_(callback), | 43 callback_(callback), |
| 42 web_contents_(web_contents), | 44 web_contents_(web_contents), |
| 43 web_contents_observer_(new WebContentsObserver(web_contents, this)) { | 45 web_contents_observer_(new WebContentsObserver(web_contents, this)) { |
| 44 } | 46 } |
| 45 | 47 |
| 46 AppInstaller::~AppInstaller() {} | 48 AppInstaller::~AppInstaller() {} |
| 47 | 49 |
| 48 bool AppInstaller::CheckRequestorAlive() const { | 50 bool AppInstaller::CheckRequestorAlive() const { |
| 49 // The tab may have gone away - cancel installation in that case. | 51 // The tab may have gone away - cancel installation in that case. |
| 50 return web_contents_ != NULL; | 52 return web_contents_ != NULL; |
| 51 } | 53 } |
| 52 | 54 |
| 53 const GURL& AppInstaller::GetRequestorURL() const { | 55 const GURL& AppInstaller::GetRequestorURL() const { |
| 54 return GURL::EmptyGURL(); | 56 return GURL::EmptyGURL(); |
| 55 } | 57 } |
| 56 | 58 |
| 57 scoped_refptr<ExtensionInstallPrompt::Prompt> | 59 scoped_refptr<ExtensionInstallPrompt::Prompt> |
| 58 AppInstaller::CreateInstallPrompt() const { | 60 AppInstaller::CreateInstallPrompt() const { |
| 61 if (silent_installation_) |
| 62 return NULL; |
| 63 |
| 59 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt( | 64 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt( |
| 60 new ExtensionInstallPrompt::Prompt( | 65 new ExtensionInstallPrompt::Prompt( |
| 61 ExtensionInstallPrompt::INLINE_INSTALL_PROMPT)); | 66 ExtensionInstallPrompt::INLINE_INSTALL_PROMPT)); |
| 62 | 67 |
| 63 prompt->SetWebstoreData(localized_user_count(), | 68 prompt->SetWebstoreData(localized_user_count(), |
| 64 show_user_count(), | 69 show_user_count(), |
| 65 average_rating(), | 70 average_rating(), |
| 66 rating_count()); | 71 rating_count()); |
| 67 return prompt; | 72 return prompt; |
| 68 } | 73 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 97 | 102 |
| 98 void AppInstaller::OnWebContentsDestroyed( | 103 void AppInstaller::OnWebContentsDestroyed( |
| 99 content::WebContents* web_contents) { | 104 content::WebContents* web_contents) { |
| 100 callback_.Run(false, | 105 callback_.Run(false, |
| 101 kWebContentsDestroyedError, | 106 kWebContentsDestroyedError, |
| 102 extensions::webstore_install::OTHER_ERROR); | 107 extensions::webstore_install::OTHER_ERROR); |
| 103 AbortInstall(); | 108 AbortInstall(); |
| 104 } | 109 } |
| 105 | 110 |
| 106 } // namespace file_manager | 111 } // namespace file_manager |
| OLD | NEW |