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

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

Issue 8558020: Protector strings and bubble/SettingsChange code refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: This time it really should compile. Created 9 years, 1 month 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_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"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/task.h" 12 #include "base/task.h"
13 #include "chrome/browser/protector/setting_change.h" 13 #include "chrome/browser/protector/base_setting_change.h"
14 #include "chrome/browser/protector/settings_change_global_error_delegate.h" 14 #include "chrome/browser/protector/settings_change_global_error_delegate.h"
15 15
16 class GURL; 16 class GURL;
17 class Profile; 17 class Profile;
18 class TemplateURLService; 18 class TemplateURLService;
19 19
20 namespace protector { 20 namespace protector {
21 21
22 class SettingsChangeGlobalError; 22 class SettingsChangeGlobalError;
23 23
24 // Accumulates settings changes and shows them altogether to user. 24 // Presents a SettingChange to user and handles possible user actions.
25 // Deletes itself when changes are shown to the user and some action is taken 25 // Deletes itself after a user action is taken or timeout expires.
26 // or timeout expires.
27 class Protector : public SettingsChangeGlobalErrorDelegate { 26 class Protector : public SettingsChangeGlobalErrorDelegate {
28 public: 27 public:
29 explicit Protector(Profile* profile); 28 explicit Protector(Profile* profile);
30 29
31 // 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
32 // bubble for. 31 // bubble for.
33 void OpenTab(const GURL& url); 32 void OpenTab(const GURL& url);
34 33
35 // Returns TemplateURLService for the profile we've shown error bubble 34 // Returns TemplateURLService for the profile we've shown error bubble
36 // for. 35 // for.
37 TemplateURLService* GetTemplateURLService(); 36 TemplateURLService* GetTemplateURLService();
38 37
39 // Shows global error about the specified change. Ownership of the change 38 // Shows global error about the specified change. Ownership of the change
40 // is passed to the error object. 39 // is passed to the GlobalError object.
41 void ShowChange(SettingChange* change); 40 void ShowChange(BaseSettingChange* change);
42 41
43 // SettingsChangeGlobalErrorDelegate implementation. 42 // SettingsChangeGlobalErrorDelegate implementation.
44 virtual void OnApplyChanges() OVERRIDE; 43 virtual void OnApplyChange() OVERRIDE;
45 virtual void OnDiscardChanges() OVERRIDE; 44 virtual void OnDiscardChange() OVERRIDE;
46 virtual void OnDecisionTimeout() OVERRIDE; 45 virtual void OnDecisionTimeout() OVERRIDE;
47 virtual void OnRemovedFromProfile() OVERRIDE; 46 virtual void OnRemovedFromProfile() OVERRIDE;
48 47
49 private: 48 private:
50 friend class DeleteTask<Protector>; 49 friend class DeleteTask<Protector>;
51 50
52 // The object can only be allocated and destroyed on heap. 51 // The object can only be allocated and destroyed on heap.
53 virtual ~Protector(); 52 virtual ~Protector();
54 53
55 // Common handler for error delegate handlers. Calls the specified method 54 // Performs the initial action on settings change and shows it. This is run
56 // on each change we showed error for. 55 // asynchronously on UI thread because |ShowChange| may be called in the
57 void OnChangesAction(SettingChangeAction action); 56 // middle of some operations on settings that have changed.
57 void InitAndShowChange(BaseSettingChange* change);
58 58
59 // Pointer to error bubble controller. Indicates if we're showing change 59 // Pointer to error bubble controller. Indicates if we're showing change
60 // notification to user. Owns itself. 60 // notification to user. Owns itself.
61 scoped_ptr<SettingsChangeGlobalError> error_; 61 scoped_ptr<SettingsChangeGlobalError> error_;
62 62
63 // Profile which settings we are protecting. 63 // Profile which settings we are protecting.
64 Profile* profile_; 64 Profile* profile_;
65 65
66 DISALLOW_COPY_AND_ASSIGN(Protector); 66 DISALLOW_COPY_AND_ASSIGN(Protector);
67 }; 67 };
68 68
69 // Signs string value with protector's key. 69 // Signs string value with protector's key.
70 std::string SignSetting(const std::string& value); 70 std::string SignSetting(const std::string& value);
71 71
72 // Returns true if the signature is valid for the specified key. 72 // Returns true if the signature is valid for the specified key.
73 bool IsSettingValid(const std::string& value, const std::string& signature); 73 bool IsSettingValid(const std::string& value, const std::string& signature);
74 74
75 } // namespace protector 75 } // namespace protector
76 76
77 #endif // CHROME_BROWSER_PROTECTOR_PROTECTOR_H_ 77 #endif // CHROME_BROWSER_PROTECTOR_PROTECTOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/protector/default_search_provider_change.cc ('k') | chrome/browser/protector/protector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698