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

Side by Side Diff: chrome/browser/protector/settings_change_global_error.h

Issue 8342049: Added Protector, hooked up DSE verification with error bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Always persist default search provider in db Created 9 years, 2 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_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 <vector>
10
11 #include "base/basictypes.h" 9 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
14 #include "base/string16.h"
15 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/protector/setting_change.h"
16 #include "chrome/browser/ui/global_error.h" 13 #include "chrome/browser/ui/global_error.h"
17 14
15 class Browser;
18 class Profile; 16 class Profile;
19 17
18 namespace protector {
19
20 class SettingsChangeGlobalErrorDelegate;
21
20 // Global error about unwanted settings changes. 22 // Global error about unwanted settings changes.
21 class SettingsChangeGlobalError : public GlobalError { 23 class SettingsChangeGlobalError : public GlobalError {
22 public: 24 public:
23 enum ChangeType { 25 // Creates new global error about settings changes |changes|. Takes
24 kSearchEngineChanged = 0, // Default search engine has been changed. 26 // ownership over |changes| contents.
25 kHomePageChanged, // Home page has been changed. 27 // Uses |delegate| to notify about user decision.
26 }; 28 SettingsChangeGlobalError(
27 29 const SettingChangeVector& changes,
28 struct Change { 30 SettingsChangeGlobalErrorDelegate* delegate);
29 ChangeType type; // Which setting has been changed.
30 string16 old_setting; // Old setting value or "" if unknown.
31 string16 new_setting; // New setting value.
32 };
33
34 typedef std::vector<Change> ChangesVector;
35
36 // Creates new global error about settings changes |changes|.
37 // If user decides to apply changes, |apply_changes_cb| is called.
38 // If user decides to keep previous settings, |revert_changes_cb| is called.
39 SettingsChangeGlobalError(const ChangesVector& changes,
40 const base::Closure& apply_changes_cb,
41 const base::Closure& revert_changes_cb);
42 virtual ~SettingsChangeGlobalError(); 31 virtual ~SettingsChangeGlobalError();
43 32
44 // Displays a global error bubble for the default browser profile. 33 // Displays a global error bubble for the given browser profile.
45 // Can be called from any thread. 34 // Can be called from any thread.
46 void ShowForDefaultProfile(); 35 void ShowForProfile(Profile* profile);
36
37 // Browser that the bubble has been last time shown for.
38 Browser* browser() const { return browser_; }
39
40 SettingChangeVector* mutable_changes() { return &changes_; }
47 41
48 // GlobalError implementation. 42 // GlobalError implementation.
49 virtual bool HasBadge() OVERRIDE; 43 virtual bool HasBadge() OVERRIDE;
50 virtual bool HasMenuItem() OVERRIDE; 44 virtual bool HasMenuItem() OVERRIDE;
51 virtual int MenuItemCommandID() OVERRIDE; 45 virtual int MenuItemCommandID() OVERRIDE;
52 virtual string16 MenuItemLabel() OVERRIDE; 46 virtual string16 MenuItemLabel() OVERRIDE;
53 virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; 47 virtual void ExecuteMenuItem(Browser* browser) OVERRIDE;
54 virtual bool HasBubbleView() OVERRIDE; 48 virtual bool HasBubbleView() OVERRIDE;
55 virtual string16 GetBubbleViewTitle() OVERRIDE; 49 virtual string16 GetBubbleViewTitle() OVERRIDE;
56 virtual string16 GetBubbleViewMessage() OVERRIDE; 50 virtual string16 GetBubbleViewMessage() OVERRIDE;
57 virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE; 51 virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE;
58 virtual string16 GetBubbleViewCancelButtonLabel() OVERRIDE; 52 virtual string16 GetBubbleViewCancelButtonLabel() OVERRIDE;
59 virtual bool IsAcceptButtonDefault() OVERRIDE; 53 virtual bool IsAcceptButtonDefault() OVERRIDE;
60 virtual void BubbleViewDidClose() OVERRIDE; 54 virtual void BubbleViewDidClose() OVERRIDE;
61 virtual void BubbleViewAcceptButtonPressed() OVERRIDE; 55 virtual void BubbleViewAcceptButtonPressed() OVERRIDE;
62 virtual void BubbleViewCancelButtonPressed() OVERRIDE; 56 virtual void BubbleViewCancelButtonPressed() OVERRIDE;
63 57
64 private: 58 private:
65 ChangesVector changes_;
66
67 base::Closure apply_changes_cb_;
68 base::Closure revert_changes_cb_;
69
70 // Profile that we have been added to.
71 Profile* profile_;
72
73 // True if user has dismissed the bubble by clicking on one of the buttons.
74 bool closed_by_button_;
75
76 base::WeakPtrFactory<SettingsChangeGlobalError> weak_factory_;
77
78 // Helper called on the UI thread to add this global error to the default 59 // Helper called on the UI thread to add this global error to the default
79 // profile (stored in |profile_|). 60 // profile (stored in |profile_|).
80 void AddToDefaultProfile(); 61 void AddToProfile(Profile* profile);
81 62
82 // Displays global error bubble. Must be called on the UI thread. 63 // Displays global error bubble. Must be called on the UI thread.
83 void Show(); 64 void Show();
84 65
85 // Removes global error from its profile and deletes |this| later. 66 // Removes global error from its profile and deletes |this| later.
86 void RemoveFromProfile(); 67 void RemoveFromProfile();
87 68
69 // List of changes to show.
70 SettingChangeVector changes_;
71
72 // Delegate to notify about user actions.
73 SettingsChangeGlobalErrorDelegate* delegate_;
74
75 // Profile that we have been added to.
76 Profile* profile_;
77
78 // Browser that we have been shown for.
79 Browser* browser_;
80
81 // True if user has dismissed the bubble by clicking on one of the buttons.
82 bool closed_by_button_;
83
84 base::WeakPtrFactory<SettingsChangeGlobalError> weak_factory_;
85
88 DISALLOW_COPY_AND_ASSIGN(SettingsChangeGlobalError); 86 DISALLOW_COPY_AND_ASSIGN(SettingsChangeGlobalError);
89 }; 87 };
90 88
89 } // namespace protector
90
91 #endif // CHROME_BROWSER_PROTECTOR_SETTINGS_CHANGE_GLOBAL_ERROR_H_ 91 #endif // CHROME_BROWSER_PROTECTOR_SETTINGS_CHANGE_GLOBAL_ERROR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698