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