OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_OBSERVER_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_OBSERVER_H_ | |
7 #pragma once | |
8 | |
9 #include "base/values.h" | |
10 | |
11 class Profile; | |
12 | |
13 // Interface for classes that listen to changes to extension settings. | |
14 class ExtensionSettingsObserver { | |
15 public: | |
16 // A list of setting changes. Use this class when building the event value, | |
akalin
2011/10/12 22:26:30
i feel like this class should be in its own class
not at google - send to devlin
2011/10/13 06:40:43
Given comment below, still sensible to have this h
akalin
2011/10/13 20:45:57
I think so. Less coupling is better.
not at google - send to devlin
2011/10/13 23:08:14
Done.
| |
17 // then pass the result of |GetEventJson| into |OnSettingsChanged|. | |
18 class ChangeList { | |
19 public: | |
20 ChangeList(); | |
21 ~ChangeList(); | |
22 | |
23 // Appends a change for a setting. | |
24 void AppendChange( | |
25 const std::string& key, | |
26 // Ownership taken. May be NULL to imply there is no old value. | |
27 Value* old_value, | |
28 // Ownership taken. May be NULL to imply there is no new value. | |
29 Value* new_value); | |
30 | |
31 // Gets the JSON serialization of the event. | |
32 std::string GetEventJson() const; | |
33 | |
34 private: | |
35 ListValue changes_; | |
36 }; | |
37 | |
38 // Called when a list of settings have changed for an extension. | |
39 // | |
40 // |profile| is the profile of the event originator, or NULL if the event | |
41 // didn't originate from a background page. This is so that events can avoid | |
42 // being sent back to the background page which made the change. When the | |
43 // settings API is exposed to content scripts, this will need to be changed. | |
44 // | |
45 // |event_json| is the JSON serialization of the event to be passed directly | |
46 // to the onChanged listeners of the settings API. | |
47 virtual void OnSettingsChanged( | |
48 Profile* profile, | |
49 const std::string& extension_id, | |
50 const std::string& event_json) = 0; | |
akalin
2011/10/12 22:26:30
I'm not really a fan of flattening into a string b
not at google - send to devlin
2011/10/13 06:40:43
Done.
Though it's really very simple. linked_ptr
akalin
2011/10/13 20:45:15
shared_ptr isn't in Chromium and probably won't be
| |
51 | |
52 protected: | |
53 virtual ~ExtensionSettingsObserver(); | |
54 }; | |
55 | |
56 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_OBSERVER_H_ | |
OLD | NEW |