OLD | NEW |
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_PROTECTOR_SETTINGS_CHANGE_GLOBAL_ERROR_H_ | 5 #ifndef CHROME_BROWSER_PROTECTOR_SETTINGS_CHANGE_GLOBAL_ERROR_H_ |
6 #define CHROME_BROWSER_PROTECTOR_SETTINGS_CHANGE_GLOBAL_ERROR_H_ | 6 #define CHROME_BROWSER_PROTECTOR_SETTINGS_CHANGE_GLOBAL_ERROR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
13 #include "chrome/browser/protector/setting_change.h" | 12 #include "chrome/browser/protector/setting_change.h" |
14 #include "chrome/browser/ui/global_error.h" | 13 #include "chrome/browser/ui/global_error.h" |
15 | 14 |
16 class Browser; | 15 class Browser; |
17 class Profile; | 16 class Profile; |
18 | 17 |
19 namespace protector { | 18 namespace protector { |
20 | 19 |
21 class SettingsChangeGlobalErrorDelegate; | 20 class SettingsChangeGlobalErrorDelegate; |
22 | 21 |
23 // Global error about unwanted settings changes. | 22 // Global error about unwanted settings changes. |
24 class SettingsChangeGlobalError : public GlobalError { | 23 class SettingsChangeGlobalError : public GlobalError { |
25 public: | 24 public: |
26 // Creates new global error about setting changes |change| and takes | 25 // Creates new global error about settings changes |changes|. Takes |
27 // ownership over it. Uses |delegate| to notify about user decision. | 26 // ownership over |changes| contents. |
28 SettingsChangeGlobalError(SettingChange* change, | 27 // Uses |delegate| to notify about user decision. |
29 SettingsChangeGlobalErrorDelegate* delegate); | 28 SettingsChangeGlobalError( |
| 29 const SettingChangeVector& changes, |
| 30 SettingsChangeGlobalErrorDelegate* delegate); |
30 virtual ~SettingsChangeGlobalError(); | 31 virtual ~SettingsChangeGlobalError(); |
31 | 32 |
32 // Displays a global error bubble for the given browser profile. | 33 // Displays a global error bubble for the given browser profile. |
33 // Can be called from any thread. | 34 // Can be called from any thread. |
34 void ShowForProfile(Profile* profile); | 35 void ShowForProfile(Profile* profile); |
35 | 36 |
36 // Browser that the bubble has been last time shown for. | 37 // Browser that the bubble has been last time shown for. |
37 Browser* browser() const { return browser_; } | 38 Browser* browser() const { return browser_; } |
38 | 39 |
39 SettingChange* mutable_change() { return change_.get(); } | 40 SettingChangeVector* mutable_changes() { return &changes_; } |
40 | 41 |
41 // GlobalError implementation. | 42 // GlobalError implementation. |
42 virtual bool HasBadge() OVERRIDE; | 43 virtual bool HasBadge() OVERRIDE; |
43 virtual bool HasMenuItem() OVERRIDE; | 44 virtual bool HasMenuItem() OVERRIDE; |
44 virtual int MenuItemCommandID() OVERRIDE; | 45 virtual int MenuItemCommandID() OVERRIDE; |
45 virtual string16 MenuItemLabel() OVERRIDE; | 46 virtual string16 MenuItemLabel() OVERRIDE; |
46 virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; | 47 virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; |
47 virtual bool HasBubbleView() OVERRIDE; | 48 virtual bool HasBubbleView() OVERRIDE; |
48 virtual string16 GetBubbleViewTitle() OVERRIDE; | 49 virtual string16 GetBubbleViewTitle() OVERRIDE; |
49 virtual string16 GetBubbleViewMessage() OVERRIDE; | 50 virtual string16 GetBubbleViewMessage() OVERRIDE; |
50 virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE; | 51 virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE; |
51 virtual string16 GetBubbleViewCancelButtonLabel() OVERRIDE; | 52 virtual string16 GetBubbleViewCancelButtonLabel() OVERRIDE; |
52 virtual void BubbleViewDidClose() OVERRIDE; | 53 virtual void BubbleViewDidClose() OVERRIDE; |
53 virtual void BubbleViewAcceptButtonPressed() OVERRIDE; | 54 virtual void BubbleViewAcceptButtonPressed() OVERRIDE; |
54 virtual void BubbleViewCancelButtonPressed() OVERRIDE; | 55 virtual void BubbleViewCancelButtonPressed() OVERRIDE; |
55 | 56 |
56 private: | 57 private: |
57 // Helper called on the UI thread to add this global error to the default | 58 // Helper called on the UI thread to add this global error to the default |
58 // profile (stored in |profile_|). | 59 // profile (stored in |profile_|). |
59 void AddToProfile(Profile* profile); | 60 void AddToProfile(Profile* profile); |
60 | 61 |
61 // Displays global error bubble. Must be called on the UI thread. | 62 // Displays global error bubble. Must be called on the UI thread. |
62 void Show(); | 63 void Show(); |
63 | 64 |
64 // Removes global error from its profile and deletes |this| later. | 65 // Removes global error from its profile and deletes |this| later. |
65 void RemoveFromProfile(); | 66 void RemoveFromProfile(); |
66 | 67 |
67 // Change to show. | 68 // List of changes to show. |
68 scoped_ptr<SettingChange> change_; | 69 SettingChangeVector changes_; |
69 | 70 |
70 // Delegate to notify about user actions. | 71 // Delegate to notify about user actions. |
71 SettingsChangeGlobalErrorDelegate* delegate_; | 72 SettingsChangeGlobalErrorDelegate* delegate_; |
72 | 73 |
73 // Profile that we have been added to. | 74 // Profile that we have been added to. |
74 Profile* profile_; | 75 Profile* profile_; |
75 | 76 |
76 // Browser that we have been shown for. | 77 // Browser that we have been shown for. |
77 Browser* browser_; | 78 Browser* browser_; |
78 | 79 |
79 // True if user has dismissed the bubble by clicking on one of the buttons. | 80 // True if user has dismissed the bubble by clicking on one of the buttons. |
80 bool closed_by_button_; | 81 bool closed_by_button_; |
81 | 82 |
82 base::WeakPtrFactory<SettingsChangeGlobalError> weak_factory_; | 83 base::WeakPtrFactory<SettingsChangeGlobalError> weak_factory_; |
83 | 84 |
84 DISALLOW_COPY_AND_ASSIGN(SettingsChangeGlobalError); | 85 DISALLOW_COPY_AND_ASSIGN(SettingsChangeGlobalError); |
85 }; | 86 }; |
86 | 87 |
87 } // namespace protector | 88 } // namespace protector |
88 | 89 |
89 #endif // CHROME_BROWSER_PROTECTOR_SETTINGS_CHANGE_GLOBAL_ERROR_H_ | 90 #endif // CHROME_BROWSER_PROTECTOR_SETTINGS_CHANGE_GLOBAL_ERROR_H_ |
OLD | NEW |