| 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 "content/public/browser/web_contents.h" | 7 #include "content/public/browser/web_contents.h" |
| 8 | 8 #include "content/public/browser/web_contents_observer.h" |
| 9 class Profile; | |
| 10 | 9 |
| 11 namespace file_manager { | 10 namespace file_manager { |
| 12 | 11 |
| 13 namespace { | 12 namespace { |
| 14 const char kWebContentsDestroyedError[] = "WebContents is destroyed."; | 13 const char kWebContentsDestroyedError[] = "WebContents is destroyed."; |
| 15 } // namespace | 14 } // namespace |
| 16 | 15 |
| 17 class AppInstaller::WebContentsObserver | 16 class AppInstaller::WebContentsObserver : public content::WebContentsObserver { |
| 18 : public content::WebContentsObserver { | |
| 19 | |
| 20 public: | 17 public: |
| 21 explicit WebContentsObserver( | 18 WebContentsObserver(content::WebContents* web_contents, AppInstaller* parent) |
| 22 content::WebContents* web_contents, | |
| 23 AppInstaller* parent) | |
| 24 : content::WebContentsObserver(web_contents), | 19 : content::WebContentsObserver(web_contents), |
| 25 parent_(parent) { | 20 parent_(parent) { |
| 26 } | 21 } |
| 27 | 22 |
| 28 protected: | 23 protected: |
| 29 // content::WebContentsObserver implementation. | 24 // content::WebContentsObserver implementation. |
| 30 virtual void WebContentsDestroyed() OVERRIDE { | 25 virtual void WebContentsDestroyed() OVERRIDE { |
| 31 parent_->OnWebContentsDestroyed(web_contents()); | 26 parent_->OnWebContentsDestroyed(web_contents()); |
| 32 } | 27 } |
| 33 | 28 |
| 34 private: | 29 private: |
| 35 AppInstaller* parent_; | 30 AppInstaller* parent_; |
| 36 | 31 |
| 37 DISALLOW_IMPLICIT_CONSTRUCTORS(WebContentsObserver); | 32 DISALLOW_IMPLICIT_CONSTRUCTORS(WebContentsObserver); |
| 38 }; | 33 }; |
| 39 | 34 |
| 40 AppInstaller::AppInstaller( | 35 AppInstaller::AppInstaller(content::WebContents* web_contents, |
| 41 content::WebContents* web_contents, | 36 const std::string& item_id, |
| 42 const std::string& webstore_item_id, | 37 Profile* profile, |
| 43 Profile* profile, | 38 const Callback& callback) |
| 44 const Callback& callback) | 39 : extensions::WebstoreStandaloneInstaller(item_id, profile, callback), |
| 45 : extensions::WebstoreStandaloneInstaller( | |
| 46 webstore_item_id, | |
| 47 profile, | |
| 48 callback), | |
| 49 callback_(callback), | 40 callback_(callback), |
| 50 web_contents_(web_contents), | 41 web_contents_(web_contents), |
| 51 web_contents_observer_(new WebContentsObserver(web_contents, this)) { | 42 web_contents_observer_(new WebContentsObserver(web_contents, this)) { |
| 52 } | 43 } |
| 53 | 44 |
| 54 AppInstaller::~AppInstaller() {} | 45 AppInstaller::~AppInstaller() {} |
| 55 | 46 |
| 56 bool AppInstaller::CheckRequestorAlive() const { | 47 bool AppInstaller::CheckRequestorAlive() const { |
| 57 // The tab may have gone away - cancel installation in that case. | 48 // The tab may have gone away - cancel installation in that case. |
| 58 return web_contents_ != NULL; | 49 return web_contents_ != NULL; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 return true; | 94 return true; |
| 104 } | 95 } |
| 105 | 96 |
| 106 void AppInstaller::OnWebContentsDestroyed( | 97 void AppInstaller::OnWebContentsDestroyed( |
| 107 content::WebContents* web_contents) { | 98 content::WebContents* web_contents) { |
| 108 callback_.Run(false, kWebContentsDestroyedError); | 99 callback_.Run(false, kWebContentsDestroyedError); |
| 109 AbortInstall(); | 100 AbortInstall(); |
| 110 } | 101 } |
| 111 | 102 |
| 112 } // namespace file_manager | 103 } // namespace file_manager |
| OLD | NEW |