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

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

Issue 660349: First cut at custom user style sheets. (Closed)
Patch Set: compile Created 10 years, 9 months 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
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.cc ('k') | chrome/browser/user_style_sheet_watcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 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_USER_STYLE_SHEET_WATCHER_H_
6 #define CHROME_BROWSER_USER_STYLE_SHEET_WATCHER_H_
7
8 #include "base/file_path.h"
9 #include "base/logging.h"
10 #include "base/ref_counted.h"
11 #include "chrome/browser/chrome_thread.h"
12 #include "chrome/common/notification_observer.h"
13 #include "chrome/common/notification_registrar.h"
14 #include "googleurl/src/gurl.h"
15
16 // This loads the user style sheet on the file thread and sends a notification
17 // when the style sheet is loaded.
18 // TODO(tony): Watch for file changes and send a notification of the update.
19 class UserStyleSheetWatcher
20 : public base::RefCountedThreadSafe<UserStyleSheetWatcher,
21 ChromeThread::DeleteOnUIThread>,
22 public NotificationObserver {
23 public:
24 explicit UserStyleSheetWatcher(const FilePath& profile_path);
25 virtual ~UserStyleSheetWatcher() {}
26
27 void Init();
28
29 GURL user_style_sheet() const {
30 return user_style_sheet_;
31 }
32
33 // NotificationObserver interface
34 virtual void Observe(NotificationType type,
35 const NotificationSource& source,
36 const NotificationDetails& details);
37
38 private:
39 // Load the user style sheet on the file thread and convert it to a
40 // base64 URL. Posts the base64 URL back to the UI thread.
41 void LoadStyleSheet(const FilePath& profile_path);
42
43 void SetStyleSheet(const GURL& url);
44
45 // The directory containing the User StyleSheet.
46 FilePath profile_path_;
47
48 // The user style sheet as a base64 data:// URL.
49 GURL user_style_sheet_;
50
51 NotificationRegistrar registrar_;
52 bool has_loaded_;
53
54 DISALLOW_COPY_AND_ASSIGN(UserStyleSheetWatcher);
55 };
56
57 #endif // CHROME_BROWSER_USER_STYLE_SHEET_WATCHER_H_
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.cc ('k') | chrome/browser/user_style_sheet_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698