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

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

Issue 11087071: Making ShowExtensionInstallDialog a callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android build Created 8 years, 2 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_EXTENSION_INSTALL_PROMPT_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h"
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
13 #include "base/string16.h" 14 #include "base/string16.h"
14 #include "chrome/browser/extensions/crx_installer_error.h" 15 #include "chrome/browser/extensions/crx_installer_error.h"
15 #include "chrome/browser/extensions/image_loading_tracker.h" 16 #include "chrome/browser/extensions/image_loading_tracker.h"
16 #include "chrome/common/extensions/url_pattern.h" 17 #include "chrome/common/extensions/url_pattern.h"
17 #include "google_apis/gaia/oauth2_mint_token_flow.h" 18 #include "google_apis/gaia/oauth2_mint_token_flow.h"
18 #include "third_party/skia/include/core/SkBitmap.h" 19 #include "third_party/skia/include/core/SkBitmap.h"
19 #include "ui/gfx/image/image.h" 20 #include "ui/gfx/image/image.h"
20 #include "ui/gfx/image/image_skia.h" 21 #include "ui/gfx/image/image_skia.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 virtual void InstallUIProceed() = 0; 151 virtual void InstallUIProceed() = 0;
151 152
152 // We call this method to signal that the installation should stop, with 153 // We call this method to signal that the installation should stop, with
153 // |user_initiated| true if the installation was stopped by the user. 154 // |user_initiated| true if the installation was stopped by the user.
154 virtual void InstallUIAbort(bool user_initiated) = 0; 155 virtual void InstallUIAbort(bool user_initiated) = 0;
155 156
156 protected: 157 protected:
157 virtual ~Delegate() {} 158 virtual ~Delegate() {}
158 }; 159 };
159 160
161 typedef base::Callback<void(gfx::NativeWindow,
162 content::PageNavigator*,
163 ExtensionInstallPrompt::Delegate*,
164 const ExtensionInstallPrompt::Prompt&)>
165 ShowDialogCallback;
166
167 // Callback to show the default extension install dialog.
168 // The implementations of this function are platform-specific.
169 static ShowDialogCallback GetDefaultShowDialogCallback();
170
160 // Creates a dummy extension from the |manifest|, replacing the name and 171 // Creates a dummy extension from the |manifest|, replacing the name and
161 // description with the localizations if provided. 172 // description with the localizations if provided.
162 static scoped_refptr<extensions::Extension> GetLocalizedExtensionForDisplay( 173 static scoped_refptr<extensions::Extension> GetLocalizedExtensionForDisplay(
163 const base::DictionaryValue* manifest, 174 const base::DictionaryValue* manifest,
164 int flags, // Extension::InitFromValueFlags 175 int flags, // Extension::InitFromValueFlags
165 const std::string& id, 176 const std::string& id,
166 const std::string& localized_name, 177 const std::string& localized_name,
167 const std::string& localized_description, 178 const std::string& localized_description,
168 std::string* error); 179 std::string* error);
169 180
(...skipping 19 matching lines...) Expand all
189 // This is called by the standalone installer to verify whether the install 200 // This is called by the standalone installer to verify whether the install
190 // from the webstore should proceed. 201 // from the webstore should proceed.
191 // 202 //
192 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. 203 // We *MUST* eventually call either Proceed() or Abort() on |delegate|.
193 virtual void ConfirmStandaloneInstall(Delegate* delegate, 204 virtual void ConfirmStandaloneInstall(Delegate* delegate,
194 const extensions::Extension* extension, 205 const extensions::Extension* extension,
195 SkBitmap* icon, 206 SkBitmap* icon,
196 const Prompt& prompt); 207 const Prompt& prompt);
197 208
198 // This is called by the installer to verify whether the installation from 209 // This is called by the installer to verify whether the installation from
199 // the webstore should proceed. 210 // the webstore should proceed. |show_dialog_callback| is optional and can be
211 // NULL.
200 // 212 //
201 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. 213 // We *MUST* eventually call either Proceed() or Abort() on |delegate|.
202 virtual void ConfirmWebstoreInstall(Delegate* delegate, 214 virtual void ConfirmWebstoreInstall(
203 const extensions::Extension* extension, 215 Delegate* delegate,
204 const SkBitmap* icon); 216 const extensions::Extension* extension,
217 const SkBitmap* icon,
218 const ShowDialogCallback& show_dialog_callback);
205 219
206 // This is called by the installer to verify whether the installation should 220 // This is called by the installer to verify whether the installation should
207 // proceed. This is declared virtual for testing. 221 // proceed. This is declared virtual for testing. |show_dialog_callback| is
222 // optional and can be NULL.
208 // 223 //
209 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. 224 // We *MUST* eventually call either Proceed() or Abort() on |delegate|.
210 virtual void ConfirmInstall(Delegate* delegate, 225 virtual void ConfirmInstall(Delegate* delegate,
211 const extensions::Extension* extension); 226 const extensions::Extension* extension,
227 const ShowDialogCallback& show_dialog_callback);
212 228
213 // This is called by the app handler launcher to verify whether the app 229 // This is called by the app handler launcher to verify whether the app
214 // should be re-enabled. This is declared virtual for testing. 230 // should be re-enabled. This is declared virtual for testing.
215 // 231 //
216 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. 232 // We *MUST* eventually call either Proceed() or Abort() on |delegate|.
217 virtual void ConfirmReEnable(Delegate* delegate, 233 virtual void ConfirmReEnable(Delegate* delegate,
218 const extensions::Extension* extension); 234 const extensions::Extension* extension);
219 235
220 // This is called by the extension permissions API to verify whether an 236 // This is called by the extension permissions API to verify whether an
221 // extension may be granted additional permissions. 237 // extension may be granted additional permissions.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 Prompt prompt_; 320 Prompt prompt_;
305 321
306 // The type of prompt we are going to show. 322 // The type of prompt we are going to show.
307 PromptType prompt_type_; 323 PromptType prompt_type_;
308 324
309 scoped_ptr<OAuth2MintTokenFlow> token_flow_; 325 scoped_ptr<OAuth2MintTokenFlow> token_flow_;
310 326
311 // Keeps track of extension images being loaded on the File thread for the 327 // Keeps track of extension images being loaded on the File thread for the
312 // purpose of showing the install UI. 328 // purpose of showing the install UI.
313 ImageLoadingTracker tracker_; 329 ImageLoadingTracker tracker_;
330
331 // Used to show the confirm dialog.
332 ShowDialogCallback show_dialog_callback_;
314 }; 333 };
315 334
316 namespace chrome { 335 namespace chrome {
317 336
318 // Creates an ExtensionInstallPrompt from |browser|. Caller assumes ownership. 337 // Creates an ExtensionInstallPrompt from |browser|. Caller assumes ownership.
319 // TODO(beng): remove this once various extensions types are weaned from 338 // TODO(beng): remove this once various extensions types are weaned from
320 // Browser. 339 // Browser.
321 ExtensionInstallPrompt* CreateExtensionInstallPromptWithBrowser( 340 ExtensionInstallPrompt* CreateExtensionInstallPromptWithBrowser(
322 Browser* browser); 341 Browser* browser);
323 342
324 } // namespace chrome 343 } // namespace chrome
325 344
326 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ 345 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698