OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_function_base.h" | 5 #include "chrome/browser/chromeos/extensions/wallpaper_function_base.h" |
6 | 6 |
7 #include "base/synchronization/cancellation_flag.h" | 7 #include "base/synchronization/cancellation_flag.h" |
8 #include "chrome/browser/image_decoder.h" | 8 #include "chrome/browser/image_decoder.h" |
9 #include "chrome/grit/generated_resources.h" | 9 #include "chrome/grit/generated_resources.h" |
10 #include "chromeos/login/login_state.h" | 10 #include "chromeos/login/login_state.h" |
11 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
12 | 12 |
13 using content::BrowserThread; | 13 using content::BrowserThread; |
14 | 14 |
15 namespace wallpaper_api_util { | 15 namespace wallpaper_api_util { |
16 namespace { | 16 namespace { |
17 | 17 |
18 // Keeps in sync (same order) with WallpaperLayout enum in header file. | 18 // Keeps in sync (same order) with WallpaperLayout enum in header file. |
19 const char* kWallpaperLayoutArrays[] = { | 19 const char* const kWallpaperLayoutArrays[] = { |
20 "CENTER", | 20 "CENTER", |
21 "CENTER_CROPPED", | 21 "CENTER_CROPPED", |
22 "STRETCH", | 22 "STRETCH", |
23 "TILE" | 23 "TILE" |
24 }; | 24 }; |
25 | 25 |
26 const int kWallpaperLayoutCount = arraysize(kWallpaperLayoutArrays); | 26 const int kWallpaperLayoutCount = arraysize(kWallpaperLayoutArrays); |
27 | 27 |
28 } // namespace | 28 } // namespace |
29 | 29 |
30 const char kCancelWallpaperMessage[] = "Set wallpaper was canceled."; | 30 const char kCancelWallpaperMessage[] = "Set wallpaper was canceled."; |
31 | 31 |
32 ash::WallpaperLayout GetLayoutEnum(const std::string& layout) { | 32 ash::WallpaperLayout GetLayoutEnum(const std::string& layout) { |
33 for (int i = 0; i < kWallpaperLayoutCount; i++) { | 33 for (int i = 0; i < kWallpaperLayoutCount; i++) { |
34 if (layout.compare(kWallpaperLayoutArrays[i]) == 0) | 34 if (layout.compare(kWallpaperLayoutArrays[i]) == 0) |
35 return static_cast<ash::WallpaperLayout>(i); | 35 return static_cast<ash::WallpaperLayout>(i); |
36 } | 36 } |
37 // Default to use CENTER layout. | 37 // Default to use CENTER layout. |
38 return ash::WALLPAPER_LAYOUT_CENTER; | 38 return ash::WALLPAPER_LAYOUT_CENTER; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 unsafe_wallpaper_decoder_ = NULL; | 119 unsafe_wallpaper_decoder_ = NULL; |
120 SetError(wallpaper_api_util::kCancelWallpaperMessage); | 120 SetError(wallpaper_api_util::kCancelWallpaperMessage); |
121 SendResponse(false); | 121 SendResponse(false); |
122 } | 122 } |
123 | 123 |
124 void WallpaperFunctionBase::OnFailure(const std::string& error) { | 124 void WallpaperFunctionBase::OnFailure(const std::string& error) { |
125 unsafe_wallpaper_decoder_ = NULL; | 125 unsafe_wallpaper_decoder_ = NULL; |
126 SetError(error); | 126 SetError(error); |
127 SendResponse(false); | 127 SendResponse(false); |
128 } | 128 } |
OLD | NEW |