Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / webstore_install_with_prompt.cc
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.
4
5 #include "chrome/browser/extensions/webstore_install_with_prompt.h"
6
7 #include "chrome/browser/extensions/webstore_installer.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "content/public/browser/web_contents.h"
10
11 using content::WebContents;
12
13 namespace extensions {
14
15 WebstoreInstallWithPrompt::WebstoreInstallWithPrompt(
16     const std::string& webstore_item_id,
17     Profile* profile,
18     const Callback& callback)
19     : WebstoreStandaloneInstaller(webstore_item_id, profile, callback),
20       show_post_install_ui_(true),
21       dummy_web_contents_(
22           WebContents::Create(WebContents::CreateParams(profile))),
23       parent_window_(NULL) {
24   set_install_source(WebstoreInstaller::INSTALL_SOURCE_OTHER);
25 }
26
27 WebstoreInstallWithPrompt::WebstoreInstallWithPrompt(
28     const std::string& webstore_item_id,
29     Profile* profile,
30     gfx::NativeWindow parent_window,
31     const Callback& callback)
32     : WebstoreStandaloneInstaller(webstore_item_id, profile, callback),
33       show_post_install_ui_(true),
34       dummy_web_contents_(
35           WebContents::Create(WebContents::CreateParams(profile))),
36       parent_window_(parent_window) {
37   DCHECK(parent_window);
38   set_install_source(WebstoreInstaller::INSTALL_SOURCE_OTHER);
39 }
40
41 WebstoreInstallWithPrompt::~WebstoreInstallWithPrompt() {
42 }
43
44 bool WebstoreInstallWithPrompt::CheckRequestorAlive() const {
45   // Assume the requestor is always alive.
46   return true;
47 }
48
49 const GURL& WebstoreInstallWithPrompt::GetRequestorURL() const {
50   return dummy_requestor_url_;
51 }
52
53 scoped_refptr<ExtensionInstallPrompt::Prompt>
54 WebstoreInstallWithPrompt::CreateInstallPrompt() const {
55   return new ExtensionInstallPrompt::Prompt(
56       ExtensionInstallPrompt::INSTALL_PROMPT);
57 }
58
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_));
64 }
65
66 bool WebstoreInstallWithPrompt::ShouldShowPostInstallUI() const {
67   return show_post_install_ui_;
68 }
69
70 bool WebstoreInstallWithPrompt::ShouldShowAppInstalledBubble() const {
71   return false;
72 }
73
74 WebContents* WebstoreInstallWithPrompt::GetWebContents() const {
75   return dummy_web_contents_.get();
76 }
77
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();
83   return true;
84 }
85
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();
91   return true;
92 }
93
94 }  // namespace extensions