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

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: Cleanup 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"
Devlin 2014/06/24 22:21:12 Only the associated .h file goes at the top, all o
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 TriggerOnLoadFailure(extension_path, error);
Devlin 2014/06/24 22:21:12 You can just inline the notification here.
58 } 60 }
59 61
60 void ExtensionErrorReporter::ReportError(const base::string16& message, 62 void ExtensionErrorReporter::ReportError(const base::string16& message,
61 bool be_noisy) { 63 bool be_noisy) {
62 // NOTE: There won't be a ui_loop_ in the unit test environment. 64 // NOTE: There won't be a ui_loop_ in the unit test environment.
63 if (ui_loop_) { 65 if (ui_loop_) {
64 CHECK(base::MessageLoop::current() == ui_loop_) 66 CHECK(base::MessageLoop::current() == ui_loop_)
65 << "ReportError can only be called from the UI thread."; 67 << "ReportError can only be called from the UI thread.";
66 } 68 }
67 69
(...skipping 11 matching lines...) Expand all
79 } 81 }
80 } 82 }
81 83
82 const std::vector<base::string16>* ExtensionErrorReporter::GetErrors() { 84 const std::vector<base::string16>* ExtensionErrorReporter::GetErrors() {
83 return &errors_; 85 return &errors_;
84 } 86 }
85 87
86 void ExtensionErrorReporter::ClearErrors() { 88 void ExtensionErrorReporter::ClearErrors() {
87 errors_.clear(); 89 errors_.clear();
88 } 90 }
91
92 void ExtensionErrorReporter::AddObserver(
Devlin 2014/06/24 22:21:11 Methods should be defined in the .cc in the same o
gpdavis 2014/06/25 00:21:01 They are implemented in the same order as in the h
Devlin 2014/06/25 19:49:36 Whoops, you're right, my bad.
93 ExtensionErrorReporterObserver* observer) {
94 observers_.AddObserver(observer);
95 }
96
97 void ExtensionErrorReporter::RemoveObserver(
98 ExtensionErrorReporterObserver* observer) {
99 observers_.RemoveObserver(observer);
100 }
101
102 void ExtensionErrorReporter::TriggerOnLoadFailure(
103 const base::FilePath& extension_path,
104 const std::string& error) {
105 FOR_EACH_OBSERVER(ExtensionErrorReporterObserver,
106 observers_,
107 OnLoadFailure(extension_path, error));
108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698