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