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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/file_manager/app_installer.h"
7 #include "content/public/browser/web_contents.h"
11 namespace file_manager
{
14 const char kWebContentsDestroyedError
[] = "WebContents is destroyed.";
17 class AppInstaller::WebContentsObserver
18 : public content::WebContentsObserver
{
21 explicit WebContentsObserver(
22 content::WebContents
* web_contents
,
24 : content::WebContentsObserver(web_contents
),
29 // content::WebContentsObserver implementation.
30 virtual void WebContentsDestroyed(
31 content::WebContents
* web_contents
) OVERRIDE
{
32 parent_
->OnWebContentsDestroyed(web_contents
);
36 AppInstaller
* parent_
;
38 DISALLOW_IMPLICIT_CONSTRUCTORS(WebContentsObserver
);
41 AppInstaller::AppInstaller(
42 content::WebContents
* web_contents
,
43 const std::string
& webstore_item_id
,
45 const Callback
& callback
)
46 : extensions::WebstoreStandaloneInstaller(
51 web_contents_(web_contents
),
52 web_contents_observer_(new WebContentsObserver(web_contents
, this)) {
55 AppInstaller::~AppInstaller() {}
57 bool AppInstaller::CheckRequestorAlive() const {
58 // The tab may have gone away - cancel installation in that case.
59 return web_contents_
!= NULL
;
62 const GURL
& AppInstaller::GetRequestorURL() const {
63 return GURL::EmptyGURL();
66 scoped_ptr
<ExtensionInstallPrompt::Prompt
>
67 AppInstaller::CreateInstallPrompt() const {
68 scoped_ptr
<ExtensionInstallPrompt::Prompt
> prompt(
69 new ExtensionInstallPrompt::Prompt(
70 ExtensionInstallPrompt::INLINE_INSTALL_PROMPT
));
72 prompt
->SetWebstoreData(localized_user_count(),
79 bool AppInstaller::ShouldShowPostInstallUI() const {
83 bool AppInstaller::ShouldShowAppInstalledBubble() const {
87 content::WebContents
* AppInstaller::GetWebContents() const {
91 bool AppInstaller::CheckInlineInstallPermitted(
92 const base::DictionaryValue
& webstore_data
,
93 std::string
* error
) const {
94 DCHECK(error
!= NULL
);
95 DCHECK(error
->empty());
99 bool AppInstaller::CheckRequestorPermitted(
100 const base::DictionaryValue
& webstore_data
,
101 std::string
* error
) const {
102 DCHECK(error
!= NULL
);
103 DCHECK(error
->empty());
107 void AppInstaller::OnWebContentsDestroyed(
108 content::WebContents
* web_contents
) {
109 callback_
.Run(false, kWebContentsDestroyedError
);
113 } // namespace file_manager