Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/ash_switches.h" | 9 #include "ash/ash_switches.h" |
| 10 #include "ash/desktop_background/desktop_background_controller.h" | 10 #include "ash/desktop_background/desktop_background_controller.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 bool SaveData(int key, const std::string& file_name, const std::string& data) { | 65 bool SaveData(int key, const std::string& file_name, const std::string& data) { |
| 66 base::FilePath data_dir; | 66 base::FilePath data_dir; |
| 67 CHECK(PathService::Get(key, &data_dir)); | 67 CHECK(PathService::Get(key, &data_dir)); |
| 68 if (!base::DirectoryExists(data_dir) && | 68 if (!base::DirectoryExists(data_dir) && |
| 69 !base::CreateDirectory(data_dir)) { | 69 !base::CreateDirectory(data_dir)) { |
| 70 return false; | 70 return false; |
| 71 } | 71 } |
| 72 base::FilePath file_path = data_dir.Append(file_name); | 72 base::FilePath file_path = data_dir.Append(file_name); |
| 73 | 73 |
| 74 return base::PathExists(file_path) || | 74 return base::PathExists(file_path) || |
| 75 (file_util::WriteFile(file_path, data.c_str(), | 75 (base::WriteFile(file_path, data.c_str(), |
| 76 data.size()) != -1); | 76 data.size()) != -1); |
|
viettrungluu
2014/02/28 21:47:24
nit: fix indentation
| |
| 77 } | 77 } |
| 78 | 78 |
| 79 // Gets |file_name| from directory with |key|. Return false if the directory can | 79 // Gets |file_name| from directory with |key|. Return false if the directory can |
| 80 // not be found or failed to read file to string |data|. Note if the |file_name| | 80 // not be found or failed to read file to string |data|. Note if the |file_name| |
| 81 // can not be found in the directory, return true with empty |data|. It is | 81 // can not be found in the directory, return true with empty |data|. It is |
| 82 // expected that we may try to access file which did not saved yet. | 82 // expected that we may try to access file which did not saved yet. |
| 83 bool GetData(const base::FilePath& path, std::string* data) { | 83 bool GetData(const base::FilePath& path, std::string* data) { |
| 84 base::FilePath data_dir = path.DirName(); | 84 base::FilePath data_dir = path.DirName(); |
| 85 if (!base::DirectoryExists(data_dir) && | 85 if (!base::DirectoryExists(data_dir) && |
| 86 !base::CreateDirectory(data_dir)) | 86 !base::CreateDirectory(data_dir)) |
| (...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 850 this, file_list)); | 850 this, file_list)); |
| 851 } | 851 } |
| 852 | 852 |
| 853 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( | 853 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( |
| 854 const std::vector<std::string>& file_list) { | 854 const std::vector<std::string>& file_list) { |
| 855 base::ListValue* results = new base::ListValue(); | 855 base::ListValue* results = new base::ListValue(); |
| 856 results->AppendStrings(file_list); | 856 results->AppendStrings(file_list); |
| 857 SetResult(results); | 857 SetResult(results); |
| 858 SendResponse(true); | 858 SendResponse(true); |
| 859 } | 859 } |
| OLD | NEW |