| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 namespace { | 51 namespace { |
| 52 | 52 |
| 53 #if defined(GOOGLE_CHROME_BUILD) | 53 #if defined(GOOGLE_CHROME_BUILD) |
| 54 const char kWallpaperManifestBaseURL[] = "https://commondatastorage.googleapis." | 54 const char kWallpaperManifestBaseURL[] = "https://commondatastorage.googleapis." |
| 55 "com/chromeos-wallpaper-public/manifest_"; | 55 "com/chromeos-wallpaper-public/manifest_"; |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 bool IsOEMDefaultWallpaper() { | 58 bool IsOEMDefaultWallpaper() { |
| 59 return CommandLine::ForCurrentProcess()->HasSwitch( | 59 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 60 ash::switches::kAshDefaultWallpaperIsOem) || | 60 ash::switches::kAshDefaultWallpaperIsOem); |
| 61 CommandLine::ForCurrentProcess()->HasSwitch( | |
| 62 ash::switches::kAshOemWallpaperSmall); | |
| 63 } | 61 } |
| 64 | 62 |
| 65 // Saves |data| as |file_name| to directory with |key|. Return false if the | 63 // Saves |data| as |file_name| to directory with |key|. Return false if the |
| 66 // directory can not be found/created or failed to write file. | 64 // directory can not be found/created or failed to write file. |
| 67 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) { |
| 68 base::FilePath data_dir; | 66 base::FilePath data_dir; |
| 69 CHECK(PathService::Get(key, &data_dir)); | 67 CHECK(PathService::Get(key, &data_dir)); |
| 70 if (!base::DirectoryExists(data_dir) && | 68 if (!base::DirectoryExists(data_dir) && |
| 71 !file_util::CreateDirectory(data_dir)) { | 69 !file_util::CreateDirectory(data_dir)) { |
| 72 return false; | 70 return false; |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 } else { | 613 } else { |
| 616 if (!IsOEMDefaultWallpaper()) { | 614 if (!IsOEMDefaultWallpaper()) { |
| 617 SetError("No OEM wallpaper."); | 615 SetError("No OEM wallpaper."); |
| 618 SendResponse(false); | 616 SendResponse(false); |
| 619 return false; | 617 return false; |
| 620 } | 618 } |
| 621 | 619 |
| 622 // TODO(bshe): Small resolution wallpaper is used here as wallpaper | 620 // TODO(bshe): Small resolution wallpaper is used here as wallpaper |
| 623 // thumbnail. We should either resize it or include a wallpaper thumbnail in | 621 // thumbnail. We should either resize it or include a wallpaper thumbnail in |
| 624 // addition to large and small wallpaper resolutions. | 622 // addition to large and small wallpaper resolutions. |
| 625 thumbnail_path = CommandLine::ForCurrentProcess()->HasSwitch( | 623 thumbnail_path = CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
| 626 ash::switches::kAshDefaultWallpaperIsOem) ? | 624 ash::switches::kAshDefaultWallpaperSmall); |
| 627 CommandLine::ForCurrentProcess()->GetSwitchValuePath( | |
| 628 ash::switches::kAshDefaultWallpaperSmall) : | |
| 629 CommandLine::ForCurrentProcess()->GetSwitchValuePath( | |
| 630 ash::switches::kAshOemWallpaperSmall); | |
| 631 } | 625 } |
| 632 | 626 |
| 633 sequence_token_ = BrowserThread::GetBlockingPool()-> | 627 sequence_token_ = BrowserThread::GetBlockingPool()-> |
| 634 GetNamedSequenceToken(chromeos::kWallpaperSequenceTokenName); | 628 GetNamedSequenceToken(chromeos::kWallpaperSequenceTokenName); |
| 635 scoped_refptr<base::SequencedTaskRunner> task_runner = | 629 scoped_refptr<base::SequencedTaskRunner> task_runner = |
| 636 BrowserThread::GetBlockingPool()-> | 630 BrowserThread::GetBlockingPool()-> |
| 637 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, | 631 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, |
| 638 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 632 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
| 639 | 633 |
| 640 task_runner->PostTask(FROM_HERE, | 634 task_runner->PostTask(FROM_HERE, |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 this, file_list)); | 775 this, file_list)); |
| 782 } | 776 } |
| 783 | 777 |
| 784 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( | 778 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( |
| 785 const std::vector<std::string>& file_list) { | 779 const std::vector<std::string>& file_list) { |
| 786 ListValue* results = new ListValue(); | 780 ListValue* results = new ListValue(); |
| 787 results->AppendStrings(file_list); | 781 results->AppendStrings(file_list); |
| 788 SetResult(results); | 782 SetResult(results); |
| 789 SendResponse(true); | 783 SendResponse(true); |
| 790 } | 784 } |
| OLD | NEW |