Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: ash/desktop_background/desktop_background_controller.cc

Issue 10459003: Load user custom wallpaper after browser crash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix aura_shell_unittests Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/desktop_background/desktop_background_controller.h ('k') | ash/shell.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/desktop_background/desktop_background_controller.h" 5 #include "ash/desktop_background/desktop_background_controller.h"
6 6
7 #include "ash/desktop_background/desktop_background_view.h" 7 #include "ash/desktop_background/desktop_background_view.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_factory.h" 9 #include "ash/shell_factory.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 previous_index_(-1), 92 previous_index_(-1),
93 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 93 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
94 DCHECK(root_window_); 94 DCHECK(root_window_);
95 } 95 }
96 96
97 DesktopBackgroundController::~DesktopBackgroundController() { 97 DesktopBackgroundController::~DesktopBackgroundController() {
98 CancelPendingWallpaperOperation(); 98 CancelPendingWallpaperOperation();
99 } 99 }
100 100
101 void DesktopBackgroundController::SetDefaultWallpaper(int index) { 101 void DesktopBackgroundController::SetDefaultWallpaper(int index) {
102 // We should not change background when index is invalid. For instance, at
103 // login screen or stub_user login.
104 if (index == ash::GetInvalidWallpaperIndex()) {
105 CreateEmptyWallpaper();
106 return;
107 }
108
102 if (previous_index_ == index) 109 if (previous_index_ == index)
103 return; 110 return;
104 111
105 CancelPendingWallpaperOperation(); 112 CancelPendingWallpaperOperation();
106 113
107 wallpaper_op_ = new WallpaperOperation(index); 114 wallpaper_op_ = new WallpaperOperation(index);
108 base::WorkerPool::PostTaskAndReply( 115 base::WorkerPool::PostTaskAndReply(
109 FROM_HERE, 116 FROM_HERE,
110 base::Bind(&WallpaperOperation::Run, wallpaper_op_), 117 base::Bind(&WallpaperOperation::Run, wallpaper_op_),
111 base::Bind(&DesktopBackgroundController::OnWallpaperLoadCompleted, 118 base::Bind(&DesktopBackgroundController::OnWallpaperLoadCompleted,
(...skipping 12 matching lines...) Expand all
124 131
125 void DesktopBackgroundController::CancelPendingWallpaperOperation() { 132 void DesktopBackgroundController::CancelPendingWallpaperOperation() {
126 // Set canceled flag of previous request to skip unneeded loading. 133 // Set canceled flag of previous request to skip unneeded loading.
127 if (wallpaper_op_.get()) 134 if (wallpaper_op_.get())
128 wallpaper_op_->Cancel(); 135 wallpaper_op_->Cancel();
129 136
130 // Cancel reply callback for previous request. 137 // Cancel reply callback for previous request.
131 weak_ptr_factory_.InvalidateWeakPtrs(); 138 weak_ptr_factory_.InvalidateWeakPtrs();
132 } 139 }
133 140
134 void DesktopBackgroundController::SetLoggedInUserWallpaper() {
135 int index = Shell::GetInstance()->user_wallpaper_delegate()->
136 GetUserWallpaperIndex();
137 // We should not change background when index is invalid. For instance, at
138 // login screen or stub_user login.
139 if (index == ash::GetInvalidWallpaperIndex()) {
140 CreateEmptyWallpaper();
141 return;
142 }
143
144 SetDefaultWallpaper(index);
145 }
146
147 void DesktopBackgroundController::SetDesktopBackgroundSolidColorMode() { 141 void DesktopBackgroundController::SetDesktopBackgroundSolidColorMode() {
148 // Set a solid black background. 142 // Set a solid black background.
149 // TODO(derat): Remove this in favor of having the compositor only clear the 143 // TODO(derat): Remove this in favor of having the compositor only clear the
150 // viewport when there are regions not covered by a layer: 144 // viewport when there are regions not covered by a layer:
151 // http://crbug.com/113445 145 // http://crbug.com/113445
152 ui::Layer* background_layer = new ui::Layer(ui::LAYER_SOLID_COLOR); 146 ui::Layer* background_layer = new ui::Layer(ui::LAYER_SOLID_COLOR);
153 background_layer->SetColor(SK_ColorBLACK); 147 background_layer->SetColor(SK_ColorBLACK);
154 root_window_->GetChildById( 148 root_window_->GetChildById(
155 internal::kShellWindowId_DesktopBackgroundContainer)-> 149 internal::kShellWindowId_DesktopBackgroundContainer)->
156 layer()->Add(background_layer); 150 layer()->Add(background_layer);
(...skipping 22 matching lines...) Expand all
179 wallpaper_op_ = NULL; 173 wallpaper_op_ = NULL;
180 } 174 }
181 175
182 void DesktopBackgroundController::CreateEmptyWallpaper() { 176 void DesktopBackgroundController::CreateEmptyWallpaper() {
183 gfx::ImageSkia dummy; 177 gfx::ImageSkia dummy;
184 internal::CreateDesktopBackground(dummy, CENTER, root_window_); 178 internal::CreateDesktopBackground(dummy, CENTER, root_window_);
185 desktop_background_mode_ = BACKGROUND_IMAGE; 179 desktop_background_mode_ = BACKGROUND_IMAGE;
186 } 180 }
187 181
188 } // namespace ash 182 } // namespace ash
OLDNEW
« no previous file with comments | « ash/desktop_background/desktop_background_controller.h ('k') | ash/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698