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

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

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, 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 #include "chrome/browser/ui/webui/extensions/extension_loader_handler.h" 5 #include "chrome/browser/ui/webui/extensions/extension_loader_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 124 }
125 125
126 void ExtensionLoaderHandler::FileHelper::MultiFilesSelected( 126 void ExtensionLoaderHandler::FileHelper::MultiFilesSelected(
127 const std::vector<base::FilePath>& files, void* params) { 127 const std::vector<base::FilePath>& files, void* params) {
128 NOTREACHED(); 128 NOTREACHED();
129 } 129 }
130 130
131 ExtensionLoaderHandler::ExtensionLoaderHandler(Profile* profile) 131 ExtensionLoaderHandler::ExtensionLoaderHandler(Profile* profile)
132 : profile_(profile), 132 : profile_(profile),
133 file_helper_(new FileHelper(this)), 133 file_helper_(new FileHelper(this)),
134 weak_ptr_factory_(this) { 134 weak_ptr_factory_(this),
135 extension_error_reporter_observer_(this) {
135 DCHECK(profile_); 136 DCHECK(profile_);
137 extension_error_reporter_observer_.Add(ExtensionErrorReporter::GetInstance());
136 } 138 }
137 139
138 ExtensionLoaderHandler::~ExtensionLoaderHandler() { 140 ExtensionLoaderHandler::~ExtensionLoaderHandler() {
139 } 141 }
140 142
141 void ExtensionLoaderHandler::GetLocalizedValues( 143 void ExtensionLoaderHandler::GetLocalizedValues(
142 content::WebUIDataSource* source) { 144 content::WebUIDataSource* source) {
143 source->AddString( 145 source->AddString(
144 "extensionLoadErrorHeading", 146 "extensionLoadErrorHeading",
145 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOAD_ERROR_HEADING)); 147 l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOAD_ERROR_HEADING));
(...skipping 29 matching lines...) Expand all
175 177
176 void ExtensionLoaderHandler::HandleRetry(const base::ListValue* args) { 178 void ExtensionLoaderHandler::HandleRetry(const base::ListValue* args) {
177 DCHECK(args->empty()); 179 DCHECK(args->empty());
178 LoadUnpackedExtensionImpl(failed_path_); 180 LoadUnpackedExtensionImpl(failed_path_);
179 } 181 }
180 182
181 void ExtensionLoaderHandler::LoadUnpackedExtensionImpl( 183 void ExtensionLoaderHandler::LoadUnpackedExtensionImpl(
182 const base::FilePath& file_path) { 184 const base::FilePath& file_path) {
183 scoped_refptr<UnpackedInstaller> installer = UnpackedInstaller::Create( 185 scoped_refptr<UnpackedInstaller> installer = UnpackedInstaller::Create(
184 ExtensionSystem::Get(profile_)->extension_service()); 186 ExtensionSystem::Get(profile_)->extension_service());
185 installer->set_on_failure_callback(
186 base::Bind(&ExtensionLoaderHandler::OnLoadFailure,
187 weak_ptr_factory_.GetWeakPtr()));
188 187
189 // We do our own error handling, so we don't want a load failure to trigger 188 // We do our own error handling, so we don't want a load failure to trigger
190 // a dialog. 189 // a dialog.
191 installer->set_be_noisy_on_failure(false); 190 installer->set_be_noisy_on_failure(false);
192 191
193 installer->Load(file_path); 192 installer->Load(file_path);
194 } 193 }
195 194
196 void ExtensionLoaderHandler::OnLoadFailure(const base::FilePath& file_path, 195 void ExtensionLoaderHandler::OnLoadFailure(const base::FilePath& file_path,
197 const std::string& error) { 196 const std::string& error) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 highlighter.SetHighlightedRegions(&manifest_value); 236 highlighter.SetHighlightedRegions(&manifest_value);
238 237
239 web_ui()->CallJavascriptFunction( 238 web_ui()->CallJavascriptFunction(
240 "extensions.ExtensionLoader.notifyLoadFailed", 239 "extensions.ExtensionLoader.notifyLoadFailed",
241 file_value, 240 file_value,
242 error_value, 241 error_value,
243 manifest_value); 242 manifest_value);
244 } 243 }
245 244
246 } // namespace extensions 245 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698