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

Side by Side Diff: chrome/browser/extensions/webstore_inline_installer.h

Issue 7741037: Add WebstoreInlineInstaller (downloads store data, shows the install UI, and starts the install). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Put webstore response in the right directory. Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/values.h"
14 #include "chrome/browser/extensions/extension_install_ui.h"
15 #include "chrome/browser/extensions/webstore_install_helper.h"
16 #include "content/common/url_fetcher.h"
17 #include "third_party/skia/include/core/SkBitmap.h"
18
19 class TabContents;
20 class SafeWebstoreResponseParser;
21
22 // Manages inline installs requested by a page (downloads and parses metadata
23 // from the webstore, shows the install UI, starts the download once the user
24 // confirms). Clients must implement the WebstoreInlineInstaller::Delegate
25 // interface to be notified when the inline install completes (successfully or
26 // not).
27 class WebstoreInlineInstaller
28 : public base::RefCountedThreadSafe<WebstoreInlineInstaller>,
29 public ExtensionInstallUI::Delegate,
30 public URLFetcher::Delegate,
31 public WebstoreInstallHelper::Delegate {
32 public:
33 class Delegate {
34 public:
35 virtual void OnInlineInstallSuccess() = 0;
36 virtual void OnInlineInstallFailure(const std::string& error) = 0;
37 };
38
39 WebstoreInlineInstaller(TabContents* tab_contents,
40 std::string webstore_item_id,
41 Delegate* d);
42 void BeginInstall();
43
44 private:
45 friend class base::RefCountedThreadSafe<WebstoreInlineInstaller>;
46 friend class SafeWebstoreResponseParser;
47
48 virtual ~WebstoreInlineInstaller();
49
50 // Several delegate/client inteface implementations follow. The normal flow
51 // (for successful installs) is:
52 //
53 // 1. BeginInstall: starts the fetch of data from the webstore
54 // 2. OnURLFetchComplete: starts the parsing of data from the webstore
55 // 3. OnWebstoreResponseParseSuccess: starts the parsing of the manifest and
56 // fetching of icon data.
57 // 4. OnWebstoreParseSuccess: shows the install UI
58 // 5. InstallUIProceed: initiates the .crx download/install
59 //
60 // All flows (whether successful or not) end up in CompleteInstall, which
61 // informs our delegate of success/failure.
62
63 // UrlFetcher::Delegate interface implementation.
64 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE;
65
66 // Client callbacks for SafeWebstoreResponseParser when parsing is complete.
67 void OnWebstoreResponseParseSuccess(DictionaryValue* webstore_data);
68 void OnWebstoreResponseParseFailure(const std::string& error);
69
70 // WebstoreInstallHelper::Delegate interface implementation.
71 virtual void OnWebstoreParseSuccess(
72 const SkBitmap& icon,
73 base::DictionaryValue* parsed_manifest) OVERRIDE;
74 virtual void OnWebstoreParseFailure(
75 InstallHelperResultCode result_code,
76 const std::string& error_message) OVERRIDE;
77
78 // ExtensionInstallUI::Delegate interface implementation.
79 virtual void InstallUIProceed() OVERRIDE;
80 virtual void InstallUIAbort(bool user_initiated) OVERRIDE;
81
82 void CompleteInstall(const std::string& error);
83
84 TabContents* tab_contents_;
85 std::string id_;
86 Delegate* delegate_;
87
88 // For fetching webstore JSON data.
89 scoped_ptr<URLFetcher> webstore_data_url_fetcher_;
90
91 // Extracted from the webstore JSON data response.
92 std::string localized_name_;
93 scoped_ptr<DictionaryValue> webstore_data_;
94 scoped_ptr<DictionaryValue> manifest_;
95 SkBitmap icon_;
96
97 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreInlineInstaller);
98 };
99
100 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698