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
) {
37 DCHECK(parent_window
);
38 set_install_source(WebstoreInstaller::INSTALL_SOURCE_OTHER
);
41 WebstoreInstallWithPrompt::~WebstoreInstallWithPrompt() {
44 bool WebstoreInstallWithPrompt::CheckRequestorAlive() const {
45 // Assume the requestor is always alive.
49 const GURL
& WebstoreInstallWithPrompt::GetRequestorURL() const {
50 return dummy_requestor_url_
;
53 scoped_refptr
<ExtensionInstallPrompt::Prompt
>
54 WebstoreInstallWithPrompt::CreateInstallPrompt() const {
55 return new ExtensionInstallPrompt::Prompt(
56 ExtensionInstallPrompt::INSTALL_PROMPT
);
59 scoped_ptr
<ExtensionInstallPrompt
>
60 WebstoreInstallWithPrompt::CreateInstallUI() {
61 // Create an ExtensionInstallPrompt. If the parent window is NULL, the dialog
62 // will be placed in the middle of the screen.
63 return make_scoped_ptr(new ExtensionInstallPrompt(profile(), parent_window_
));
66 bool WebstoreInstallWithPrompt::ShouldShowPostInstallUI() const {
67 return show_post_install_ui_
;
70 bool WebstoreInstallWithPrompt::ShouldShowAppInstalledBubble() const {
74 WebContents
* WebstoreInstallWithPrompt::GetWebContents() const {
75 return dummy_web_contents_
.get();
78 bool WebstoreInstallWithPrompt::CheckInlineInstallPermitted(
79 const base::DictionaryValue
& webstore_data
,
80 std::string
* error
) const {
81 // Assume the requestor is trusted.
82 *error
= std::string();
86 bool WebstoreInstallWithPrompt::CheckRequestorPermitted(
87 const base::DictionaryValue
& webstore_data
,
88 std::string
* error
) const {
89 // Assume the requestor is trusted.
90 *error
= std::string();
94 } // namespace extensions