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 <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "ash/desktop_background/desktop_background_controller.h" | 12 #include "ash/desktop_background/desktop_background_controller.h" |
13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
14 #include "ash/wm/mru_window_tracker.h" | 14 #include "ash/wm/mru_window_tracker.h" |
15 #include "ash/wm/window_state.h" | 15 #include "ash/wm/window_state.h" |
16 #include "ash/wm/window_util.h" | 16 #include "ash/wm/window_util.h" |
17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
18 #include "base/files/file_enumerator.h" | 18 #include "base/files/file_enumerator.h" |
19 #include "base/files/file_util.h" | 19 #include "base/files/file_util.h" |
20 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
21 #include "base/path_service.h" | 21 #include "base/path_service.h" |
22 #include "base/prefs/pref_service.h" | 22 #include "base/prefs/pref_service.h" |
23 #include "base/stl_util.h" | |
24 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
25 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
26 #include "base/threading/worker_pool.h" | 25 #include "base/threading/worker_pool.h" |
27 #include "chrome/browser/browser_process.h" | 26 #include "chrome/browser/browser_process.h" |
28 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 27 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
29 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 28 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
30 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
31 #include "chrome/browser/sync/profile_sync_service_factory.h" | 30 #include "chrome/browser/sync/profile_sync_service_factory.h" |
32 #include "chrome/common/chrome_paths.h" | 31 #include "chrome/common/chrome_paths.h" |
33 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 const std::vector<char>& data) { | 78 const std::vector<char>& data) { |
80 base::FilePath data_dir; | 79 base::FilePath data_dir; |
81 CHECK(PathService::Get(key, &data_dir)); | 80 CHECK(PathService::Get(key, &data_dir)); |
82 if (!base::DirectoryExists(data_dir) && | 81 if (!base::DirectoryExists(data_dir) && |
83 !base::CreateDirectory(data_dir)) { | 82 !base::CreateDirectory(data_dir)) { |
84 return false; | 83 return false; |
85 } | 84 } |
86 base::FilePath file_path = data_dir.Append(file_name); | 85 base::FilePath file_path = data_dir.Append(file_name); |
87 | 86 |
88 return base::PathExists(file_path) || | 87 return base::PathExists(file_path) || |
89 base::WriteFile(file_path, vector_as_array(&data), data.size()) != -1; | 88 base::WriteFile(file_path, data.data(), data.size()) != -1; |
90 } | 89 } |
91 | 90 |
92 // Gets |file_name| from directory with |key|. Return false if the directory can | 91 // Gets |file_name| from directory with |key|. Return false if the directory can |
93 // 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| |
94 // 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 |
95 // 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. |
96 bool GetData(const base::FilePath& path, std::string* data) { | 95 bool GetData(const base::FilePath& path, std::string* data) { |
97 base::FilePath data_dir = path.DirName(); | 96 base::FilePath data_dir = path.DirName(); |
98 if (!base::DirectoryExists(data_dir) && | 97 if (!base::DirectoryExists(data_dir) && |
99 !base::CreateDirectory(data_dir)) | 98 !base::CreateDirectory(data_dir)) |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 this, file_list)); | 931 this, file_list)); |
933 } | 932 } |
934 | 933 |
935 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( | 934 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( |
936 const std::vector<std::string>& file_list) { | 935 const std::vector<std::string>& file_list) { |
937 base::ListValue* results = new base::ListValue(); | 936 base::ListValue* results = new base::ListValue(); |
938 results->AppendStrings(file_list); | 937 results->AppendStrings(file_list); |
939 SetResult(results); | 938 SetResult(results); |
940 SendResponse(true); | 939 SendResponse(true); |
941 } | 940 } |
OLD | NEW |