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_EXTENSIONS_USER_SCRIPT_MASTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/shared_memory.h" | 16 #include "base/shared_memory.h" |
17 #include "chrome/browser/extensions/extension_info_map.h" | 17 #include "chrome/browser/extensions/extension_info_map.h" |
18 #include "chrome/common/extensions/extension_messages.h" | 18 #include "chrome/common/extensions/extension_messages.h" |
19 #include "chrome/common/extensions/extension_set.h" | 19 #include "chrome/common/extensions/extension_set.h" |
20 #include "chrome/common/extensions/user_script.h" | 20 #include "chrome/common/extensions/user_script.h" |
21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
23 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
24 | 24 |
25 namespace base { | 25 namespace base { |
26 class StringPiece; | 26 class StringPiece; |
27 } | 27 } |
28 | 28 |
| 29 namespace content { |
| 30 class RenderProcessHost; |
| 31 } |
| 32 |
29 class Profile; | 33 class Profile; |
30 class RenderProcessHost; | |
31 | 34 |
32 typedef std::map<std::string, ExtensionSet::ExtensionPathAndDefaultLocale> | 35 typedef std::map<std::string, ExtensionSet::ExtensionPathAndDefaultLocale> |
33 ExtensionsInfo; | 36 ExtensionsInfo; |
34 | 37 |
35 // Manages a segment of shared memory that contains the user scripts the user | 38 // Manages a segment of shared memory that contains the user scripts the user |
36 // has installed. Lives on the UI thread. | 39 // has installed. Lives on the UI thread. |
37 class UserScriptMaster : public base::RefCountedThreadSafe<UserScriptMaster>, | 40 class UserScriptMaster : public base::RefCountedThreadSafe<UserScriptMaster>, |
38 public content::NotificationObserver { | 41 public content::NotificationObserver { |
39 public: | 42 public: |
40 explicit UserScriptMaster(Profile* profile); | 43 explicit UserScriptMaster(Profile* profile); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 DISALLOW_COPY_AND_ASSIGN(ScriptReloader); | 131 DISALLOW_COPY_AND_ASSIGN(ScriptReloader); |
129 }; | 132 }; |
130 | 133 |
131 private: | 134 private: |
132 // content::NotificationObserver implementation. | 135 // content::NotificationObserver implementation. |
133 virtual void Observe(int type, | 136 virtual void Observe(int type, |
134 const content::NotificationSource& source, | 137 const content::NotificationSource& source, |
135 const content::NotificationDetails& details) OVERRIDE; | 138 const content::NotificationDetails& details) OVERRIDE; |
136 | 139 |
137 // Sends the renderer process a new set of user scripts. | 140 // Sends the renderer process a new set of user scripts. |
138 void SendUpdate(RenderProcessHost* process, | 141 void SendUpdate(content::RenderProcessHost* process, |
139 base::SharedMemory* shared_memory); | 142 base::SharedMemory* shared_memory); |
140 | 143 |
141 // Manages our notification registrations. | 144 // Manages our notification registrations. |
142 content::NotificationRegistrar registrar_; | 145 content::NotificationRegistrar registrar_; |
143 | 146 |
144 // We hang on to our pointer to know if we've already got one running. | 147 // We hang on to our pointer to know if we've already got one running. |
145 scoped_refptr<ScriptReloader> script_reloader_; | 148 scoped_refptr<ScriptReloader> script_reloader_; |
146 | 149 |
147 // Contains the scripts that were found the last time scripts were updated. | 150 // Contains the scripts that were found the last time scripts were updated. |
148 scoped_ptr<base::SharedMemory> shared_memory_; | 151 scoped_ptr<base::SharedMemory> shared_memory_; |
(...skipping 13 matching lines...) Expand all Loading... |
162 // finishes. This boolean tracks whether another load is pending. | 165 // finishes. This boolean tracks whether another load is pending. |
163 bool pending_load_; | 166 bool pending_load_; |
164 | 167 |
165 // The profile for which the scripts managed here are installed. | 168 // The profile for which the scripts managed here are installed. |
166 Profile* profile_; | 169 Profile* profile_; |
167 | 170 |
168 DISALLOW_COPY_AND_ASSIGN(UserScriptMaster); | 171 DISALLOW_COPY_AND_ASSIGN(UserScriptMaster); |
169 }; | 172 }; |
170 | 173 |
171 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ | 174 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ |
OLD | NEW |