1 // Copyright 2014 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/extensions/webstore_install_with_prompt.h"
7 #include "chrome/browser/extensions/webstore_installer.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "content/public/browser/web_contents.h"
11 using content::WebContents
;
13 namespace extensions
{
15 WebstoreInstallWithPrompt::WebstoreInstallWithPrompt(
16 const std::string
& webstore_item_id
,
18 const Callback
& callback
)
19 : WebstoreStandaloneInstaller(webstore_item_id
, profile
, callback
),
20 show_post_install_ui_(true),
22 WebContents::Create(WebContents::CreateParams(profile
))),
23 parent_window_(NULL
) {
24 set_install_source(WebstoreInstaller::INSTALL_SOURCE_OTHER
);
27 WebstoreInstallWithPrompt::WebstoreInstallWithPrompt(
28 const std::string
& webstore_item_id
,
30 gfx::NativeWindow parent_window
,
31 const Callback
& callback
)
32 : WebstoreStandaloneInstaller(webstore_item_id
, profile
, callback
),
33 show_post_install_ui_(true),
35 WebContents::Create(WebContents::CreateParams(profile
))),
36 parent_window_(parent_window
) {
38 parent_window_tracker_
= NativeWindowTracker::Create(parent_window
);
39 set_install_source(WebstoreInstaller::INSTALL_SOURCE_OTHER
);
42 WebstoreInstallWithPrompt::~WebstoreInstallWithPrompt() {
45 bool WebstoreInstallWithPrompt::CheckRequestorAlive() const {
46 if (!parent_window_
) {
47 // Assume the requestor is always alive if |parent_window_| is null.
50 return !parent_window_tracker_
->WasNativeWindowClosed();
53 const GURL
& WebstoreInstallWithPrompt::GetRequestorURL() const {
54 return dummy_requestor_url_
;
57 scoped_refptr
<ExtensionInstallPrompt::Prompt
>
58 WebstoreInstallWithPrompt::CreateInstallPrompt() const {
59 return new ExtensionInstallPrompt::Prompt(
60 ExtensionInstallPrompt::INSTALL_PROMPT
);
63 scoped_ptr
<ExtensionInstallPrompt
>
64 WebstoreInstallWithPrompt::CreateInstallUI() {
65 // Create an ExtensionInstallPrompt. If the parent window is NULL, the dialog
66 // will be placed in the middle of the screen.
67 return make_scoped_ptr(new ExtensionInstallPrompt(profile(), parent_window_
));
70 bool WebstoreInstallWithPrompt::ShouldShowPostInstallUI() const {
71 return show_post_install_ui_
;
74 bool WebstoreInstallWithPrompt::ShouldShowAppInstalledBubble() const {
78 WebContents
* WebstoreInstallWithPrompt::GetWebContents() const {
79 return dummy_web_contents_
.get();
82 bool WebstoreInstallWithPrompt::CheckInlineInstallPermitted(
83 const base::DictionaryValue
& webstore_data
,
84 std::string
* error
) const {
85 // Assume the requestor is trusted.
86 *error
= std::string();
90 bool WebstoreInstallWithPrompt::CheckRequestorPermitted(
91 const base::DictionaryValue
& webstore_data
,
92 std::string
* error
) const {
93 // Assume the requestor is trusted.
94 *error
= std::string();
98 } // namespace extensions