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

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: Minor changes, moved observer class 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 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"
16 #include "chrome/browser/extensions/extension_error_reporter.h"
15 #include "content/public/browser/web_ui_message_handler.h" 17 #include "content/public/browser/web_ui_message_handler.h"
16 18
17 namespace base { 19 namespace base {
18 class ListValue; 20 class ListValue;
19 } 21 }
20 22
21 namespace content { 23 namespace content {
22 class WebUIDataSource; 24 class WebUIDataSource;
23 } 25 }
24 26
25 class Profile; 27 class Profile;
26 28
27 namespace extensions { 29 namespace extensions {
28 30
29 class Extension; 31 class Extension;
30 32
31 // The handler page for the Extension Commands UI overlay. 33 // The handler page for the Extension Commands UI overlay.
32 class ExtensionLoaderHandler : public content::WebUIMessageHandler { 34 class ExtensionLoaderHandler : public content::WebUIMessageHandler,
35 public ExtensionErrorReporter::
36 ExtensionErrorReporterObserver {
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:
44 class FileHelper; 48 class FileHelper;
45 49
46 // Handle the 'extensionLoaderLoadUnpacked' message. 50 // Handle the 'extensionLoaderLoadUnpacked' message.
47 void HandleLoadUnpacked(const base::ListValue* args); 51 void HandleLoadUnpacked(const base::ListValue* args);
48 52
49 // Handle the 'extensionLoaderRetry' message. 53 // Handle the 'extensionLoaderRetry' message.
50 void HandleRetry(const base::ListValue* args); 54 void HandleRetry(const base::ListValue* args);
51 55
52 // Try to load an unpacked extension from the given |file_path|. 56 // Try to load an unpacked extension from the given |file_path|.
53 void LoadUnpackedExtensionImpl(const base::FilePath& file_path); 57 void LoadUnpackedExtensionImpl(const base::FilePath& file_path);
54 58
55 // Called when an unpacked extension fails to load. 59 // Called when an unpacked extension fails to load.
56 void OnLoadFailure(const base::FilePath& file_path, const std::string& error); 60 // void OnLoadFailure(const base::FilePath& file_path, const std::string&
Devlin 2014/06/25 19:49:36 still have dead code here.
61 // error);
62 virtual void OnLoadFailure(const base::FilePath& file_path,
63 const std::string& error) OVERRIDE;
57 64
58 // Notify the frontend of the failure. If it was a manifest error, |manifest| 65 // 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 66 // will hold the manifest contents, and |line_number| will point to the line
60 // at which the error was found. 67 // at which the error was found.
61 void NotifyFrontendOfFailure(const base::FilePath& file_path, 68 void NotifyFrontendOfFailure(const base::FilePath& file_path,
62 const std::string& error, 69 const std::string& error,
63 size_t line_number, 70 size_t line_number,
64 const std::string& manifest); 71 const std::string& manifest);
65 72
66 // The profile with which this Handler is associated. 73 // The profile with which this Handler is associated.
67 Profile* profile_; 74 Profile* profile_;
68 75
69 // A helper to manage file picking. 76 // A helper to manage file picking.
70 scoped_ptr<FileHelper> file_helper_; 77 scoped_ptr<FileHelper> file_helper_;
71 78
72 // The file path to the extension that failed to load, or empty. This is 79 // The file path to the extension that failed to load, or empty. This is
73 // loaded when the user selects "retry". 80 // loaded when the user selects "retry".
74 base::FilePath failed_path_; 81 base::FilePath failed_path_;
75 82
76 // Weak pointer factory for posting background tasks. 83 // Weak pointer factory for posting background tasks.
77 base::WeakPtrFactory<ExtensionLoaderHandler> weak_ptr_factory_; 84 base::WeakPtrFactory<ExtensionLoaderHandler> weak_ptr_factory_;
78 85
79 DISALLOW_COPY_AND_ASSIGN(ExtensionLoaderHandler); 86 DISALLOW_COPY_AND_ASSIGN(ExtensionLoaderHandler);
87
88 ScopedObserver<ExtensionErrorReporter, ExtensionErrorReporterObserver>
89 extension_error_reporter_observer_;
80 }; 90 };
81 91
82 } // namespace extensions 92 } // namespace extensions
83 93
84 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_LOADER_HANDLER_H_ 94 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_LOADER_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698