MacViews: Get c/b/ui/views/tabs to build on Mac
[chromium-blink-merge.git] / chrome / browser / extensions / webstore_install_with_prompt.cc
blobf66acc1a2e5ca6bc23fda115f1fd890d13a9d11b
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,
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);
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);
41 WebstoreInstallWithPrompt::~WebstoreInstallWithPrompt() {
44 bool WebstoreInstallWithPrompt::CheckRequestorAlive() const {
45 // Assume the requestor is always alive.
46 return true;
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 {
71 return false;
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();
83 return true;
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;
94 } // namespace extensions