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

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: Created 6 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
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 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/scoped_observer.h"
15 #include "content/public/browser/web_ui_message_handler.h" 16 #include "content/public/browser/web_ui_message_handler.h"
17 #include "chrome/browser/extensions/extension_error_reporter.h"
18 #include "chrome/browser/extensions/extension_error_reporter_observer.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;
29 class ExtensionErrorReporter;
30 class ExtensionErrorReporterObserver;
26 31
27 namespace extensions { 32 namespace extensions {
28 33
29 class Extension; 34 class Extension;
30 35
31 // The handler page for the Extension Commands UI overlay. 36 // The handler page for the Extension Commands UI overlay.
32 class ExtensionLoaderHandler : public content::WebUIMessageHandler { 37 class ExtensionLoaderHandler : public content::WebUIMessageHandler,
38 public ExtensionErrorReporterObserver {
33 public: 39 public:
34 explicit ExtensionLoaderHandler(Profile* profile); 40 explicit ExtensionLoaderHandler(Profile* profile);
35 virtual ~ExtensionLoaderHandler(); 41 virtual ~ExtensionLoaderHandler();
36 42
37 // Fetches the localized values for the page and deposits them into |source|. 43 // Fetches the localized values for the page and deposits them into |source|.
38 void GetLocalizedValues(content::WebUIDataSource* source); 44 void GetLocalizedValues(content::WebUIDataSource* source);
39 45
40 // WebUIMessageHandler implementation. 46 // WebUIMessageHandler implementation.
41 virtual void RegisterMessages() OVERRIDE; 47 virtual void RegisterMessages() OVERRIDE;
42 48
49 virtual void OnLoadFailure(const base::FilePath& file_path,
50 const std::string& error) OVERRIDE;
51
43 private: 52 private:
44 class FileHelper; 53 class FileHelper;
45 54
46 // Handle the 'extensionLoaderLoadUnpacked' message. 55 // Handle the 'extensionLoaderLoadUnpacked' message.
47 void HandleLoadUnpacked(const base::ListValue* args); 56 void HandleLoadUnpacked(const base::ListValue* args);
48 57
49 // Handle the 'extensionLoaderRetry' message. 58 // Handle the 'extensionLoaderRetry' message.
50 void HandleRetry(const base::ListValue* args); 59 void HandleRetry(const base::ListValue* args);
51 60
52 // Try to load an unpacked extension from the given |file_path|. 61 // Try to load an unpacked extension from the given |file_path|.
53 void LoadUnpackedExtensionImpl(const base::FilePath& file_path); 62 void LoadUnpackedExtensionImpl(const base::FilePath& file_path);
54 63
55 // Called when an unpacked extension fails to load. 64 // Called when an unpacked extension fails to load.
56 void OnLoadFailure(const base::FilePath& file_path, const std::string& error); 65 // void OnLoadFailure(const base::FilePath& file_path, const std::string&
66 // error);
57 67
58 // Notify the frontend of the failure. If it was a manifest error, |manifest| 68 // 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 69 // will hold the manifest contents, and |line_number| will point to the line
60 // at which the error was found. 70 // at which the error was found.
61 void NotifyFrontendOfFailure(const base::FilePath& file_path, 71 void NotifyFrontendOfFailure(const base::FilePath& file_path,
62 const std::string& error, 72 const std::string& error,
63 size_t line_number, 73 size_t line_number,
64 const std::string& manifest); 74 const std::string& manifest);
65 75
66 // The profile with which this Handler is associated. 76 // The profile with which this Handler is associated.
67 Profile* profile_; 77 Profile* profile_;
68 78
69 // A helper to manage file picking. 79 // A helper to manage file picking.
70 scoped_ptr<FileHelper> file_helper_; 80 scoped_ptr<FileHelper> file_helper_;
71 81
72 // The file path to the extension that failed to load, or empty. This is 82 // The file path to the extension that failed to load, or empty. This is
73 // loaded when the user selects "retry". 83 // loaded when the user selects "retry".
74 base::FilePath failed_path_; 84 base::FilePath failed_path_;
75 85
76 // Weak pointer factory for posting background tasks. 86 // Weak pointer factory for posting background tasks.
77 base::WeakPtrFactory<ExtensionLoaderHandler> weak_ptr_factory_; 87 base::WeakPtrFactory<ExtensionLoaderHandler> weak_ptr_factory_;
78 88
79 DISALLOW_COPY_AND_ASSIGN(ExtensionLoaderHandler); 89 DISALLOW_COPY_AND_ASSIGN(ExtensionLoaderHandler);
90
91 ScopedObserver<ExtensionErrorReporter, ExtensionErrorReporterObserver>
92 extension_error_reporter_observer_;
80 }; 93 };
81 94
82 } // namespace extensions 95 } // namespace extensions
83 96
84 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_LOADER_HANDLER_H_ 97 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_LOADER_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698