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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/user_style_sheet_watcher.h
diff --git a/chrome/browser/user_style_sheet_watcher.h b/chrome/browser/user_style_sheet_watcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..87fa5ce3fc1692d05179b8337e264e6ed3beec8e
--- /dev/null
+++ b/chrome/browser/user_style_sheet_watcher.h
@@ -0,0 +1,57 @@
+// Copyright (c) 2010 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_USER_STYLE_SHEET_WATCHER_H_
+#define CHROME_BROWSER_USER_STYLE_SHEET_WATCHER_H_
+
+#include "base/file_path.h"
+#include "base/logging.h"
+#include "base/ref_counted.h"
+#include "chrome/browser/chrome_thread.h"
+#include "chrome/common/notification_observer.h"
+#include "chrome/common/notification_registrar.h"
+#include "googleurl/src/gurl.h"
+
+// This loads the user style sheet on the file thread and sends a notification
+// when the style sheet is loaded.
+// TODO(tony): Watch for file changes and send a notification of the update.
+class UserStyleSheetWatcher
+ : public base::RefCountedThreadSafe<UserStyleSheetWatcher,
+ ChromeThread::DeleteOnUIThread>,
+ public NotificationObserver {
+ public:
+ explicit UserStyleSheetWatcher(const FilePath& profile_path);
+ virtual ~UserStyleSheetWatcher() {}
+
+ void Init();
+
+ GURL user_style_sheet() const {
+ return user_style_sheet_;
+ }
+
+ // NotificationObserver interface
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ private:
+ // Load the user style sheet on the file thread and convert it to a
+ // base64 URL. Posts the base64 URL back to the UI thread.
+ void LoadStyleSheet(const FilePath& profile_path);
+
+ void SetStyleSheet(const GURL& url);
+
+ // The directory containing the User StyleSheet.
+ FilePath profile_path_;
+
+ // The user style sheet as a base64 data:// URL.
+ GURL user_style_sheet_;
+
+ NotificationRegistrar registrar_;
+ bool has_loaded_;
+
+ DISALLOW_COPY_AND_ASSIGN(UserStyleSheetWatcher);
+};
+
+#endif // CHROME_BROWSER_USER_STYLE_SHEET_WATCHER_H_
« 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