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

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

Issue 1534123002: [Extensions] Migrate ExtensionInstallPrompt::Delegate to be a callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_EXTERNAL_INSTALL_ERROR_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTERNAL_INSTALL_ERROR_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_INSTALL_ERROR_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_INSTALL_ERROR_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 15 matching lines...) Expand all
26 namespace extensions { 26 namespace extensions {
27 class Extension; 27 class Extension;
28 class ExternalInstallManager; 28 class ExternalInstallManager;
29 class WebstoreDataFetcher; 29 class WebstoreDataFetcher;
30 30
31 // An error to show the user an extension has been externally installed. The 31 // An error to show the user an extension has been externally installed. The
32 // error will automatically fetch data about the extension from the webstore (if 32 // error will automatically fetch data about the extension from the webstore (if
33 // possible) and will handle adding itself to the GlobalErrorService when 33 // possible) and will handle adding itself to the GlobalErrorService when
34 // initialized and removing itself from the GlobalErrorService upon 34 // initialized and removing itself from the GlobalErrorService upon
35 // destruction. 35 // destruction.
36 class ExternalInstallError : public ExtensionInstallPrompt::Delegate, 36 class ExternalInstallError : public WebstoreDataFetcherDelegate {
37 public WebstoreDataFetcherDelegate {
38 public: 37 public:
39 // The possible types of errors to show. A menu alert adds a menu item to the 38 // The possible types of errors to show. A menu alert adds a menu item to the
40 // wrench, which spawns an extension install dialog when clicked. The bubble 39 // wrench, which spawns an extension install dialog when clicked. The bubble
41 // alert also adds an item, but spawns a bubble instead (less invasive and 40 // alert also adds an item, but spawns a bubble instead (less invasive and
42 // easier to dismiss). 41 // easier to dismiss).
43 enum AlertType { 42 enum AlertType {
44 BUBBLE_ALERT, 43 BUBBLE_ALERT,
45 MENU_ALERT 44 MENU_ALERT
46 }; 45 };
47 46
48 ExternalInstallError(content::BrowserContext* browser_context, 47 ExternalInstallError(content::BrowserContext* browser_context,
49 const std::string& extension_id, 48 const std::string& extension_id,
50 AlertType error_type, 49 AlertType error_type,
51 ExternalInstallManager* manager); 50 ExternalInstallManager* manager);
52 ~ExternalInstallError() override; 51 ~ExternalInstallError() override;
53 52
54 // ExtensionInstallPrompt::Delegate implementation. 53 void OnInstallPromptDone(ExtensionInstallPrompt::Result result);
55 void InstallUIProceed() override;
56 void InstallUIAbort(bool user_initiated) override;
57 54
58 // Show the associated dialog. This should only be called once the dialog is 55 // Show the associated dialog. This should only be called once the dialog is
59 // ready. 56 // ready.
60 void ShowDialog(Browser* browser); 57 void ShowDialog(Browser* browser);
61 58
62 // Return the associated extension, or NULL. 59 // Return the associated extension, or NULL.
63 const Extension* GetExtension() const; 60 const Extension* GetExtension() const;
64 61
65 const std::string& extension_id() const { return extension_id_; } 62 const std::string& extension_id() const { return extension_id_; }
66 AlertType alert_type() const { return alert_type_; } 63 AlertType alert_type() const { return alert_type_; }
67 64
68 private: 65 private:
69 // WebstoreDataFetcherDelegate implementation. 66 // WebstoreDataFetcherDelegate implementation.
70 void OnWebstoreRequestFailure() override; 67 void OnWebstoreRequestFailure() override;
71 void OnWebstoreResponseParseSuccess( 68 void OnWebstoreResponseParseSuccess(
72 scoped_ptr<base::DictionaryValue> webstore_data) override; 69 scoped_ptr<base::DictionaryValue> webstore_data) override;
73 void OnWebstoreResponseParseFailure(const std::string& error) override; 70 void OnWebstoreResponseParseFailure(const std::string& error) override;
74 71
75 // Called when data fetching has completed (either successfully or not). 72 // Called when data fetching has completed (either successfully or not).
76 void OnFetchComplete(); 73 void OnFetchComplete();
77 74
78 // Called when the dialog has been successfully populated, and is ready to be 75 // Called when the dialog has been successfully populated, and is ready to be
79 // shown. 76 // shown.
80 void OnDialogReady(ExtensionInstallPromptShowParams* show_params, 77 void OnDialogReady(ExtensionInstallPromptShowParams* show_params,
81 ExtensionInstallPrompt::Delegate* prompt_delegate, 78 const ExtensionInstallPrompt::DoneCallback& done_callback,
82 scoped_ptr<ExtensionInstallPrompt::Prompt> prompt); 79 scoped_ptr<ExtensionInstallPrompt::Prompt> prompt);
83 80
84 // The associated BrowserContext. 81 // The associated BrowserContext.
85 content::BrowserContext* browser_context_; 82 content::BrowserContext* browser_context_;
86 83
87 // The id of the external extension. 84 // The id of the external extension.
88 std::string extension_id_; 85 std::string extension_id_;
89 86
90 // The type of alert to show the user. 87 // The type of alert to show the user.
91 AlertType alert_type_; 88 AlertType alert_type_;
(...skipping 18 matching lines...) Expand all
110 scoped_ptr<WebstoreDataFetcher> webstore_data_fetcher_; 107 scoped_ptr<WebstoreDataFetcher> webstore_data_fetcher_;
111 108
112 base::WeakPtrFactory<ExternalInstallError> weak_factory_; 109 base::WeakPtrFactory<ExternalInstallError> weak_factory_;
113 110
114 DISALLOW_COPY_AND_ASSIGN(ExternalInstallError); 111 DISALLOW_COPY_AND_ASSIGN(ExternalInstallError);
115 }; 112 };
116 113
117 } // namespace extensions 114 } // namespace extensions
118 115
119 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_INSTALL_ERROR_H_ 116 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_INSTALL_ERROR_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service_unittest.cc ('k') | chrome/browser/extensions/external_install_error.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698