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

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

Issue 10388252: Refactoring ExtenionInstallUI to abstract the Browser references. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced + mac fix Created 8 years, 6 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/extensions/extension_install_ui.h" 14 #include "chrome/browser/extensions/extension_install_prompt.h"
15 #include "chrome/browser/extensions/webstore_install_helper.h" 15 #include "chrome/browser/extensions/webstore_install_helper.h"
16 #include "chrome/browser/extensions/webstore_installer.h" 16 #include "chrome/browser/extensions/webstore_installer.h"
17 #include "content/public/browser/web_contents_observer.h" 17 #include "content/public/browser/web_contents_observer.h"
18 #include "googleurl/src/gurl.h" 18 #include "googleurl/src/gurl.h"
19 #include "net/url_request/url_fetcher_delegate.h" 19 #include "net/url_request/url_fetcher_delegate.h"
20 #include "third_party/skia/include/core/SkBitmap.h" 20 #include "third_party/skia/include/core/SkBitmap.h"
21 21
22 class SafeWebstoreResponseParser; 22 class SafeWebstoreResponseParser;
23 23
24 namespace extensions { 24 namespace extensions {
25 class Extension; 25 class Extension;
26 } 26 }
27 27
28 namespace net { 28 namespace net {
29 class URLFetcher; 29 class URLFetcher;
30 } 30 }
31 31
32 // Manages inline installs requested by a page (downloads and parses metadata 32 // Manages inline installs requested by a page (downloads and parses metadata
33 // from the webstore, shows the install UI, starts the download once the user 33 // from the webstore, shows the install UI, starts the download once the user
34 // confirms). Clients must implement the WebstoreInlineInstaller::Delegate 34 // confirms). Clients must implement the WebstoreInlineInstaller::Delegate
35 // interface to be notified when the inline install completes (successfully or 35 // interface to be notified when the inline install completes (successfully or
36 // not). The client will not be notified if the WebContents that this install 36 // not). The client will not be notified if the WebContents that this install
37 // request is attached to goes away. 37 // request is attached to goes away.
38 class WebstoreInlineInstaller 38 class WebstoreInlineInstaller
39 : public base::RefCountedThreadSafe<WebstoreInlineInstaller>, 39 : public base::RefCountedThreadSafe<WebstoreInlineInstaller>,
40 public ExtensionInstallUI::Delegate, 40 public ExtensionInstallPrompt::Delegate,
41 public content::WebContentsObserver, 41 public content::WebContentsObserver,
42 public net::URLFetcherDelegate, 42 public net::URLFetcherDelegate,
43 public WebstoreInstaller::Delegate, 43 public WebstoreInstaller::Delegate,
44 public WebstoreInstallHelper::Delegate { 44 public WebstoreInstallHelper::Delegate {
45 public: 45 public:
46 class Delegate { 46 class Delegate {
47 public: 47 public:
48 virtual void OnInlineInstallSuccess(int install_id, 48 virtual void OnInlineInstallSuccess(int install_id,
49 int return_route_id) = 0; 49 int return_route_id) = 0;
50 virtual void OnInlineInstallFailure(int install_id, 50 virtual void OnInlineInstallFailure(int install_id,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // WebstoreInstallHelper::Delegate interface implementation. 90 // WebstoreInstallHelper::Delegate interface implementation.
91 virtual void OnWebstoreParseSuccess( 91 virtual void OnWebstoreParseSuccess(
92 const std::string& id, 92 const std::string& id,
93 const SkBitmap& icon, 93 const SkBitmap& icon,
94 base::DictionaryValue* parsed_manifest) OVERRIDE; 94 base::DictionaryValue* parsed_manifest) OVERRIDE;
95 virtual void OnWebstoreParseFailure( 95 virtual void OnWebstoreParseFailure(
96 const std::string& id, 96 const std::string& id,
97 InstallHelperResultCode result_code, 97 InstallHelperResultCode result_code,
98 const std::string& error_message) OVERRIDE; 98 const std::string& error_message) OVERRIDE;
99 99
100 // ExtensionInstallUI::Delegate interface implementation. 100 // ExtensionInstallPrompt::Delegate interface implementation.
101 virtual void InstallUIProceed() OVERRIDE; 101 virtual void InstallUIProceed() OVERRIDE;
102 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; 102 virtual void InstallUIAbort(bool user_initiated) OVERRIDE;
103 103
104 // content::WebContentsObserver interface implementation. 104 // content::WebContentsObserver interface implementation.
105 virtual void WebContentsDestroyed( 105 virtual void WebContentsDestroyed(
106 content::WebContents* web_contents) OVERRIDE; 106 content::WebContents* web_contents) OVERRIDE;
107 107
108 // WebstoreInstaller::Delegate interface implementation. 108 // WebstoreInstaller::Delegate interface implementation.
109 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; 109 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE;
110 virtual void OnExtensionInstallFailure(const std::string& id, 110 virtual void OnExtensionInstallFailure(const std::string& id,
111 const std::string& error) OVERRIDE; 111 const std::string& error) OVERRIDE;
112 112
113 void CompleteInstall(const std::string& error); 113 void CompleteInstall(const std::string& error);
114 114
115 // Checks whether the install is initiated by a page in the verified site 115 // Checks whether the install is initiated by a page in the verified site
116 // (which is at least a domain, but can also have a port or a path). 116 // (which is at least a domain, but can also have a port or a path).
117 static bool IsRequestorURLInVerifiedSite(const GURL& requestor_url, 117 static bool IsRequestorURLInVerifiedSite(const GURL& requestor_url,
118 const std::string& verified_site); 118 const std::string& verified_site);
119 119
120 int install_id_; 120 int install_id_;
121 int return_route_id_; 121 int return_route_id_;
122 std::string id_; 122 std::string id_;
123 GURL requestor_url_; 123 GURL requestor_url_;
124 Delegate* delegate_; 124 Delegate* delegate_;
125 scoped_ptr<ExtensionInstallUI> install_ui_; 125 scoped_ptr<ExtensionInstallPrompt> install_ui_;
126 126
127 // For fetching webstore JSON data. 127 // For fetching webstore JSON data.
128 scoped_ptr<net::URLFetcher> webstore_data_url_fetcher_; 128 scoped_ptr<net::URLFetcher> webstore_data_url_fetcher_;
129 129
130 // Extracted from the webstore JSON data response. 130 // Extracted from the webstore JSON data response.
131 std::string localized_name_; 131 std::string localized_name_;
132 std::string localized_description_; 132 std::string localized_description_;
133 std::string localized_user_count_; 133 std::string localized_user_count_;
134 double average_rating_; 134 double average_rating_;
135 int rating_count_; 135 int rating_count_;
136 scoped_ptr<DictionaryValue> webstore_data_; 136 scoped_ptr<DictionaryValue> webstore_data_;
137 scoped_ptr<DictionaryValue> manifest_; 137 scoped_ptr<DictionaryValue> manifest_;
138 scoped_refptr<extensions::Extension> dummy_extension_; 138 scoped_refptr<extensions::Extension> dummy_extension_;
139 SkBitmap icon_; 139 SkBitmap icon_;
140 140
141 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreInlineInstaller); 141 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreInlineInstaller);
142 }; 142 };
143 143
144 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_ 144 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/unpacked_installer.cc ('k') | chrome/browser/extensions/webstore_inline_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698