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

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

Issue 19052005: Move PathIsWritable, DirectoryExists, ContentsEqual, and TextContentsEqual to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/user_style_sheet_watcher.h" 5 #include "chrome/browser/user_style_sheet_watcher.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 if (!error) 97 if (!error)
98 LoadStyleSheet(path); 98 LoadStyleSheet(path);
99 } 99 }
100 100
101 void UserStyleSheetLoader::LoadStyleSheet( 101 void UserStyleSheetLoader::LoadStyleSheet(
102 const base::FilePath& style_sheet_file) { 102 const base::FilePath& style_sheet_file) {
103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
104 // We keep the user style sheet in a subdir so we can watch for changes 104 // We keep the user style sheet in a subdir so we can watch for changes
105 // to the file. 105 // to the file.
106 base::FilePath style_sheet_dir = style_sheet_file.DirName(); 106 base::FilePath style_sheet_dir = style_sheet_file.DirName();
107 if (!file_util::DirectoryExists(style_sheet_dir)) { 107 if (!base::DirectoryExists(style_sheet_dir)) {
108 if (!file_util::CreateDirectory(style_sheet_dir)) 108 if (!file_util::CreateDirectory(style_sheet_dir))
109 return; 109 return;
110 } 110 }
111 // Create the file if it doesn't exist. 111 // Create the file if it doesn't exist.
112 if (!base::PathExists(style_sheet_file)) 112 if (!base::PathExists(style_sheet_file))
113 file_util::WriteFile(style_sheet_file, "", 0); 113 file_util::WriteFile(style_sheet_file, "", 0);
114 114
115 std::string css; 115 std::string css;
116 bool rv = file_util::ReadFileToString(style_sheet_file, &css); 116 bool rv = file_util::ReadFileToString(style_sheet_file, &css);
117 GURL style_sheet_url; 117 GURL style_sheet_url;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 if (profile_->IsSameProfile(Profile::FromBrowserContext( 189 if (profile_->IsSameProfile(Profile::FromBrowserContext(
190 content::Source<WebContents>(source)->GetBrowserContext()))) { 190 content::Source<WebContents>(source)->GetBrowserContext()))) {
191 loader_->NotifyLoaded(); 191 loader_->NotifyLoaded();
192 registrar_.RemoveAll(); 192 registrar_.RemoveAll();
193 } 193 }
194 } 194 }
195 195
196 void UserStyleSheetWatcher::ShutdownOnUIThread() { 196 void UserStyleSheetWatcher::ShutdownOnUIThread() {
197 registrar_.RemoveAll(); 197 registrar_.RemoveAll();
198 } 198 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/metro_pin_tab_helper_win.cc ('k') | chrome/browser/web_applications/web_app_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698