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

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

Issue 1931713002: Don't show the 'wallpaper-set-by-message' if the current wallpaper is set by the right click menu o… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | no next file » | 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 <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/desktop_background/desktop_background_controller.h" 11 #include "ash/desktop_background/desktop_background_controller.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/memory/ref_counted_memory.h" 14 #include "base/memory/ref_counted_memory.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/threading/worker_pool.h" 16 #include "base/threading/worker_pool.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h" 18 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h"
19 #include "chrome/browser/chromeos/file_manager/app_id.h"
19 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" 20 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
20 #include "chrome/browser/chromeos/profiles/profile_helper.h" 21 #include "chrome/browser/chromeos/profiles/profile_helper.h"
21 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/common/chrome_paths.h" 23 #include "chrome/common/chrome_paths.h"
23 #include "chrome/common/extensions/extension_constants.h" 24 #include "chrome/common/extensions/extension_constants.h"
24 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
25 #include "components/prefs/pref_service.h" 26 #include "components/prefs/pref_service.h"
26 #include "components/user_manager/user.h" 27 #include "components/user_manager/user.h"
27 #include "components/user_manager/user_manager.h" 28 #include "components/user_manager/user_manager.h"
28 #include "components/wallpaper/wallpaper_layout.h" 29 #include "components/wallpaper/wallpaper_layout.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 wallpaper_api_util::RecordCustomWallpaperLayout(layout); 165 wallpaper_api_util::RecordCustomWallpaperLayout(layout);
165 166
166 bool update_wallpaper = 167 bool update_wallpaper =
167 account_id_ == 168 account_id_ ==
168 user_manager::UserManager::Get()->GetActiveUser()->GetAccountId(); 169 user_manager::UserManager::Get()->GetActiveUser()->GetAccountId();
169 wallpaper_manager->SetCustomWallpaper( 170 wallpaper_manager->SetCustomWallpaper(
170 account_id_, wallpaper_files_id_, params_->details.filename, layout, 171 account_id_, wallpaper_files_id_, params_->details.filename, layout,
171 user_manager::User::CUSTOMIZED, image, update_wallpaper); 172 user_manager::User::CUSTOMIZED, image, update_wallpaper);
172 unsafe_wallpaper_decoder_ = NULL; 173 unsafe_wallpaper_decoder_ = NULL;
173 174
174 // Save current extenion name. It will be displayed in the component 175 // Save current extension name. It will be displayed in the component
175 // wallpaper picker app. If current extension is the component wallpaper 176 // wallpaper picker app. If current extension is the component wallpaper
176 // picker, set an empty string. 177 // picker, set an empty string.
178 // TODO(xdai): This preference is unused now. For compatiblity concern, we
179 // need to keep it until it's safe to clean it up.
177 Profile* profile = Profile::FromBrowserContext(browser_context()); 180 Profile* profile = Profile::FromBrowserContext(browser_context());
178 if (extension()->id() == extension_misc::kWallpaperManagerId) { 181 if (extension()->id() == extension_misc::kWallpaperManagerId) {
179 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, 182 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName,
180 std::string()); 183 std::string());
181 } else { 184 } else {
182 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, 185 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName,
183 extension()->name()); 186 extension()->name());
184 } 187 }
185 188
186 if (!params_->details.thumbnail) 189 if (!params_->details.thumbnail)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // has been modified by a third party application. 244 // has been modified by a third party application.
242 if (extension()->id() != extension_misc::kWallpaperManagerId) { 245 if (extension()->id() != extension_misc::kWallpaperManagerId) {
243 Profile* profile = Profile::FromBrowserContext(browser_context()); 246 Profile* profile = Profile::FromBrowserContext(browser_context());
244 extensions::EventRouter* event_router = 247 extensions::EventRouter* event_router =
245 extensions::EventRouter::Get(profile); 248 extensions::EventRouter::Get(profile);
246 std::unique_ptr<base::ListValue> event_args(new base::ListValue()); 249 std::unique_ptr<base::ListValue> event_args(new base::ListValue());
247 event_args->Append(original_result); 250 event_args->Append(original_result);
248 event_args->Append(thumbnail_result); 251 event_args->Append(thumbnail_result);
249 event_args->Append(new base::StringValue( 252 event_args->Append(new base::StringValue(
250 extensions::api::wallpaper::ToString(params_->details.layout))); 253 extensions::api::wallpaper::ToString(params_->details.layout)));
251 event_args->Append(new base::StringValue(extension()->name())); 254 // Setting wallpaper from right click menu in 'Files' app is a feature that
255 // was implemented in crbug.com/578935. Since 'Files' app is a built-in v1
256 // app in ChromeOS, we should treat it slightly differently with other third
257 // party apps: the wallpaper set by the 'Files' app should still be syncable
258 // and it should not appear in the wallpaper grid in the Wallpaper Picker.
259 // But we should not display the 'wallpaper-set-by-mesage' since it might
260 // introduce confusion as shown in crbug.com/599407.
261 event_args->Append(new base::StringValue(
262 (extension()->id() == file_manager::kFileManagerAppId)
263 ? std::string()
264 : extension()->name()));
252 std::unique_ptr<extensions::Event> event(new extensions::Event( 265 std::unique_ptr<extensions::Event> event(new extensions::Event(
253 extensions::events::WALLPAPER_PRIVATE_ON_WALLPAPER_CHANGED_BY_3RD_PARTY, 266 extensions::events::WALLPAPER_PRIVATE_ON_WALLPAPER_CHANGED_BY_3RD_PARTY,
254 extensions::api::wallpaper_private::OnWallpaperChangedBy3rdParty:: 267 extensions::api::wallpaper_private::OnWallpaperChangedBy3rdParty::
255 kEventName, 268 kEventName,
256 std::move(event_args))); 269 std::move(event_args)));
257 event_router->DispatchEventToExtension(extension_misc::kWallpaperManagerId, 270 event_router->DispatchEventToExtension(extension_misc::kWallpaperManagerId,
258 std::move(event)); 271 std::move(event));
259 } 272 }
260 } 273 }
261 274
262 void WallpaperSetWallpaperFunction::OnWallpaperFetched( 275 void WallpaperSetWallpaperFunction::OnWallpaperFetched(
263 bool success, 276 bool success,
264 const std::string& response) { 277 const std::string& response) {
265 if (success) { 278 if (success) {
266 params_->details.data.reset( 279 params_->details.data.reset(
267 new std::vector<char>(response.begin(), response.end())); 280 new std::vector<char>(response.begin(), response.end()));
268 StartDecode(*params_->details.data); 281 StartDecode(*params_->details.data);
269 } else { 282 } else {
270 SetError(response); 283 SetError(response);
271 SendResponse(false); 284 SendResponse(false);
272 } 285 }
273 } 286 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698