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_PROTECTOR_H_ | 5 #ifndef CHROME_BROWSER_PROTECTOR_PROTECTOR_H_ |
6 #define CHROME_BROWSER_PROTECTOR_PROTECTOR_H_ | 6 #define CHROME_BROWSER_PROTECTOR_PROTECTOR_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" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // Presents a SettingChange to user and handles possible user actions. | 24 // Presents a SettingChange to user and handles possible user actions. |
25 // Deletes itself after a user action is taken or timeout expires. | 25 // Deletes itself after a user action is taken or timeout expires. |
26 class Protector : public SettingsChangeGlobalErrorDelegate { | 26 class Protector : public SettingsChangeGlobalErrorDelegate { |
27 public: | 27 public: |
28 explicit Protector(Profile* profile); | 28 explicit Protector(Profile* profile); |
29 | 29 |
30 // Opens a tab with specified URL in the browser window we've shown error | 30 // Opens a tab with specified URL in the browser window we've shown error |
31 // bubble for. | 31 // bubble for. |
32 void OpenTab(const GURL& url); | 32 void OpenTab(const GURL& url); |
33 | 33 |
34 // Returns TemplateURLService for the profile we've shown error bubble | 34 // Returns TemplateURLService for the profile we've shown error bubble for. |
35 // for. | |
36 TemplateURLService* GetTemplateURLService(); | 35 TemplateURLService* GetTemplateURLService(); |
37 | 36 |
38 // Shows global error about the specified change. Ownership of the change | 37 // Shows global error about the specified change. Owns |change|. |
39 // is passed to the GlobalError object. | |
40 void ShowChange(BaseSettingChange* change); | 38 void ShowChange(BaseSettingChange* change); |
41 | 39 |
| 40 // Silently discards any change previously shown (without calling Discard), |
| 41 // removes global error and deletes itself. |
| 42 void DismissChange(); |
| 43 |
42 // SettingsChangeGlobalErrorDelegate implementation. | 44 // SettingsChangeGlobalErrorDelegate implementation. |
43 virtual void OnApplyChange() OVERRIDE; | 45 virtual void OnApplyChange() OVERRIDE; |
44 virtual void OnDiscardChange() OVERRIDE; | 46 virtual void OnDiscardChange() OVERRIDE; |
45 virtual void OnDecisionTimeout() OVERRIDE; | 47 virtual void OnDecisionTimeout() OVERRIDE; |
46 virtual void OnRemovedFromProfile() OVERRIDE; | 48 virtual void OnRemovedFromProfile() OVERRIDE; |
47 | 49 |
48 private: | 50 private: |
49 friend class DeleteTask<Protector>; | 51 friend class DeleteTask<Protector>; |
50 | 52 |
51 // The object can only be allocated and destroyed on heap. | 53 // The object can only be allocated and destroyed on heap. |
52 virtual ~Protector(); | 54 virtual ~Protector(); |
53 | 55 |
54 // Performs the initial action on settings change and shows it. This is run | 56 // Performs the initial action on settings change and shows it. This is run |
55 // asynchronously on UI thread because |ShowChange| may be called in the | 57 // asynchronously on UI thread because |ShowChange| may be called in the |
56 // middle of some operations on settings that have changed. | 58 // middle of some operations on settings that have changed. If the initial |
| 59 // action fails, deletes itself. |
57 void InitAndShowChange(BaseSettingChange* change); | 60 void InitAndShowChange(BaseSettingChange* change); |
58 | 61 |
59 // Pointer to error bubble controller. Indicates if we're showing change | 62 // Pointer to error bubble controller. Indicates if we're showing change |
60 // notification to user. Owns itself. | 63 // notification to user. |
61 scoped_ptr<SettingsChangeGlobalError> error_; | 64 scoped_ptr<SettingsChangeGlobalError> error_; |
62 | 65 |
| 66 // Setting change which we're showing. |
| 67 scoped_ptr<BaseSettingChange> change_; |
| 68 |
63 // Profile which settings we are protecting. | 69 // Profile which settings we are protecting. |
64 Profile* profile_; | 70 Profile* profile_; |
65 | 71 |
66 DISALLOW_COPY_AND_ASSIGN(Protector); | 72 DISALLOW_COPY_AND_ASSIGN(Protector); |
67 }; | 73 }; |
68 | 74 |
69 // Signs string value with protector's key. | 75 // Signs string value with protector's key. |
70 std::string SignSetting(const std::string& value); | 76 std::string SignSetting(const std::string& value); |
71 | 77 |
72 // Returns true if the signature is valid for the specified key. | 78 // Returns true if the signature is valid for the specified key. |
73 bool IsSettingValid(const std::string& value, const std::string& signature); | 79 bool IsSettingValid(const std::string& value, const std::string& signature); |
74 | 80 |
75 } // namespace protector | 81 } // namespace protector |
76 | 82 |
77 #endif // CHROME_BROWSER_PROTECTOR_PROTECTOR_H_ | 83 #endif // CHROME_BROWSER_PROTECTOR_PROTECTOR_H_ |
OLD | NEW |