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

Side by Side Diff: chrome/browser/chromeos/extensions/wallpaper_api.cc

Issue 1004263002: Disable surprise me automatically if the current wallpaper was set by a third party application. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Biao's comments. Created 5 years, 9 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
OLDNEW
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_api.h" 5 #include "chrome/browser/chromeos/extensions/wallpaper_api.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/desktop_background/desktop_background_controller.h" 10 #include "ash/desktop_background/desktop_background_controller.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/threading/worker_pool.h" 15 #include "base/threading/worker_pool.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h"
17 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" 18 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/common/chrome_paths.h" 20 #include "chrome/common/chrome_paths.h"
20 #include "chrome/common/extensions/extension_constants.h" 21 #include "chrome/common/extensions/extension_constants.h"
21 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
22 #include "components/user_manager/user.h" 23 #include "components/user_manager/user.h"
23 #include "components/user_manager/user_manager.h" 24 #include "components/user_manager/user_manager.h"
24 #include "components/wallpaper/wallpaper_layout.h" 25 #include "components/wallpaper/wallpaper_layout.h"
26 #include "extensions/browser/event_router.h"
25 #include "net/base/load_flags.h" 27 #include "net/base/load_flags.h"
26 #include "net/http/http_status_code.h" 28 #include "net/http/http_status_code.h"
27 #include "net/url_request/url_fetcher.h" 29 #include "net/url_request/url_fetcher.h"
28 #include "net/url_request/url_fetcher_delegate.h" 30 #include "net/url_request/url_fetcher_delegate.h"
29 #include "url/gurl.h" 31 #include "url/gurl.h"
30 32
31 using base::BinaryValue; 33 using base::BinaryValue;
32 using content::BrowserThread; 34 using content::BrowserThread;
33 35
34 typedef base::Callback<void(bool success, const std::string&)> FetchCallback; 36 typedef base::Callback<void(bool success, const std::string&)> FetchCallback;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 Profile* profile = Profile::FromBrowserContext(browser_context()); 170 Profile* profile = Profile::FromBrowserContext(browser_context());
169 if (extension()->id() == extension_misc::kWallpaperManagerId) { 171 if (extension()->id() == extension_misc::kWallpaperManagerId) {
170 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, 172 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName,
171 std::string()); 173 std::string());
172 } else { 174 } else {
173 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, 175 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName,
174 extension()->name()); 176 extension()->name());
175 } 177 }
176 SendResponse(true); 178 SendResponse(true);
177 } 179 }
180
181 // Inform the native Wallpaper Picker Application that the current wallpaper
182 // has been modified by a third party application.
183 Profile* profile = Profile::FromBrowserContext(browser_context());
184 extensions::EventRouter* event_router = extensions::EventRouter::Get(profile);
185 scoped_ptr<base::ListValue> event_args(new base::ListValue());
186 scoped_ptr<extensions::Event> event(
187 new extensions::Event(extensions::api::wallpaper_private::
188 OnWallpaperChangedBy3rdParty::kEventName,
189 event_args.Pass()));
190 event_router->DispatchEventToExtension(extension_misc::kWallpaperManagerId,
191 event.Pass());
178 } 192 }
179 193
180 void WallpaperSetWallpaperFunction::GenerateThumbnail( 194 void WallpaperSetWallpaperFunction::GenerateThumbnail(
181 const base::FilePath& thumbnail_path, scoped_ptr<gfx::ImageSkia> image) { 195 const base::FilePath& thumbnail_path, scoped_ptr<gfx::ImageSkia> image) {
182 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( 196 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread(
183 sequence_token_)); 197 sequence_token_));
184 if (!base::PathExists(thumbnail_path.DirName())) 198 if (!base::PathExists(thumbnail_path.DirName()))
185 base::CreateDirectory(thumbnail_path.DirName()); 199 base::CreateDirectory(thumbnail_path.DirName());
186 200
187 scoped_refptr<base::RefCountedBytes> data; 201 scoped_refptr<base::RefCountedBytes> data;
(...skipping 21 matching lines...) Expand all
209 const std::string& response) { 223 const std::string& response) {
210 if (success) { 224 if (success) {
211 params_->details.data.reset( 225 params_->details.data.reset(
212 new std::vector<char>(response.begin(), response.end())); 226 new std::vector<char>(response.begin(), response.end()));
213 StartDecode(*params_->details.data); 227 StartDecode(*params_->details.data);
214 } else { 228 } else {
215 SetError(response); 229 SetError(response);
216 SendResponse(false); 230 SendResponse(false);
217 } 231 }
218 } 232 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698