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

Side by Side Diff: chrome/browser/ui/global_error_service.cc

Issue 7948003: Update error badge on wrench menu button (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/global_error_service.h" 5 #include "chrome/browser/ui/global_error_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "chrome/browser/ui/global_error.h" 10 #include "chrome/browser/ui/global_error.h"
11 #include "chrome/common/chrome_notification_types.h"
12 #include "content/common/notification_service.h"
11 13
12 GlobalErrorService::GlobalErrorService() { 14 GlobalErrorService::GlobalErrorService(Profile* profile) : profile_(profile) {
13 } 15 }
14 16
15 GlobalErrorService::~GlobalErrorService() { 17 GlobalErrorService::~GlobalErrorService() {
16 STLDeleteElements(&errors_); 18 STLDeleteElements(&errors_);
17 } 19 }
18 20
19 void GlobalErrorService::AddGlobalError(GlobalError* error) { 21 void GlobalErrorService::AddGlobalError(GlobalError* error) {
20 errors_.push_back(error); 22 errors_.push_back(error);
23 NotifyErrorsChanged(error);
21 } 24 }
22 25
23 void GlobalErrorService::RemoveGlobalError(GlobalError* error) { 26 void GlobalErrorService::RemoveGlobalError(GlobalError* error) {
24 errors_.erase(std::find(errors_.begin(), errors_.end(), error)); 27 errors_.erase(std::find(errors_.begin(), errors_.end(), error));
28 NotifyErrorsChanged(error);
25 } 29 }
26 30
27 GlobalError* GlobalErrorService::GetGlobalErrorByMenuItemCommandID( 31 GlobalError* GlobalErrorService::GetGlobalErrorByMenuItemCommandID(
28 int command_id) const { 32 int command_id) const {
29 for (std::vector<GlobalError*>::const_iterator 33 for (std::vector<GlobalError*>::const_iterator
30 it = errors_.begin(); it != errors_.end(); ++it) { 34 it = errors_.begin(); it != errors_.end(); ++it) {
31 GlobalError* error = *it; 35 GlobalError* error = *it;
32 if (error->HasMenuItem() && command_id == error->MenuItemCommandID()) 36 if (error->HasMenuItem() && command_id == error->MenuItemCommandID())
33 return error; 37 return error;
34 } 38 }
(...skipping 12 matching lines...) Expand all
47 51
48 GlobalError* GlobalErrorService::GetFirstGlobalErrorWithBubbleView() const { 52 GlobalError* GlobalErrorService::GetFirstGlobalErrorWithBubbleView() const {
49 for (std::vector<GlobalError*>::const_iterator 53 for (std::vector<GlobalError*>::const_iterator
50 it = errors_.begin(); it != errors_.end(); ++it) { 54 it = errors_.begin(); it != errors_.end(); ++it) {
51 GlobalError* error = *it; 55 GlobalError* error = *it;
52 if (error->HasBubbleView() && !error->HasShownBubbleView()) 56 if (error->HasBubbleView() && !error->HasShownBubbleView())
53 return error; 57 return error;
54 } 58 }
55 return NULL; 59 return NULL;
56 } 60 }
61
62 void GlobalErrorService::NotifyErrorsChanged(GlobalError* error) {
63 NotificationService::current()->Notify(
64 chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED,
65 Source<Profile>(profile_),
66 Details<GlobalError>(error));
67 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/global_error_service.h ('k') | chrome/browser/ui/global_error_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698