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

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: 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> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/string16.h" 14 #include "base/string16.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "chrome/browser/protector/protector.h"
16 #include "chrome/browser/ui/global_error.h" 17 #include "chrome/browser/ui/global_error.h"
17 18
19 class Browser;
18 class Profile; 20 class Profile;
19 21
22 namespace protector {
23
20 // Global error about unwanted settings changes. 24 // Global error about unwanted settings changes.
21 class SettingsChangeGlobalError : public GlobalError { 25 class SettingsChangeGlobalError : public GlobalError {
22 public: 26 public:
23 enum ChangeType {
24 kSearchEngineChanged = 0, // Default search engine has been changed.
25 kHomePageChanged, // Home page has been changed.
26 };
27
28 struct Change {
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|. 27 // Creates new global error about settings changes |changes|.
37 // If user decides to apply changes, |make_changes_cb| is called. 28 // If user decides to apply changes, |make_changes_cb| is called.
38 // If user decides to keep previous settings, |restore_changes_cb| is called. 29 // If user decides to keep previous settings, |restore_changes_cb| is called.
39 SettingsChangeGlobalError(const ChangesVector& changes, 30 SettingsChangeGlobalError(const Protector::ChangesVector& changes,
40 const base::Closure& make_changes_cb, 31 const base::Closure& make_changes_cb,
41 const base::Closure& restore_changes_cb); 32 const base::Closure& restore_changes_cb);
42 virtual ~SettingsChangeGlobalError(); 33 virtual ~SettingsChangeGlobalError();
43 34
44 // Displays a global error bubble for the default browser profile. 35 // Displays a global error bubble for the default browser profile.
45 // Can be called from any thread. 36 // Can be called from any thread.
46 void ShowForDefaultProfile(); 37 void ShowForDefaultProfile();
47 38
39 Profile* profile() const { return profile_; }
40 Browser* browser() const { return browser_; }
Ivan Korotkov 2011/10/19 20:24:37 Document these please.
whywhat 2011/10/20 20:50:10 Done.
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 void BubbleViewDidClose() OVERRIDE; 53 virtual void BubbleViewDidClose() OVERRIDE;
60 virtual void BubbleViewAcceptButtonPressed() OVERRIDE; 54 virtual void BubbleViewAcceptButtonPressed() OVERRIDE;
61 virtual void BubbleViewCancelButtonPressed() OVERRIDE; 55 virtual void BubbleViewCancelButtonPressed() OVERRIDE;
62 56
63 private: 57 private:
64 ChangesVector changes_; 58 Protector::ChangesVector changes_;
65 59
66 base::Closure make_changes_cb_; 60 base::Closure make_changes_cb_;
67 base::Closure restore_changes_cb_; 61 base::Closure restore_changes_cb_;
68 62
69 // Profile that we have been added to. 63 // Profile that we have been added to.
70 Profile* profile_; 64 Profile* profile_;
71 65
66 // Browser that we have been shown for.
67 Browser* browser_;
68
72 // True if user has dismissed the bubble by clicking on one of the buttons. 69 // True if user has dismissed the bubble by clicking on one of the buttons.
73 bool closed_by_button_; 70 bool closed_by_button_;
74 71
75 base::WeakPtrFactory<SettingsChangeGlobalError> weak_factory_; 72 base::WeakPtrFactory<SettingsChangeGlobalError> weak_factory_;
76 73
77 // Helper called on the UI thread to add this global error to the default 74 // Helper called on the UI thread to add this global error to the default
78 // profile (stored in |profile_|). 75 // profile (stored in |profile_|).
79 void AddToDefaultProfile(); 76 void AddToDefaultProfile();
80 77
81 // Displays global error bubble. Must be called on the UI thread. 78 // Displays global error bubble. Must be called on the UI thread.
82 void Show(); 79 void Show();
83 80
84 // Removes global error from its profile and deletes |this| later. 81 // Removes global error from its profile and deletes |this| later.
85 void RemoveFromProfile(); 82 void RemoveFromProfile();
86 83
87 DISALLOW_COPY_AND_ASSIGN(SettingsChangeGlobalError); 84 DISALLOW_COPY_AND_ASSIGN(SettingsChangeGlobalError);
88 }; 85 };
89 86
87 } // namespace protector
88
90 #endif // CHROME_BROWSER_PROTECTOR_SETTINGS_CHANGE_GLOBAL_ERROR_H_ 89 #endif // CHROME_BROWSER_PROTECTOR_SETTINGS_CHANGE_GLOBAL_ERROR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698