Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(712)

Unified Diff: chrome/browser/chromeos/extensions/file_manager/webstore_app_installer.cc

Issue 23332012: Add a private API method to install a webstore app from Files.app (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/extensions/file_manager/webstore_app_installer.cc
diff --git a/chrome/browser/chromeos/extensions/file_manager/webstore_app_installer.cc b/chrome/browser/chromeos/extensions/file_manager/webstore_app_installer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7cdf8d2d9fb141b85fd188c5155bccc53e9cc081
--- /dev/null
+++ b/chrome/browser/chromeos/extensions/file_manager/webstore_app_installer.cc
@@ -0,0 +1,90 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/extensions/file_manager/webstore_app_installer.h"
+
+#include "base/strings/stringprintf.h"
+#include "chrome/browser/profiles/profile.h"
+#include "content/public/browser/web_contents.h"
+
+using content::WebContents;
+
+namespace file_manager {
+
+const char kWebContentsDestroyedError[] = "WebContents is destroyed.";
+
+WebstoreAppInstaller::WebstoreAppInstaller(
+ content::WebContents* web_contents,
+ const std::string& webstore_item_id,
+ Profile* profile,
+ const Callback& callback)
+ : extensions::WebstoreStandaloneInstaller(
asargent_no_longer_on_chrome 2013/08/27 18:22:33 nit: I think the ":" is supposed to go at the end
yoshiki 2013/08/28 13:19:04 No. According to the style guide, we hasve to put
asargent_no_longer_on_chrome 2013/08/29 22:26:03 Ok, sorry for my mistake, and thanks for double-ch
+ webstore_item_id,
+ profile,
+ callback),
+ content::WebContentsObserver(web_contents),
+ callback_(callback) {
+}
+
+WebstoreAppInstaller::~WebstoreAppInstaller() {}
+
+bool WebstoreAppInstaller::CheckRequestorAlive() const {
+ // The tab may have gone away - cancel installation in that case.
+ return web_contents() != NULL;
+}
+
+const GURL& WebstoreAppInstaller::GetRequestorURL() const {
+ return dummy_url_;
asargent_no_longer_on_chrome 2013/08/27 18:22:33 Ok, I see now why you need dummy_url_. This is sor
yoshiki 2013/08/28 13:19:04 I agree, this method should return just GURL.
+}
+
+scoped_ptr<ExtensionInstallPrompt::Prompt>
+WebstoreAppInstaller::CreateInstallPrompt() const {
+ scoped_ptr<ExtensionInstallPrompt::Prompt> prompt(
+ new ExtensionInstallPrompt::Prompt(
+ ExtensionInstallPrompt::INLINE_INSTALL_PROMPT));
+
+ prompt->SetInlineInstallWebstoreData(localized_user_count(),
+ show_user_count(),
+ average_rating(),
+ rating_count());
+ return prompt.Pass();
+}
+
+bool WebstoreAppInstaller::ShouldShowPostInstallUI() const {
+ return false;
+}
+
+bool WebstoreAppInstaller::ShouldShowAppInstalledBubble() const {
+ return false;
+}
+
+WebContents* WebstoreAppInstaller::GetWebContents() const {
+ return web_contents();
+}
+
+bool WebstoreAppInstaller::CheckInlineInstallPermitted(
+ const base::DictionaryValue& webstore_data,
+ std::string* error) const {
+ error->clear();
asargent_no_longer_on_chrome 2013/08/27 18:22:33 nit: I'd personally rather just leave |error| alon
yoshiki 2013/08/28 13:19:04 Done.
+ return true;
+}
+
+bool WebstoreAppInstaller::CheckRequestorPermitted(
+ const base::DictionaryValue& webstore_data,
+ std::string* error) const {
+ error->clear();
asargent_no_longer_on_chrome 2013/08/27 18:22:33 same here
yoshiki 2013/08/28 13:19:04 Done.
+ return true;
+}
+
+//
+// Private implementation.
asargent_no_longer_on_chrome 2013/08/27 18:22:33 I'm not sure this comment really helps any with re
yoshiki 2013/08/28 13:19:04 Removed
+//
+
+void WebstoreAppInstaller::WebContentsDestroyed(
+ content::WebContents* web_contents) {
+ callback_.Run(false, kWebContentsDestroyedError);
+ AbortInstall();
+}
+
+} // namespace file_manager

Powered by Google App Engine
This is Rietveld 408576698