OLD | NEW |
(Empty) | |
| 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 "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 11 #include "content/public/browser/web_contents.h" |
| 12 |
| 13 using content::WebContents; |
| 14 |
| 15 namespace extensions { |
| 16 |
| 17 WebstoreInstallWithPrompt::WebstoreInstallWithPrompt( |
| 18 const std::string& webstore_item_id, |
| 19 Profile* profile, |
| 20 const Callback& callback) |
| 21 : WebstoreStandaloneInstaller(webstore_item_id, profile, callback), |
| 22 dummy_web_contents_( |
| 23 WebContents::Create(WebContents::CreateParams(profile))), |
| 24 parent_window_(NULL) { |
| 25 set_install_source(WebstoreInstaller::INSTALL_SOURCE_OTHER); |
| 26 } |
| 27 |
| 28 WebstoreInstallWithPrompt::WebstoreInstallWithPrompt( |
| 29 const std::string& webstore_item_id, |
| 30 Profile* profile, |
| 31 gfx::NativeWindow parent_window, |
| 32 const Callback& callback) |
| 33 : WebstoreStandaloneInstaller(webstore_item_id, profile, callback), |
| 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_ptr<ExtensionInstallPrompt::Prompt> |
| 54 WebstoreInstallWithPrompt::CreateInstallPrompt() const { |
| 55 scoped_ptr<ExtensionInstallPrompt::Prompt> prompt( |
| 56 new ExtensionInstallPrompt::Prompt( |
| 57 ExtensionInstallPrompt::INSTALL_PROMPT)); |
| 58 return prompt.Pass(); |
| 59 } |
| 60 |
| 61 scoped_ptr<ExtensionInstallPrompt> |
| 62 WebstoreInstallWithPrompt::CreateInstallUI() { |
| 63 // Create an ExtensionInstallPrompt. If the parent window is NULL, the dialog |
| 64 // will be placed in the middle of the screen. |
| 65 return make_scoped_ptr( |
| 66 new ExtensionInstallPrompt(profile(), parent_window_, this)); |
| 67 } |
| 68 |
| 69 bool WebstoreInstallWithPrompt::ShouldShowPostInstallUI() const { |
| 70 return false; |
| 71 } |
| 72 |
| 73 bool WebstoreInstallWithPrompt::ShouldShowAppInstalledBubble() const { |
| 74 return false; |
| 75 } |
| 76 |
| 77 WebContents* WebstoreInstallWithPrompt::GetWebContents() const { |
| 78 return dummy_web_contents_.get(); |
| 79 } |
| 80 |
| 81 bool WebstoreInstallWithPrompt::CheckInlineInstallPermitted( |
| 82 const base::DictionaryValue& webstore_data, |
| 83 std::string* error) const { |
| 84 // Assume the requestor is trusted. |
| 85 *error = std::string(); |
| 86 return true; |
| 87 } |
| 88 |
| 89 bool WebstoreInstallWithPrompt::CheckRequestorPermitted( |
| 90 const base::DictionaryValue& webstore_data, |
| 91 std::string* error) const { |
| 92 // Assume the requestor is trusted. |
| 93 *error = std::string(); |
| 94 return true; |
| 95 } |
| 96 |
| 97 content::WebContents* WebstoreInstallWithPrompt::OpenURL( |
| 98 const content::OpenURLParams& params) { |
| 99 chrome::ScopedTabbedBrowserDisplayer displayer(profile(), |
| 100 chrome::GetActiveDesktop()); |
| 101 return displayer.browser()->OpenURL(params); |
| 102 } |
| 103 |
| 104 } // namespace extensions |
OLD | NEW |