OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_PROTECTOR_SETTINGS_CHANGE_GLOBAL_ERROR_H_ | |
6 #define CHROME_BROWSER_PROTECTOR_SETTINGS_CHANGE_GLOBAL_ERROR_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/compiler_specific.h" | |
10 #include "base/memory/weak_ptr.h" | |
11 #include "chrome/app/chrome_command_ids.h" | |
12 #include "chrome/browser/protector/base_setting_change.h" | |
13 #include "chrome/browser/ui/browser_list_observer.h" | |
14 #include "chrome/browser/ui/global_error/global_error.h" | |
15 #include "chrome/browser/ui/host_desktop.h" | |
16 | |
17 class Browser; | |
18 class Profile; | |
19 | |
20 namespace protector { | |
21 | |
22 class BaseSettingChange; | |
23 class SettingsChangeGlobalErrorDelegate; | |
24 | |
25 // Global error about unwanted settings changes. | |
26 class SettingsChangeGlobalError : public GlobalError, | |
27 public chrome::BrowserListObserver { | |
28 public: | |
29 // Creates new global error about setting changes |change| which must not be | |
30 // deleted until |delegate->OnRemovedFromProfile| is called. Uses |delegate| | |
31 // to notify about user decision. | |
32 SettingsChangeGlobalError(BaseSettingChange* change, | |
33 SettingsChangeGlobalErrorDelegate* delegate); | |
34 virtual ~SettingsChangeGlobalError(); | |
35 | |
36 // Adds a global error to the given browser profile and shows a bubble | |
37 // immediately on the desktop specified by |desktop_type| if |show_bubble| is | |
38 // |true|. | |
39 void AddToProfile(Profile* profile, | |
40 bool show_bubble, | |
41 chrome::HostDesktopType desktop_type); | |
42 | |
43 // Removes global error from its profile. | |
44 void RemoveFromProfile(); | |
45 | |
46 // Displays the bubble in the last active tabbed browser on the desktop | |
47 // specified by |desktop_type|. | |
48 void ShowBubble(chrome::HostDesktopType desktop_type); | |
49 | |
50 // Returns the change instance to which this error refers. | |
51 BaseSettingChange* change() { return change_; } | |
52 | |
53 private: | |
54 // GlobalError implementation. | |
55 virtual bool HasBadge() OVERRIDE; | |
56 virtual int GetBadgeResourceID() OVERRIDE; | |
57 virtual bool HasMenuItem() OVERRIDE; | |
58 virtual int MenuItemCommandID() OVERRIDE; | |
59 virtual string16 MenuItemLabel() OVERRIDE; | |
60 virtual int MenuItemIconResourceID() OVERRIDE; | |
61 virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; | |
62 virtual bool HasBubbleView() OVERRIDE; | |
63 virtual int GetBubbleViewIconResourceID() OVERRIDE; | |
64 virtual string16 GetBubbleViewTitle() OVERRIDE; | |
65 virtual string16 GetBubbleViewMessage() OVERRIDE; | |
66 virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE; | |
67 virtual string16 GetBubbleViewCancelButtonLabel() OVERRIDE; | |
68 virtual void OnBubbleViewDidClose(Browser* browser) OVERRIDE; | |
69 virtual void BubbleViewAcceptButtonPressed(Browser* browser) OVERRIDE; | |
70 virtual void BubbleViewCancelButtonPressed(Browser* browser) OVERRIDE; | |
71 | |
72 // chrome::BrowserListObserver implementation. | |
73 virtual void OnBrowserAdded(Browser* browser) OVERRIDE {} | |
74 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE {} | |
75 virtual void OnBrowserSetLastActive(Browser* browser) OVERRIDE; | |
76 | |
77 // Displays the bubble in |browser|'s window. | |
78 void ShowBubbleInBrowser(Browser* browser); | |
79 | |
80 // Called when the wrench menu item has been displayed for enough time | |
81 // without user interaction. | |
82 void OnInactiveTimeout(); | |
83 | |
84 // Change to show. | |
85 BaseSettingChange* change_; | |
86 | |
87 // Delegate to notify about user actions. | |
88 SettingsChangeGlobalErrorDelegate* delegate_; | |
89 | |
90 // Profile that we have been added to. | |
91 Profile* profile_; | |
92 | |
93 // True if user has dismissed the bubble by clicking on one of the buttons. | |
94 bool closed_by_button_; | |
95 | |
96 // True if the bubble has to be shown on the next browser window activation. | |
97 bool show_on_browser_activation_; | |
98 | |
99 base::WeakPtrFactory<SettingsChangeGlobalError> weak_factory_; | |
100 | |
101 // Menu command ID assigned to |this| from the pool of available IDs. | |
102 int menu_id_; | |
103 | |
104 DISALLOW_COPY_AND_ASSIGN(SettingsChangeGlobalError); | |
105 }; | |
106 | |
107 } // namespace protector | |
108 | |
109 #endif // CHROME_BROWSER_PROTECTOR_SETTINGS_CHANGE_GLOBAL_ERROR_H_ | |
OLD | NEW |