blob: 7d5616680bda5eed79d70cdb584c96ef234bc7f7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_H_
#define CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_H_
#pragma once
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop_helpers.h"
#include "chrome/browser/profiles/profile_keyed_service.h"
#include "chrome/browser/protector/base_setting_change.h"
#include "chrome/browser/protector/settings_change_global_error_delegate.h"
class GURL;
class PrefService;
class Profile;
class TemplateURLService;
namespace protector {
class SettingsChangeGlobalError;
// Presents a SettingChange to user and handles possible user actions.
class ProtectorService : public ProfileKeyedService,
public SettingsChangeGlobalErrorDelegate {
public:
explicit ProtectorService(Profile* profile);
virtual ~ProtectorService();
// Shows global error about the specified change. Owns |change|.
// TODO(ivankr): handle multiple subsequent changes.
virtual void ShowChange(BaseSettingChange* change);
// Returns |true| if a change is currently active (shown by a ShowChange call
// and not yet applied or discarded).
virtual bool IsShowingChange() const;
// Removes global error (including the bubbble if one is shown) and deletes
// the change instance (without calling Apply or Discard on it).
virtual void DismissChange();
// Persists the change that is currently active and removes global error.
virtual void ApplyChange();
// Discards the change that is currently active and removes global error.
virtual void DiscardChange();
// Opens a tab with specified URL in the browser window we've shown error
// bubble for.
virtual void OpenTab(const GURL& url);
// Returns the Profile instance we've shown error bubble for.
Profile* profile() { return profile_; }
private:
friend class ProtectorServiceTest;
// ProfileKeyedService implementation.
virtual void Shutdown() OVERRIDE;
// SettingsChangeGlobalErrorDelegate implementation.
virtual void OnApplyChange() OVERRIDE;
virtual void OnDiscardChange() OVERRIDE;
virtual void OnDecisionTimeout() OVERRIDE;
virtual void OnRemovedFromProfile() OVERRIDE;
// Pointer to error bubble controller. Indicates if we're showing change
// notification to user.
scoped_ptr<SettingsChangeGlobalError> error_;
// Setting change which we're showing.
scoped_ptr<BaseSettingChange> change_;
// Profile which settings we are protecting.
Profile* profile_;
DISALLOW_COPY_AND_ASSIGN(ProtectorService);
};
// Signs string value with protector's key.
std::string SignSetting(const std::string& value);
// Returns true if the signature is valid for the specified key.
bool IsSettingValid(const std::string& value, const std::string& signature);
// Register related preferences in Local State.
void RegisterPrefs(PrefService* prefs);
// Whether the Protector feature is enabled.
bool IsEnabled();
} // namespace protector
#endif // CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_H_
|