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

Side by Side Diff: chrome/browser/ui/webui/extensions/extension_loader_handler.h

Issue 342003005: Show alert failure for reloading unpacked extensions with bad manifest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Synchronized page loading, support multiple load errors Created 6 years, 5 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_UI_WEBUI_EXTENSIONS_EXTENSION_LOADER_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_LOADER_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_LOADER_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_LOADER_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector>
9 10
10 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
11 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/scoped_observer.h"
17 #include "chrome/browser/extensions/extension_error_reporter.h"
15 #include "content/public/browser/web_ui_message_handler.h" 18 #include "content/public/browser/web_ui_message_handler.h"
16 19
17 namespace base { 20 namespace base {
18 class ListValue; 21 class ListValue;
19 } 22 }
20 23
21 namespace content { 24 namespace content {
22 class WebUIDataSource; 25 class WebUIDataSource;
23 } 26 }
24 27
25 class Profile; 28 class Profile;
26 29
27 namespace extensions { 30 namespace extensions {
28 31
29 class Extension; 32 class Extension;
30 33
31 // The handler page for the Extension Commands UI overlay. 34 // The handler page for the Extension Commands UI overlay.
32 class ExtensionLoaderHandler : public content::WebUIMessageHandler { 35 class ExtensionLoaderHandler : public content::WebUIMessageHandler,
36 public ExtensionErrorReporter::Observer {
33 public: 37 public:
34 explicit ExtensionLoaderHandler(Profile* profile); 38 explicit ExtensionLoaderHandler(Profile* profile);
35 virtual ~ExtensionLoaderHandler(); 39 virtual ~ExtensionLoaderHandler();
36 40
37 // Fetches the localized values for the page and deposits them into |source|. 41 // Fetches the localized values for the page and deposits them into |source|.
38 void GetLocalizedValues(content::WebUIDataSource* source); 42 void GetLocalizedValues(content::WebUIDataSource* source);
39 43
40 // WebUIMessageHandler implementation. 44 // WebUIMessageHandler implementation.
41 virtual void RegisterMessages() OVERRIDE; 45 virtual void RegisterMessages() OVERRIDE;
42 46
43 private: 47 private:
48 class FailureData;
49
50 // Holds information about all unpacked extension install failures that
51 // were reported while the extensions page was loading.
52 std::vector<FailureData*> failures_;
Devlin 2014/06/27 22:31:10 member variables at the bottom.
gpdavis 2014/06/28 02:31:18 Done.
53
44 class FileHelper; 54 class FileHelper;
45 55
46 // Handle the 'extensionLoaderLoadUnpacked' message. 56 // Handle the 'extensionLoaderLoadUnpacked' message.
47 void HandleLoadUnpacked(const base::ListValue* args); 57 void HandleLoadUnpacked(const base::ListValue* args);
48 58
49 // Handle the 'extensionLoaderRetry' message. 59 // Handle the 'extensionLoaderRetry' message.
50 void HandleRetry(const base::ListValue* args); 60 void HandleRetry(const base::ListValue* args);
51 61
62 // Handle the 'extensionLoaderSetDisplayLoading' message.
63 void HandleSetDisplayLoading(const base::ListValue* args);
64
65 // Handle the 'extensionLoaderDisplayFailures' message.
66 void HandleDisplayFailures(const base::ListValue* args);
67
52 // Try to load an unpacked extension from the given |file_path|. 68 // Try to load an unpacked extension from the given |file_path|.
53 void LoadUnpackedExtensionImpl(const base::FilePath& file_path); 69 void LoadUnpackedExtensionImpl(const base::FilePath& file_path);
54 70
55 // Called when an unpacked extension fails to load. 71 // Called when an unpacked extension fails to load.
Devlin 2014/06/27 22:31:10 This comment should be updated to be: "ExtensionEr
gpdavis 2014/06/28 02:31:18 Done.
56 void OnLoadFailure(const base::FilePath& file_path, const std::string& error); 72 virtual void OnLoadFailure(const base::FilePath& file_path,
73 const std::string& error) OVERRIDE;
57 74
58 // Notify the frontend of the failure. If it was a manifest error, |manifest| 75 // Notify the frontend of the failure. If it was a manifest error, |manifest|
59 // will hold the manifest contents, and |line_number| will point to the line 76 // will hold the manifest contents, and |line_number| will point to the line
60 // at which the error was found. 77 // at which the error was found.
61 void NotifyFrontendOfFailure(const base::FilePath& file_path, 78 void NotifyFrontendOfFailure(const base::FilePath& file_path,
62 const std::string& error, 79 const std::string& error,
63 size_t line_number, 80 size_t line_number,
64 const std::string& manifest); 81 const std::string& manifest);
65 82
66 // The profile with which this Handler is associated. 83 // The profile with which this Handler is associated.
67 Profile* profile_; 84 Profile* profile_;
68 85
69 // A helper to manage file picking. 86 // A helper to manage file picking.
70 scoped_ptr<FileHelper> file_helper_; 87 scoped_ptr<FileHelper> file_helper_;
71 88
72 // The file path to the extension that failed to load, or empty. This is 89 // The file path to the extension that failed to load, or empty. This is
73 // loaded when the user selects "retry". 90 // loaded when the user selects "retry".
74 base::FilePath failed_path_; 91 base::FilePath failed_path_;
75 92
76 // Weak pointer factory for posting background tasks. 93 // Weak pointer factory for posting background tasks.
77 base::WeakPtrFactory<ExtensionLoaderHandler> weak_ptr_factory_; 94 base::WeakPtrFactory<ExtensionLoaderHandler> weak_ptr_factory_;
78 95
96 ScopedObserver<ExtensionErrorReporter, ExtensionErrorReporter::Observer>
97 extension_error_reporter_observer_;
98
99 bool display_ready_;
100
79 DISALLOW_COPY_AND_ASSIGN(ExtensionLoaderHandler); 101 DISALLOW_COPY_AND_ASSIGN(ExtensionLoaderHandler);
80 }; 102 };
81 103
82 } // namespace extensions 104 } // namespace extensions
83 105
84 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_LOADER_HANDLER_H_ 106 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_LOADER_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698