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

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 kalman@'s comment. 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
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/wallpaper_manager/js/event_page.js » ('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 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 Profile* profile = Profile::FromBrowserContext(browser_context()); 172 Profile* profile = Profile::FromBrowserContext(browser_context());
171 if (extension()->id() == extension_misc::kWallpaperManagerId) { 173 if (extension()->id() == extension_misc::kWallpaperManagerId) {
172 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, 174 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName,
173 std::string()); 175 std::string());
174 } else { 176 } else {
175 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, 177 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName,
176 extension()->name()); 178 extension()->name());
177 } 179 }
178 SendResponse(true); 180 SendResponse(true);
179 } 181 }
182
183 // Inform the native Wallpaper Picker Application that the current wallpaper
184 // has been modified by a third party application.
185 Profile* profile = Profile::FromBrowserContext(browser_context());
186 extensions::EventRouter* event_router = extensions::EventRouter::Get(profile);
187 scoped_ptr<base::ListValue> event_args(new base::ListValue());
188 scoped_ptr<extensions::Event> event(
189 new extensions::Event(extensions::api::wallpaper_private::
190 OnWallpaperChangedBy3rdParty::kEventName,
191 event_args.Pass()));
192 event_router->DispatchEventToExtension(extension_misc::kWallpaperManagerId,
193 event.Pass());
180 } 194 }
181 195
182 void WallpaperSetWallpaperFunction::GenerateThumbnail( 196 void WallpaperSetWallpaperFunction::GenerateThumbnail(
183 const base::FilePath& thumbnail_path, scoped_ptr<gfx::ImageSkia> image) { 197 const base::FilePath& thumbnail_path, scoped_ptr<gfx::ImageSkia> image) {
184 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( 198 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread(
185 sequence_token_)); 199 sequence_token_));
186 if (!base::PathExists(thumbnail_path.DirName())) 200 if (!base::PathExists(thumbnail_path.DirName()))
187 base::CreateDirectory(thumbnail_path.DirName()); 201 base::CreateDirectory(thumbnail_path.DirName());
188 202
189 scoped_refptr<base::RefCountedBytes> data; 203 scoped_refptr<base::RefCountedBytes> data;
(...skipping 21 matching lines...) Expand all
211 const std::string& response) { 225 const std::string& response) {
212 if (success) { 226 if (success) {
213 params_->details.data.reset( 227 params_->details.data.reset(
214 new std::vector<char>(response.begin(), response.end())); 228 new std::vector<char>(response.begin(), response.end()));
215 StartDecode(*params_->details.data); 229 StartDecode(*params_->details.data);
216 } else { 230 } else {
217 SetError(response); 231 SetError(response);
218 SendResponse(false); 232 SendResponse(false);
219 } 233 }
220 } 234 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/wallpaper_manager/js/event_page.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698