OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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/chromeos/extensions/file_manager/file_manager_installer
.h" |
| 6 |
| 7 #include "base/strings/stringprintf.h" |
| 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "content/public/browser/web_contents.h" |
| 10 |
| 11 using content::WebContents; |
| 12 |
| 13 namespace file_manager { |
| 14 |
| 15 const char kWebContentsDestroyedError[] = "WebContents is destroyed."; |
| 16 |
| 17 FileManagerInstaller::FileManagerInstaller( |
| 18 content::WebContents* web_contents, |
| 19 const std::string& webstore_item_id, |
| 20 Profile* profile, |
| 21 const Callback& callback) |
| 22 : extensions::WebstoreStandaloneInstaller( |
| 23 webstore_item_id, |
| 24 profile, |
| 25 callback), |
| 26 content::WebContentsObserver(web_contents), |
| 27 callback_(callback) { |
| 28 } |
| 29 |
| 30 FileManagerInstaller::~FileManagerInstaller() {} |
| 31 |
| 32 bool FileManagerInstaller::CheckRequestorAlive() const { |
| 33 // The tab may have gone away - cancel installation in that case. |
| 34 return web_contents() != NULL; |
| 35 } |
| 36 |
| 37 const GURL& FileManagerInstaller::GetRequestorURL() const { |
| 38 return dummy_url_; |
| 39 } |
| 40 |
| 41 scoped_ptr<ExtensionInstallPrompt::Prompt> |
| 42 FileManagerInstaller::CreateInstallPrompt() const { |
| 43 scoped_ptr<ExtensionInstallPrompt::Prompt> prompt( |
| 44 new ExtensionInstallPrompt::Prompt( |
| 45 ExtensionInstallPrompt::INLINE_INSTALL_PROMPT)); |
| 46 |
| 47 prompt->SetInlineInstallWebstoreData(localized_user_count(), |
| 48 show_user_count(), |
| 49 average_rating(), |
| 50 rating_count()); |
| 51 return prompt.Pass(); |
| 52 } |
| 53 |
| 54 bool FileManagerInstaller::ShouldShowPostInstallUI() const { |
| 55 return false; |
| 56 } |
| 57 |
| 58 bool FileManagerInstaller::ShouldShowAppInstalledBubble() const { |
| 59 return false; |
| 60 } |
| 61 |
| 62 WebContents* FileManagerInstaller::GetWebContents() const { |
| 63 return web_contents(); |
| 64 } |
| 65 |
| 66 bool FileManagerInstaller::CheckInlineInstallPermitted( |
| 67 const base::DictionaryValue& webstore_data, |
| 68 std::string* error) const { |
| 69 DCHECK(error != NULL); |
| 70 DCHECK(error->empty()); |
| 71 return true; |
| 72 } |
| 73 |
| 74 bool FileManagerInstaller::CheckRequestorPermitted( |
| 75 const base::DictionaryValue& webstore_data, |
| 76 std::string* error) const { |
| 77 DCHECK(error != NULL); |
| 78 DCHECK(error->empty()); |
| 79 return true; |
| 80 } |
| 81 |
| 82 void FileManagerInstaller::WebContentsDestroyed( |
| 83 content::WebContents* web_contents) { |
| 84 callback_.Run(false, kWebContentsDestroyedError); |
| 85 AbortInstall(); |
| 86 } |
| 87 |
| 88 } // namespace file_manager |
OLD | NEW |