Update {virtual,override,final} to follow C++11 style in chrome/browser/chromeos...
[chromium-blink-merge.git] / chrome / browser / chromeos / file_manager / app_installer.cc
blob7fd8b9727d88c50500ecffd75747c13f8f37bff5
1 // Copyright 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.
5 #include "chrome/browser/chromeos/file_manager/app_installer.h"
7 #include "chrome/common/extensions/webstore_install_result.h"
8 #include "content/public/browser/web_contents.h"
9 #include "content/public/browser/web_contents_observer.h"
11 namespace file_manager {
13 namespace {
14 const char kWebContentsDestroyedError[] = "WebContents is destroyed.";
15 } // namespace
17 class AppInstaller::WebContentsObserver : public content::WebContentsObserver {
18 public:
19 WebContentsObserver(content::WebContents* web_contents, AppInstaller* parent)
20 : content::WebContentsObserver(web_contents),
21 parent_(parent) {
24 protected:
25 // content::WebContentsObserver implementation.
26 void WebContentsDestroyed() override {
27 parent_->OnWebContentsDestroyed(web_contents());
30 private:
31 AppInstaller* parent_;
33 DISALLOW_IMPLICIT_CONSTRUCTORS(WebContentsObserver);
36 AppInstaller::AppInstaller(content::WebContents* web_contents,
37 const std::string& item_id,
38 Profile* profile,
39 bool silent_installation,
40 const Callback& callback)
41 : extensions::WebstoreStandaloneInstaller(item_id, profile, callback),
42 silent_installation_(silent_installation),
43 callback_(callback),
44 web_contents_(web_contents),
45 web_contents_observer_(new WebContentsObserver(web_contents, this)) {
48 AppInstaller::~AppInstaller() {}
50 bool AppInstaller::CheckRequestorAlive() const {
51 // The tab may have gone away - cancel installation in that case.
52 return web_contents_ != NULL;
55 const GURL& AppInstaller::GetRequestorURL() const {
56 return GURL::EmptyGURL();
59 scoped_refptr<ExtensionInstallPrompt::Prompt>
60 AppInstaller::CreateInstallPrompt() const {
61 if (silent_installation_)
62 return NULL;
64 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt(
65 new ExtensionInstallPrompt::Prompt(
66 ExtensionInstallPrompt::INLINE_INSTALL_PROMPT));
68 prompt->SetWebstoreData(localized_user_count(),
69 show_user_count(),
70 average_rating(),
71 rating_count());
72 return prompt;
75 bool AppInstaller::ShouldShowPostInstallUI() const {
76 return false;
79 bool AppInstaller::ShouldShowAppInstalledBubble() const {
80 return false;
83 content::WebContents* AppInstaller::GetWebContents() const {
84 return web_contents_;
87 bool AppInstaller::CheckInlineInstallPermitted(
88 const base::DictionaryValue& webstore_data,
89 std::string* error) const {
90 DCHECK(error != NULL);
91 DCHECK(error->empty());
92 return true;
95 bool AppInstaller::CheckRequestorPermitted(
96 const base::DictionaryValue& webstore_data,
97 std::string* error) const {
98 DCHECK(error != NULL);
99 DCHECK(error->empty());
100 return true;
103 void AppInstaller::OnWebContentsDestroyed(
104 content::WebContents* web_contents) {
105 callback_.Run(false,
106 kWebContentsDestroyedError,
107 extensions::webstore_install::OTHER_ERROR);
108 AbortInstall();
111 } // namespace file_manager