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_USER_STYLE_SHEET_WATCHER_H_ | 5 #ifndef CHROME_BROWSER_USER_STYLE_SHEET_WATCHER_H_ |
6 #define CHROME_BROWSER_USER_STYLE_SHEET_WATCHER_H_ | 6 #define CHROME_BROWSER_USER_STYLE_SHEET_WATCHER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/files/file_path_watcher.h" | 10 #include "base/files/file_path_watcher.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
17 | 17 |
18 class Profile; | 18 class Profile; |
19 class UserStyleSheetLoader; | 19 class UserStyleSheetLoader; |
20 | 20 |
21 // Watches the user style sheet file and triggers reloads on the file thread | 21 // Watches the user style sheet file and triggers reloads on the file thread |
22 // whenever the file changes. | 22 // whenever the file changes. |
23 class UserStyleSheetWatcher | 23 class UserStyleSheetWatcher |
24 : public base::RefCountedThreadSafe<UserStyleSheetWatcher, | 24 : public base::RefCountedThreadSafe< |
25 BrowserThread::DeleteOnUIThread>, | 25 UserStyleSheetWatcher, |
| 26 content::BrowserThread::DeleteOnUIThread>, |
26 public content::NotificationObserver { | 27 public content::NotificationObserver { |
27 public: | 28 public: |
28 UserStyleSheetWatcher(Profile* profile, const FilePath& profile_path); | 29 UserStyleSheetWatcher(Profile* profile, const FilePath& profile_path); |
29 | 30 |
30 void Init(); | 31 void Init(); |
31 | 32 |
32 GURL user_style_sheet() const; | 33 GURL user_style_sheet() const; |
33 | 34 |
34 // content::NotificationObserver interface | 35 // content::NotificationObserver interface |
35 virtual void Observe(int type, | 36 virtual void Observe(int type, |
36 const content::NotificationSource& source, | 37 const content::NotificationSource& source, |
37 const content::NotificationDetails& details); | 38 const content::NotificationDetails& details); |
38 | 39 |
39 private: | 40 private: |
40 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; | 41 friend struct content::BrowserThread::DeleteOnThread< |
| 42 content::BrowserThread::UI>; |
41 friend class DeleteTask<UserStyleSheetWatcher>; | 43 friend class DeleteTask<UserStyleSheetWatcher>; |
42 | 44 |
43 virtual ~UserStyleSheetWatcher(); | 45 virtual ~UserStyleSheetWatcher(); |
44 | 46 |
45 // The profile owning us. | 47 // The profile owning us. |
46 Profile* profile_; | 48 Profile* profile_; |
47 | 49 |
48 // The directory containing User StyleSheets/Custom.css. | 50 // The directory containing User StyleSheets/Custom.css. |
49 FilePath profile_path_; | 51 FilePath profile_path_; |
50 | 52 |
51 // The loader object. | 53 // The loader object. |
52 scoped_refptr<UserStyleSheetLoader> loader_; | 54 scoped_refptr<UserStyleSheetLoader> loader_; |
53 | 55 |
54 // Watches for changes to the css file so we can reload the style sheet. | 56 // Watches for changes to the css file so we can reload the style sheet. |
55 scoped_ptr<base::files::FilePathWatcher> file_watcher_; | 57 scoped_ptr<base::files::FilePathWatcher> file_watcher_; |
56 | 58 |
57 content::NotificationRegistrar registrar_; | 59 content::NotificationRegistrar registrar_; |
58 | 60 |
59 DISALLOW_COPY_AND_ASSIGN(UserStyleSheetWatcher); | 61 DISALLOW_COPY_AND_ASSIGN(UserStyleSheetWatcher); |
60 }; | 62 }; |
61 | 63 |
62 #endif // CHROME_BROWSER_USER_STYLE_SHEET_WATCHER_H_ | 64 #endif // CHROME_BROWSER_USER_STYLE_SHEET_WATCHER_H_ |
OLD | NEW |