Index: chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js |
diff --git a/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js b/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js |
index 22ef6cf57eef24ae5f76e37cd0d7a736552f0510..274fc76588e0d0ef1f7f8288a9fd6c9748e52ec1 100644 |
--- a/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js |
+++ b/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js |
@@ -621,11 +621,20 @@ function WallpaperManager(dialogDom) { |
*/ |
WallpaperManager.prototype.onThumbnailSelectionChanged_ = function() { |
flackr
2013/04/16 01:28:41
This method and description seem to be inaccuratel
bshe
2013/04/16 16:19:26
Done.
|
var selectedItem = this.wallpaperGrid_.selectedItem; |
- if (selectedItem && selectedItem.source == 'ADDNEW') |
+ this.setWallpaperAttribution_(selectedItem); |
+ |
+ // splice may dispatch a change event because the position of selected |
+ // element changing. But the actual selected element didn't change after |
+ // splice. Check if the new selected element equals to the previous selected |
+ // element before continuing. Otherwise, wallpaper may reset to previous one |
+ // as described in http://crbug.com/229036. |
+ if (!selectedItem || selectedItem.source == 'ADDNEW' || |
+ selectedItem == this.wallpaperGrid_.previousSelectedItem) { |
return; |
+ } |
- if (selectedItem && selectedItem.baseURL && |
- !this.wallpaperGrid_.inProgramSelection) { |
+ this.wallpaperGrid_.previousSelectedItem = selectedItem; |
flackr
2013/04/16 01:28:41
previousSelectedItem doesn't belong in wallpaperGr
bshe
2013/04/16 16:19:26
I can't use currentWallpaper or activeItem to repl
|
+ if (selectedItem.baseURL && !this.wallpaperGrid_.inProgramSelection) { |
if (selectedItem.source == wallpapers.WallpaperSourceEnum.Custom) { |
var items = {}; |
var key = selectedItem.baseURL; |
@@ -638,7 +647,6 @@ function WallpaperManager(dialogDom) { |
this.setSelectedWallpaper_(selectedItem); |
} |
} |
- this.setWallpaperAttribution_(selectedItem); |
}; |
/** |
@@ -769,7 +777,6 @@ function WallpaperManager(dialogDom) { |
self.currentWallpaper_ = fileName; |
var items = {}; |
items[self.currentWallpaper_] = layout; |
- self.storage_.set(items, function() {}); |
self.wallpaperGrid_.dataModel.splice(0, 0, wallpaperInfo); |
self.wallpaperGrid_.selectedItem = wallpaperInfo; |
self.wallpaperGrid_.activeItem = wallpaperInfo; |