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

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

Issue 10375010: Implement user selected wallpaper feature. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 void Cancel() { 51 void Cancel() {
52 cancel_flag_.Set(); 52 cancel_flag_.Set();
53 } 53 }
54 54
55 const SkBitmap* wallpaper() { 55 const SkBitmap* wallpaper() {
56 return wallpaper_; 56 return wallpaper_;
57 } 57 }
58 58
59 ImageLayout image_layout() { 59 WallpaperLayout wallpaper_layout() {
60 return layout_; 60 return layout_;
61 } 61 }
62 62
63 int index() { 63 int index() {
64 return index_; 64 return index_;
65 } 65 }
66 66
67 private: 67 private:
68 friend class base::RefCountedThreadSafe< 68 friend class base::RefCountedThreadSafe<
69 DesktopBackgroundController::WallpaperOperation>; 69 DesktopBackgroundController::WallpaperOperation>;
70 70
71 base::CancellationFlag cancel_flag_; 71 base::CancellationFlag cancel_flag_;
72 72
73 const SkBitmap* wallpaper_; 73 const SkBitmap* wallpaper_;
74 ImageLayout layout_; 74 WallpaperLayout layout_;
75 int index_; 75 int index_;
76 76
77 DISALLOW_COPY_AND_ASSIGN(WallpaperOperation); 77 DISALLOW_COPY_AND_ASSIGN(WallpaperOperation);
78 }; 78 };
79 79
80 DesktopBackgroundController::DesktopBackgroundController() 80 DesktopBackgroundController::DesktopBackgroundController()
81 : desktop_background_mode_(BACKGROUND_IMAGE), 81 : desktop_background_mode_(BACKGROUND_IMAGE),
82 previous_index_(-1), 82 previous_index_(-1),
83 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 83 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
84 } 84 }
(...skipping 11 matching lines...) Expand all
96 wallpaper_op_ = new WallpaperOperation(index); 96 wallpaper_op_ = new WallpaperOperation(index);
97 base::WorkerPool::PostTaskAndReply( 97 base::WorkerPool::PostTaskAndReply(
98 FROM_HERE, 98 FROM_HERE,
99 base::Bind(&WallpaperOperation::Run, wallpaper_op_), 99 base::Bind(&WallpaperOperation::Run, wallpaper_op_),
100 base::Bind(&DesktopBackgroundController::OnWallpaperLoadCompleted, 100 base::Bind(&DesktopBackgroundController::OnWallpaperLoadCompleted,
101 weak_ptr_factory_.GetWeakPtr(), 101 weak_ptr_factory_.GetWeakPtr(),
102 wallpaper_op_), 102 wallpaper_op_),
103 true /* task_is_slow */); 103 true /* task_is_slow */);
104 } 104 }
105 105
106 void DesktopBackgroundController::SetCustomWallpaper(
107 const SkBitmap& wallpaper, WallpaperLayout layout) {
flackr 2012/05/04 19:06:17 I believe we want 1 argument per line in function
bshe 2012/05/08 22:22:18 Done.
108 internal::RootWindowLayoutManager* root_window_layout =
109 Shell::GetInstance()->root_window_layout();
110 root_window_layout->SetBackgroundLayer(NULL);
111 internal::CreateDesktopBackground(wallpaper, layout);
112 desktop_background_mode_ = BACKGROUND_IMAGE;
113 }
114
106 void DesktopBackgroundController::CancelPendingWallpaperOperation() { 115 void DesktopBackgroundController::CancelPendingWallpaperOperation() {
107 // Set canceled flag of previous request to skip unneeded loading. 116 // Set canceled flag of previous request to skip unneeded loading.
108 if (wallpaper_op_.get()) 117 if (wallpaper_op_.get())
109 wallpaper_op_->Cancel(); 118 wallpaper_op_->Cancel();
110 119
111 // Cancel reply callback for previous request. 120 // Cancel reply callback for previous request.
112 weak_ptr_factory_.InvalidateWeakPtrs(); 121 weak_ptr_factory_.InvalidateWeakPtrs();
113 } 122 }
114 123
115 void DesktopBackgroundController::SetLoggedInUserWallpaper() { 124 void DesktopBackgroundController::SetLoggedInUserWallpaper() {
(...skipping 22 matching lines...) Expand all
138 shell->root_window_layout()->SetBackgroundWidget(NULL); 147 shell->root_window_layout()->SetBackgroundWidget(NULL);
139 desktop_background_mode_ = BACKGROUND_SOLID_COLOR; 148 desktop_background_mode_ = BACKGROUND_SOLID_COLOR;
140 } 149 }
141 150
142 void DesktopBackgroundController::SetDesktopBackgroundImageMode( 151 void DesktopBackgroundController::SetDesktopBackgroundImageMode(
143 scoped_refptr<WallpaperOperation> wo) { 152 scoped_refptr<WallpaperOperation> wo) {
144 internal::RootWindowLayoutManager* root_window_layout = 153 internal::RootWindowLayoutManager* root_window_layout =
145 Shell::GetInstance()->root_window_layout(); 154 Shell::GetInstance()->root_window_layout();
146 root_window_layout->SetBackgroundLayer(NULL); 155 root_window_layout->SetBackgroundLayer(NULL);
147 if(wo->wallpaper()) { 156 if(wo->wallpaper()) {
148 internal::CreateDesktopBackground(*wo->wallpaper(), wo->image_layout()); 157 internal::CreateDesktopBackground(*wo->wallpaper(),
Ben Goodger (Google) 2012/05/07 15:35:08 seems unnecessary?
bshe 2012/05/09 18:51:54 Sorry, just to clarify, do you mean two parameters
Ben Goodger (Google) 2012/05/09 19:53:13 The linewrapping is unnecessary.
158 wo->wallpaper_layout());
149 desktop_background_mode_ = BACKGROUND_IMAGE; 159 desktop_background_mode_ = BACKGROUND_IMAGE;
150 } 160 }
151 } 161 }
152 162
153 void DesktopBackgroundController::OnWallpaperLoadCompleted( 163 void DesktopBackgroundController::OnWallpaperLoadCompleted(
154 scoped_refptr<WallpaperOperation> wo) { 164 scoped_refptr<WallpaperOperation> wo) {
155 SetDesktopBackgroundImageMode(wo); 165 SetDesktopBackgroundImageMode(wo);
156 previous_index_ = wo->index(); 166 previous_index_ = wo->index();
157 167
158 DCHECK(wo.get() == wallpaper_op_.get()); 168 DCHECK(wo.get() == wallpaper_op_.get());
159 wallpaper_op_ = NULL; 169 wallpaper_op_ = NULL;
160 } 170 }
161 171
162 } // namespace ash 172 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698