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

Side by Side Diff: chrome/browser/chromeos/extensions/wallpaper_private_api.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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/chromeos/extensions/wallpaper_private_api.h" 5 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/wm/mru_window_tracker.h" 10 #include "ash/wm/mru_window_tracker.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // not be found or failed to read file to string |data|. Note if the |file_name| 92 // not be found or failed to read file to string |data|. Note if the |file_name|
93 // can not be found in the directory, return true with empty |data|. It is 93 // can not be found in the directory, return true with empty |data|. It is
94 // expected that we may try to access file which did not saved yet. 94 // expected that we may try to access file which did not saved yet.
95 bool GetData(const base::FilePath& path, std::string* data) { 95 bool GetData(const base::FilePath& path, std::string* data) {
96 base::FilePath data_dir = path.DirName(); 96 base::FilePath data_dir = path.DirName();
97 if (!base::DirectoryExists(data_dir) && 97 if (!base::DirectoryExists(data_dir) &&
98 !file_util::CreateDirectory(data_dir)) 98 !file_util::CreateDirectory(data_dir))
99 return false; 99 return false;
100 100
101 return !base::PathExists(path) || 101 return !base::PathExists(path) ||
102 file_util::ReadFileToString(path, data); 102 base::ReadFileToString(path, data);
103 } 103 }
104 104
105 class WindowStateManager; 105 class WindowStateManager;
106 106
107 // static 107 // static
108 WindowStateManager* g_window_state_manager = NULL; 108 WindowStateManager* g_window_state_manager = NULL;
109 109
110 // WindowStateManager remembers which windows have been minimized in order to 110 // WindowStateManager remembers which windows have been minimized in order to
111 // restore them when the wallpaper viewer is hidden. 111 // restore them when the wallpaper viewer is hidden.
112 class WindowStateManager : public aura::WindowObserver { 112 class WindowStateManager : public aura::WindowObserver {
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 const base::FilePath& fallback_path) { 379 const base::FilePath& fallback_path) {
380 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( 380 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread(
381 sequence_token_)); 381 sequence_token_));
382 std::string data; 382 std::string data;
383 base::FilePath path = file_path; 383 base::FilePath path = file_path;
384 384
385 if (!base::PathExists(file_path)) 385 if (!base::PathExists(file_path))
386 path = fallback_path; 386 path = fallback_path;
387 387
388 if (base::PathExists(path) && 388 if (base::PathExists(path) &&
389 file_util::ReadFileToString(path, &data)) { 389 base::ReadFileToString(path, &data)) {
390 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 390 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
391 base::Bind(&WallpaperPrivateSetWallpaperIfExistsFunction::StartDecode, 391 base::Bind(&WallpaperPrivateSetWallpaperIfExistsFunction::StartDecode,
392 this, data)); 392 this, data));
393 return; 393 return;
394 } 394 }
395 std::string error = base::StringPrintf( 395 std::string error = base::StringPrintf(
396 "Failed to set wallpaper %s from file system.", 396 "Failed to set wallpaper %s from file system.",
397 path.BaseName().value().c_str()); 397 path.BaseName().value().c_str());
398 BrowserThread::PostTask( 398 BrowserThread::PostTask(
399 BrowserThread::UI, FROM_HERE, 399 BrowserThread::UI, FROM_HERE,
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 this, file_list)); 911 this, file_list));
912 } 912 }
913 913
914 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( 914 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete(
915 const std::vector<std::string>& file_list) { 915 const std::vector<std::string>& file_list) {
916 ListValue* results = new ListValue(); 916 ListValue* results = new ListValue();
917 results->AppendStrings(file_list); 917 results->AppendStrings(file_list);
918 SetResult(results); 918 SetResult(results);
919 SendResponse(true); 919 SendResponse(true);
920 } 920 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698