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

Side by Side Diff: chrome/browser/extensions/extension_error_reporter.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: 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/extension_error_reporter.h" 5 #include "chrome/browser/extensions/extension_error_reporter.h"
6 #include "chrome/browser/extensions/extension_error_reporter_observer.h"
6 7
7 #include "build/build_config.h" 8 #include "build/build_config.h"
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
11 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
14 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 content::NotificationService::current()->Notify( 48 content::NotificationService::current()->Notify(
48 chrome::NOTIFICATION_EXTENSION_LOAD_ERROR, 49 chrome::NOTIFICATION_EXTENSION_LOAD_ERROR,
49 content::Source<Profile>(profile), 50 content::Source<Profile>(profile),
50 content::Details<const std::string>(&error)); 51 content::Details<const std::string>(&error));
51 52
52 std::string path_str = base::UTF16ToUTF8(extension_path.LossyDisplayName()); 53 std::string path_str = base::UTF16ToUTF8(extension_path.LossyDisplayName());
53 base::string16 message = base::UTF8ToUTF16( 54 base::string16 message = base::UTF8ToUTF16(
54 base::StringPrintf("Could not load extension from '%s'. %s", 55 base::StringPrintf("Could not load extension from '%s'. %s",
55 path_str.c_str(), 56 path_str.c_str(),
56 error.c_str())); 57 error.c_str()));
57 ReportError(message, be_noisy); 58 // ReportError(message, be_noisy);
59 ReportError(message, false);
60 TriggerOnLoadFailure(extension_path, error);
58 } 61 }
59 62
60 void ExtensionErrorReporter::ReportError(const base::string16& message, 63 void ExtensionErrorReporter::ReportError(const base::string16& message,
61 bool be_noisy) { 64 bool be_noisy) {
65 DLOG(ERROR) << "----ReportError";
62 // NOTE: There won't be a ui_loop_ in the unit test environment. 66 // NOTE: There won't be a ui_loop_ in the unit test environment.
63 if (ui_loop_) { 67 if (ui_loop_) {
64 CHECK(base::MessageLoop::current() == ui_loop_) 68 CHECK(base::MessageLoop::current() == ui_loop_)
65 << "ReportError can only be called from the UI thread."; 69 << "ReportError can only be called from the UI thread.";
66 } 70 }
67 71
68 errors_.push_back(message); 72 errors_.push_back(message);
69 73
70 // TODO(aa): Print the error message out somewhere better. I think we are 74 // TODO(aa): Print the error message out somewhere better. I think we are
71 // going to need some sort of 'extension inspector'. 75 // going to need some sort of 'extension inspector'.
72 LOG(WARNING) << "Extension error: " << message; 76 LOG(WARNING) << "Extension error: " << message;
73 77
74 if (enable_noisy_errors_ && be_noisy) { 78 if (enable_noisy_errors_ && be_noisy) {
75 chrome::ShowMessageBox(NULL, 79 chrome::ShowMessageBox(NULL,
76 base::ASCIIToUTF16("Extension error"), 80 base::ASCIIToUTF16("Extension error"),
77 message, 81 message,
78 chrome::MESSAGE_BOX_TYPE_WARNING); 82 chrome::MESSAGE_BOX_TYPE_WARNING);
79 } 83 }
80 } 84 }
81 85
82 const std::vector<base::string16>* ExtensionErrorReporter::GetErrors() { 86 const std::vector<base::string16>* ExtensionErrorReporter::GetErrors() {
83 return &errors_; 87 return &errors_;
84 } 88 }
85 89
86 void ExtensionErrorReporter::ClearErrors() { 90 void ExtensionErrorReporter::ClearErrors() {
87 errors_.clear(); 91 errors_.clear();
88 } 92 }
93
94 void ExtensionErrorReporter::AddObserver(
95 ExtensionErrorReporterObserver* observer) {
96 observers_.AddObserver(observer);
97 }
98
99 void ExtensionErrorReporter::RemoveObserver(
100 ExtensionErrorReporterObserver* observer) {
101 observers_.RemoveObserver(observer);
102 }
103
104 void ExtensionErrorReporter::TriggerOnLoadFailure(
105 const base::FilePath& extension_path,
106 const std::string& error) {
107 DLOG(ERROR) << "---TriggerOnLoadFailure";
108 FOR_EACH_OBSERVER(ExtensionErrorReporterObserver,
109 observers_,
110 OnLoadFailure(extension_path, error));
111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698