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

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

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 #ifndef CHROME_BROWSER_UI_GLOBAL_ERROR_SERVICE_H_ 5 #ifndef CHROME_BROWSER_UI_GLOBAL_ERROR_SERVICE_H_
6 #define CHROME_BROWSER_UI_GLOBAL_ERROR_SERVICE_H_ 6 #define CHROME_BROWSER_UI_GLOBAL_ERROR_SERVICE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "chrome/browser/profiles/profile_keyed_service.h" 12 #include "chrome/browser/profiles/profile_keyed_service.h"
13 13
14 class GlobalError; 14 class GlobalError;
15 class Profile;
15 16
16 // This service manages a list of errors that are meant to be shown globally. 17 // This service manages a list of errors that are meant to be shown globally.
17 // If an error applies to an entire profile and not just to a tab then the 18 // If an error applies to an entire profile and not just to a tab then the
18 // error should be shown using this service. Examples of global errors are: 19 // error should be shown using this service. Examples of global errors are:
19 // - the previous session crashed for a given profile. 20 // - the previous session crashed for a given profile.
20 // - a sync error occurred 21 // - a sync error occurred
21 class GlobalErrorService : public ProfileKeyedService { 22 class GlobalErrorService : public ProfileKeyedService {
22 public: 23 public:
23 GlobalErrorService(); 24 explicit GlobalErrorService(Profile* profile);
24 virtual ~GlobalErrorService(); 25 virtual ~GlobalErrorService();
25 26
26 // Adds the given error to the list of global errors and displays it on 27 // Adds the given error to the list of global errors and displays it on
27 // browswer windows. If no browser windows are open then the error is 28 // browswer windows. If no browser windows are open then the error is
28 // displayed once a browser window is opened. This class takes ownership of 29 // displayed once a browser window is opened. This class takes ownership of
29 // the error. 30 // the error.
30 void AddGlobalError(GlobalError* error); 31 void AddGlobalError(GlobalError* error);
31 32
32 // Hides the given error and removes it from the list of global errors. Caller 33 // Hides the given error and removes it from the list of global errors. Caller
33 // then takes ownership of the error and is responsible for deleting it. 34 // then takes ownership of the error and is responsible for deleting it.
34 void RemoveGlobalError(GlobalError* error); 35 void RemoveGlobalError(GlobalError* error);
35 36
36 // Gets the error with the given command ID or NULL if no such error exists. 37 // Gets the error with the given command ID or NULL if no such error exists.
37 // This class maintains ownership of the returned error. 38 // This class maintains ownership of the returned error.
38 GlobalError* GetGlobalErrorByMenuItemCommandID(int command_id) const; 39 GlobalError* GetGlobalErrorByMenuItemCommandID(int command_id) const;
39 40
40 // Gets the badge icon resource ID for the first error with a badge. 41 // Gets the badge icon resource ID for the first error with a badge.
41 // Returns 0 if no such error exists. 42 // Returns 0 if no such error exists.
42 int GetFirstBadgeResourceID() const; 43 int GetFirstBadgeResourceID() const;
43 44
44 // Gets the first error that has a bubble view which hasn't been shown yet. 45 // Gets the first error that has a bubble view which hasn't been shown yet.
45 // Returns NULL if no such error exists. 46 // Returns NULL if no such error exists.
46 GlobalError* GetFirstGlobalErrorWithBubbleView() const; 47 GlobalError* GetFirstGlobalErrorWithBubbleView() const;
47 48
48 // Gets all errors. 49 // Gets all errors.
49 const std::vector<GlobalError*>& errors() { return errors_; } 50 const std::vector<GlobalError*>& errors() { return errors_; }
50 51
52 // Post a notification that a global error has changed and that the error UI
53 // should update it self. Pass NULL for the given error to mean all error UIs
54 // should update.
55 void NotifyErrorsChanged(GlobalError* error);
56
51 private: 57 private:
52 std::vector<GlobalError*> errors_; 58 std::vector<GlobalError*> errors_;
59 Profile* profile_;
sky 2011/09/19 23:53:01 Can you add a comment that this is NULL for tests.
sail 2011/09/20 00:09:07 Done.
53 60
54 DISALLOW_COPY_AND_ASSIGN(GlobalErrorService); 61 DISALLOW_COPY_AND_ASSIGN(GlobalErrorService);
55 }; 62 };
56 63
57 #endif // CHROME_BROWSER_UI_GLOBAL_ERROR_SERVICE_H_ 64 #endif // CHROME_BROWSER_UI_GLOBAL_ERROR_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698