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

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

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
« no previous file with comments | « chrome/browser/upload_list.cc ('k') | chrome/common/auto_start_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 base::FilePath style_sheet_dir = style_sheet_file.DirName(); 115 base::FilePath style_sheet_dir = style_sheet_file.DirName();
116 if (!base::DirectoryExists(style_sheet_dir)) { 116 if (!base::DirectoryExists(style_sheet_dir)) {
117 if (!file_util::CreateDirectory(style_sheet_dir)) 117 if (!file_util::CreateDirectory(style_sheet_dir))
118 return; 118 return;
119 } 119 }
120 // Create the file if it doesn't exist. 120 // Create the file if it doesn't exist.
121 if (!base::PathExists(style_sheet_file)) 121 if (!base::PathExists(style_sheet_file))
122 file_util::WriteFile(style_sheet_file, "", 0); 122 file_util::WriteFile(style_sheet_file, "", 0);
123 123
124 std::string css; 124 std::string css;
125 bool rv = file_util::ReadFileToString(style_sheet_file, &css); 125 bool rv = base::ReadFileToString(style_sheet_file, &css);
126 GURL style_sheet_url; 126 GURL style_sheet_url;
127 if (rv && !css.empty()) { 127 if (rv && !css.empty()) {
128 std::string css_base64; 128 std::string css_base64;
129 rv = base::Base64Encode(css, &css_base64); 129 rv = base::Base64Encode(css, &css_base64);
130 if (rv) { 130 if (rv) {
131 // WebKit knows about data urls, so convert the file to a data url. 131 // WebKit knows about data urls, so convert the file to a data url.
132 const char kDataUrlPrefix[] = "data:text/css;charset=utf-8;base64,"; 132 const char kDataUrlPrefix[] = "data:text/css;charset=utf-8;base64,";
133 style_sheet_url = GURL(kDataUrlPrefix + css_base64); 133 style_sheet_url = GURL(kDataUrlPrefix + css_base64);
134 } 134 }
135 } 135 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 if (profile_->IsSameProfile(Profile::FromBrowserContext( 207 if (profile_->IsSameProfile(Profile::FromBrowserContext(
208 content::Source<WebContents>(source)->GetBrowserContext()))) { 208 content::Source<WebContents>(source)->GetBrowserContext()))) {
209 loader_->NotifyLoaded(); 209 loader_->NotifyLoaded();
210 registrar_.RemoveAll(); 210 registrar_.RemoveAll();
211 } 211 }
212 } 212 }
213 213
214 void UserStyleSheetWatcher::ShutdownOnUIThread() { 214 void UserStyleSheetWatcher::ShutdownOnUIThread() {
215 registrar_.RemoveAll(); 215 registrar_.RemoveAll();
216 } 216 }
OLDNEW
« no previous file with comments | « chrome/browser/upload_list.cc ('k') | chrome/common/auto_start_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698