Chromium Code Reviews| 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_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 WebstoreInstallPrompt::WebstoreInstallPrompt( | |
| 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 WebstoreInstallPrompt::WebstoreInstallPrompt( | |
| 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 set_install_source(WebstoreInstaller::INSTALL_SOURCE_OTHER); | |
|
tapted
2014/05/28 06:28:46
since it's a separate constructor, maybe DCHECK(pa
| |
| 38 } | |
| 39 | |
| 40 WebstoreInstallPrompt::~WebstoreInstallPrompt() { | |
| 41 } | |
| 42 | |
| 43 bool WebstoreInstallPrompt::CheckRequestorAlive() const { | |
| 44 // Assume the requestor is always alive. | |
| 45 return true; | |
| 46 } | |
| 47 | |
| 48 const GURL& WebstoreInstallPrompt::GetRequestorURL() const { | |
| 49 return dummy_requestor_url_; | |
| 50 } | |
| 51 | |
| 52 scoped_ptr<ExtensionInstallPrompt::Prompt> | |
| 53 WebstoreInstallPrompt::CreateInstallPrompt() const { | |
| 54 scoped_ptr<ExtensionInstallPrompt::Prompt> prompt( | |
| 55 new ExtensionInstallPrompt::Prompt( | |
| 56 ExtensionInstallPrompt::INSTALL_PROMPT)); | |
| 57 return prompt.Pass(); | |
| 58 } | |
| 59 | |
| 60 scoped_ptr<ExtensionInstallPrompt> WebstoreInstallPrompt::CreateInstallUI() { | |
| 61 // Create an ExtensionInstallPrompt with a parent window. | |
| 62 if (parent_window_) { | |
| 63 return make_scoped_ptr( | |
| 64 new ExtensionInstallPrompt(profile(), parent_window_, this)); | |
| 65 } | |
| 66 | |
| 67 // The WebContents passed to ExtensionInstallPrompt is used to find a parent | |
| 68 // window for the dialog. If there is no associated parent native window, pass | |
| 69 // NULL so the dialog is placed in the middle of the screen. | |
| 70 return make_scoped_ptr(new ExtensionInstallPrompt(NULL)); | |
|
tapted
2014/05/28 06:28:46
I'm not sure this is safe.. it looks like passing
tmdiep
2014/05/28 08:39:27
Ugh. Using the ExtensionInstallPrompt(content::Web
| |
| 71 } | |
| 72 | |
| 73 bool WebstoreInstallPrompt::ShouldShowPostInstallUI() const { | |
| 74 return false; | |
| 75 } | |
| 76 | |
| 77 bool WebstoreInstallPrompt::ShouldShowAppInstalledBubble() const { | |
| 78 return false; | |
| 79 } | |
| 80 | |
| 81 WebContents* WebstoreInstallPrompt::GetWebContents() const { | |
| 82 return dummy_web_contents_.get(); | |
| 83 } | |
| 84 | |
| 85 bool WebstoreInstallPrompt::CheckInlineInstallPermitted( | |
| 86 const base::DictionaryValue& webstore_data, | |
| 87 std::string* error) const { | |
| 88 // Assume the requestor is trusted. | |
| 89 *error = ""; | |
|
tapted
2014/05/28 06:28:46
nit: "" -> std::string() (doesn't malloc a 1-byte
| |
| 90 return true; | |
| 91 } | |
| 92 | |
| 93 bool WebstoreInstallPrompt::CheckRequestorPermitted( | |
| 94 const base::DictionaryValue& webstore_data, | |
| 95 std::string* error) const { | |
| 96 // Assume the requestor is trusted. | |
| 97 *error = ""; | |
|
tapted
2014/05/28 06:28:46
std::string()
| |
| 98 return true; | |
| 99 } | |
| 100 | |
| 101 content::WebContents* WebstoreInstallPrompt::OpenURL( | |
| 102 const content::OpenURLParams& params) { | |
| 103 chrome::ScopedTabbedBrowserDisplayer displayer(profile(), | |
| 104 chrome::GetActiveDesktop()); | |
| 105 return displayer.browser()->OpenURL(params); | |
| 106 } | |
| 107 | |
| 108 } // namespace extensions | |
| OLD | NEW |