Chromium Code Reviews| 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. |
|
whywhat
2011/11/21 14:51:21
You should document that object might be self-dest
Ivan Korotkov
2011/11/21 15:27:38
Done.
| |
| 57 void InitAndShowChange(BaseSettingChange* change); | 59 void InitAndShowChange(BaseSettingChange* change); |
| 58 | 60 |
| 59 // Pointer to error bubble controller. Indicates if we're showing change | 61 // Pointer to error bubble controller. Indicates if we're showing change |
| 60 // notification to user. Owns itself. | 62 // notification to user. |
| 61 scoped_ptr<SettingsChangeGlobalError> error_; | 63 scoped_ptr<SettingsChangeGlobalError> error_; |
| 62 | 64 |
| 65 // Setting change which we're showing. | |
| 66 scoped_ptr<BaseSettingChange> change_; | |
| 67 | |
| 63 // Profile which settings we are protecting. | 68 // Profile which settings we are protecting. |
| 64 Profile* profile_; | 69 Profile* profile_; |
| 65 | 70 |
| 66 DISALLOW_COPY_AND_ASSIGN(Protector); | 71 DISALLOW_COPY_AND_ASSIGN(Protector); |
| 67 }; | 72 }; |
| 68 | 73 |
| 69 // Signs string value with protector's key. | 74 // Signs string value with protector's key. |
| 70 std::string SignSetting(const std::string& value); | 75 std::string SignSetting(const std::string& value); |
| 71 | 76 |
| 72 // Returns true if the signature is valid for the specified key. | 77 // Returns true if the signature is valid for the specified key. |
| 73 bool IsSettingValid(const std::string& value, const std::string& signature); | 78 bool IsSettingValid(const std::string& value, const std::string& signature); |
| 74 | 79 |
| 75 } // namespace protector | 80 } // namespace protector |
| 76 | 81 |
| 77 #endif // CHROME_BROWSER_PROTECTOR_PROTECTOR_H_ | 82 #endif // CHROME_BROWSER_PROTECTOR_PROTECTOR_H_ |
| OLD | NEW |