OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/file_manager/file_manager_installer.h" | 5 #include "chrome/browser/chromeos/file_manager/app_installer.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
10 | 10 |
11 namespace file_manager { | 11 namespace file_manager { |
12 | 12 |
13 namespace { | 13 namespace { |
14 const char kWebContentsDestroyedError[] = "WebContents is destroyed."; | 14 const char kWebContentsDestroyedError[] = "WebContents is destroyed."; |
15 } // namespace | 15 } // namespace |
16 | 16 |
17 class FileManagerInstaller::WebContentsObserver | 17 class AppInstaller::WebContentsObserver |
18 : public content::WebContentsObserver { | 18 : public content::WebContentsObserver { |
19 | 19 |
20 public: | 20 public: |
21 explicit WebContentsObserver( | 21 explicit WebContentsObserver( |
22 content::WebContents* web_contents, | 22 content::WebContents* web_contents, |
23 FileManagerInstaller* parent) | 23 AppInstaller* parent) |
24 : content::WebContentsObserver(web_contents), | 24 : content::WebContentsObserver(web_contents), |
25 parent_(parent) { | 25 parent_(parent) { |
26 } | 26 } |
27 | 27 |
28 protected: | 28 protected: |
29 // content::WebContentsObserver implementation. | 29 // content::WebContentsObserver implementation. |
30 virtual void WebContentsDestroyed( | 30 virtual void WebContentsDestroyed( |
31 content::WebContents* web_contents) OVERRIDE { | 31 content::WebContents* web_contents) OVERRIDE { |
32 parent_->OnWebContentsDestroyed(web_contents); | 32 parent_->OnWebContentsDestroyed(web_contents); |
33 } | 33 } |
34 | 34 |
35 private: | 35 private: |
36 FileManagerInstaller* parent_; | 36 AppInstaller* parent_; |
37 | 37 |
38 DISALLOW_IMPLICIT_CONSTRUCTORS(WebContentsObserver); | 38 DISALLOW_IMPLICIT_CONSTRUCTORS(WebContentsObserver); |
39 }; | 39 }; |
40 | 40 |
41 FileManagerInstaller::FileManagerInstaller( | 41 AppInstaller::AppInstaller( |
42 content::WebContents* web_contents, | 42 content::WebContents* web_contents, |
43 const std::string& webstore_item_id, | 43 const std::string& webstore_item_id, |
44 Profile* profile, | 44 Profile* profile, |
45 const Callback& callback) | 45 const Callback& callback) |
46 : extensions::WebstoreStandaloneInstaller( | 46 : extensions::WebstoreStandaloneInstaller( |
47 webstore_item_id, | 47 webstore_item_id, |
48 profile, | 48 profile, |
49 callback), | 49 callback), |
50 callback_(callback), | 50 callback_(callback), |
51 web_contents_(web_contents), | 51 web_contents_(web_contents), |
52 web_contents_observer_(new WebContentsObserver(web_contents, this)) { | 52 web_contents_observer_(new WebContentsObserver(web_contents, this)) { |
53 } | 53 } |
54 | 54 |
55 FileManagerInstaller::~FileManagerInstaller() {} | 55 AppInstaller::~AppInstaller() {} |
56 | 56 |
57 bool FileManagerInstaller::CheckRequestorAlive() const { | 57 bool AppInstaller::CheckRequestorAlive() const { |
58 // The tab may have gone away - cancel installation in that case. | 58 // The tab may have gone away - cancel installation in that case. |
59 return web_contents_ != NULL; | 59 return web_contents_ != NULL; |
60 } | 60 } |
61 | 61 |
62 const GURL& FileManagerInstaller::GetRequestorURL() const { | 62 const GURL& AppInstaller::GetRequestorURL() const { |
63 return GURL::EmptyGURL(); | 63 return GURL::EmptyGURL(); |
64 } | 64 } |
65 | 65 |
66 scoped_ptr<ExtensionInstallPrompt::Prompt> | 66 scoped_ptr<ExtensionInstallPrompt::Prompt> |
67 FileManagerInstaller::CreateInstallPrompt() const { | 67 AppInstaller::CreateInstallPrompt() const { |
68 scoped_ptr<ExtensionInstallPrompt::Prompt> prompt( | 68 scoped_ptr<ExtensionInstallPrompt::Prompt> prompt( |
69 new ExtensionInstallPrompt::Prompt( | 69 new ExtensionInstallPrompt::Prompt( |
70 ExtensionInstallPrompt::INLINE_INSTALL_PROMPT)); | 70 ExtensionInstallPrompt::INLINE_INSTALL_PROMPT)); |
71 | 71 |
72 prompt->SetInlineInstallWebstoreData(localized_user_count(), | 72 prompt->SetInlineInstallWebstoreData(localized_user_count(), |
73 show_user_count(), | 73 show_user_count(), |
74 average_rating(), | 74 average_rating(), |
75 rating_count()); | 75 rating_count()); |
76 return prompt.Pass(); | 76 return prompt.Pass(); |
77 } | 77 } |
78 | 78 |
79 bool FileManagerInstaller::ShouldShowPostInstallUI() const { | 79 bool AppInstaller::ShouldShowPostInstallUI() const { |
80 return false; | 80 return false; |
81 } | 81 } |
82 | 82 |
83 bool FileManagerInstaller::ShouldShowAppInstalledBubble() const { | 83 bool AppInstaller::ShouldShowAppInstalledBubble() const { |
84 return false; | 84 return false; |
85 } | 85 } |
86 | 86 |
87 content::WebContents* FileManagerInstaller::GetWebContents() const { | 87 content::WebContents* AppInstaller::GetWebContents() const { |
88 return web_contents_; | 88 return web_contents_; |
89 } | 89 } |
90 | 90 |
91 bool FileManagerInstaller::CheckInlineInstallPermitted( | 91 bool AppInstaller::CheckInlineInstallPermitted( |
92 const base::DictionaryValue& webstore_data, | 92 const base::DictionaryValue& webstore_data, |
93 std::string* error) const { | 93 std::string* error) const { |
94 DCHECK(error != NULL); | 94 DCHECK(error != NULL); |
95 DCHECK(error->empty()); | 95 DCHECK(error->empty()); |
96 return true; | 96 return true; |
97 } | 97 } |
98 | 98 |
99 bool FileManagerInstaller::CheckRequestorPermitted( | 99 bool AppInstaller::CheckRequestorPermitted( |
100 const base::DictionaryValue& webstore_data, | 100 const base::DictionaryValue& webstore_data, |
101 std::string* error) const { | 101 std::string* error) const { |
102 DCHECK(error != NULL); | 102 DCHECK(error != NULL); |
103 DCHECK(error->empty()); | 103 DCHECK(error->empty()); |
104 return true; | 104 return true; |
105 } | 105 } |
106 | 106 |
107 void FileManagerInstaller::OnWebContentsDestroyed( | 107 void AppInstaller::OnWebContentsDestroyed( |
108 content::WebContents* web_contents) { | 108 content::WebContents* web_contents) { |
109 callback_.Run(false, kWebContentsDestroyedError); | 109 callback_.Run(false, kWebContentsDestroyedError); |
110 AbortInstall(); | 110 AbortInstall(); |
111 } | 111 } |
112 | 112 |
113 } // namespace file_manager | 113 } // namespace file_manager |
OLD | NEW |