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

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

Issue 398753004: [cros] Move User class to user_manager component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add deps ( trybots) Created 6 years, 5 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_private_api.h" 5 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/desktop_background/desktop_background_controller.h" 10 #include "ash/desktop_background/desktop_background_controller.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/wm/mru_window_tracker.h" 12 #include "ash/wm/mru_window_tracker.h"
13 #include "ash/wm/window_state.h" 13 #include "ash/wm/window_state.h"
14 #include "ash/wm/window_util.h" 14 #include "ash/wm/window_util.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/file_util.h" 16 #include "base/file_util.h"
17 #include "base/files/file_enumerator.h" 17 #include "base/files/file_enumerator.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "base/path_service.h" 19 #include "base/path_service.h"
20 #include "base/prefs/pref_service.h" 20 #include "base/prefs/pref_service.h"
21 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
23 #include "base/threading/worker_pool.h" 23 #include "base/threading/worker_pool.h"
24 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/chromeos/login/users/user.h"
26 #include "chrome/browser/chromeos/login/users/user_manager.h" 25 #include "chrome/browser/chromeos/login/users/user_manager.h"
27 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" 26 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
28 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
29 #include "chrome/common/chrome_paths.h" 28 #include "chrome/common/chrome_paths.h"
30 #include "chrome/common/pref_names.h" 29 #include "chrome/common/pref_names.h"
30 #include "components/user_manager/user.h"
31 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
32 #include "extensions/browser/event_router.h" 32 #include "extensions/browser/event_router.h"
33 #include "grit/app_locale_settings.h" 33 #include "grit/app_locale_settings.h"
34 #include "grit/generated_resources.h" 34 #include "grit/generated_resources.h"
35 #include "grit/platform_locale_settings.h" 35 #include "grit/platform_locale_settings.h"
36 #include "ui/base/l10n/l10n_util.h" 36 #include "ui/base/l10n/l10n_util.h"
37 #include "ui/base/webui/web_ui_util.h" 37 #include "ui/base/webui/web_ui_util.h"
38 #include "url/gurl.h" 38 #include "url/gurl.h"
39 39
40 using base::BinaryValue; 40 using base::BinaryValue;
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 chromeos::WallpaperManager::Get(); 370 chromeos::WallpaperManager::Get();
371 ash::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( 371 ash::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum(
372 wallpaper_private::ToString(params->layout)); 372 wallpaper_private::ToString(params->layout));
373 373
374 bool update_wallpaper = 374 bool update_wallpaper =
375 user_id_ == chromeos::UserManager::Get()->GetActiveUser()->email(); 375 user_id_ == chromeos::UserManager::Get()->GetActiveUser()->email();
376 wallpaper_manager->SetWallpaperFromImageSkia( 376 wallpaper_manager->SetWallpaperFromImageSkia(
377 user_id_, image, layout, update_wallpaper); 377 user_id_, image, layout, update_wallpaper);
378 bool is_persistent = 378 bool is_persistent =
379 !chromeos::UserManager::Get()->IsCurrentUserNonCryptohomeDataEphemeral(); 379 !chromeos::UserManager::Get()->IsCurrentUserNonCryptohomeDataEphemeral();
380 chromeos::WallpaperInfo info = { 380 chromeos::WallpaperInfo info = {params->url, layout,
381 params->url, 381 user_manager::User::ONLINE,
382 layout, 382 base::Time::Now().LocalMidnight()};
383 chromeos::User::ONLINE,
384 base::Time::Now().LocalMidnight()
385 };
386 wallpaper_manager->SetUserWallpaperInfo(user_id_, info, is_persistent); 383 wallpaper_manager->SetUserWallpaperInfo(user_id_, info, is_persistent);
387 SetResult(new base::FundamentalValue(true)); 384 SetResult(new base::FundamentalValue(true));
388 Profile* profile = Profile::FromBrowserContext(browser_context()); 385 Profile* profile = Profile::FromBrowserContext(browser_context());
389 // This API is only available to the component wallpaper picker. We do not 386 // This API is only available to the component wallpaper picker. We do not
390 // need to show the app's name if it is the component wallpaper picker. So set 387 // need to show the app's name if it is the component wallpaper picker. So set
391 // the pref to empty string. 388 // the pref to empty string.
392 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, 389 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName,
393 std::string()); 390 std::string());
394 SendResponse(true); 391 SendResponse(true);
395 } 392 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 ash::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( 481 ash::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum(
485 wallpaper_private::ToString(params->layout)); 482 wallpaper_private::ToString(params->layout));
486 483
487 bool update_wallpaper = 484 bool update_wallpaper =
488 user_id_ == chromeos::UserManager::Get()->GetActiveUser()->email(); 485 user_id_ == chromeos::UserManager::Get()->GetActiveUser()->email();
489 wallpaper_manager->SetWallpaperFromImageSkia( 486 wallpaper_manager->SetWallpaperFromImageSkia(
490 user_id_, *image.get(), layout, update_wallpaper); 487 user_id_, *image.get(), layout, update_wallpaper);
491 488
492 bool is_persistent = 489 bool is_persistent =
493 !chromeos::UserManager::Get()->IsCurrentUserNonCryptohomeDataEphemeral(); 490 !chromeos::UserManager::Get()->IsCurrentUserNonCryptohomeDataEphemeral();
494 chromeos::WallpaperInfo info = { 491 chromeos::WallpaperInfo info = {params->url, layout,
495 params->url, 492 user_manager::User::ONLINE,
496 layout, 493 base::Time::Now().LocalMidnight()};
497 chromeos::User::ONLINE,
498 base::Time::Now().LocalMidnight()
499 };
500 Profile* profile = Profile::FromBrowserContext(browser_context()); 494 Profile* profile = Profile::FromBrowserContext(browser_context());
501 // This API is only available to the component wallpaper picker. We do not 495 // This API is only available to the component wallpaper picker. We do not
502 // need to show the app's name if it is the component wallpaper picker. So set 496 // need to show the app's name if it is the component wallpaper picker. So set
503 // the pref to empty string. 497 // the pref to empty string.
504 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, 498 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName,
505 std::string()); 499 std::string());
506 wallpaper_manager->SetUserWallpaperInfo(user_id_, info, is_persistent); 500 wallpaper_manager->SetUserWallpaperInfo(user_id_, info, is_persistent);
507 SendResponse(true); 501 SendResponse(true);
508 } 502 }
509 503
510 WallpaperPrivateResetWallpaperFunction:: 504 WallpaperPrivateResetWallpaperFunction::
511 WallpaperPrivateResetWallpaperFunction() {} 505 WallpaperPrivateResetWallpaperFunction() {}
512 506
513 WallpaperPrivateResetWallpaperFunction:: 507 WallpaperPrivateResetWallpaperFunction::
514 ~WallpaperPrivateResetWallpaperFunction() {} 508 ~WallpaperPrivateResetWallpaperFunction() {}
515 509
516 bool WallpaperPrivateResetWallpaperFunction::RunAsync() { 510 bool WallpaperPrivateResetWallpaperFunction::RunAsync() {
517 chromeos::WallpaperManager* wallpaper_manager = 511 chromeos::WallpaperManager* wallpaper_manager =
518 chromeos::WallpaperManager::Get(); 512 chromeos::WallpaperManager::Get();
519 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); 513 chromeos::UserManager* user_manager = chromeos::UserManager::Get();
520 514
521 std::string user_id = user_manager->GetActiveUser()->email(); 515 std::string user_id = user_manager->GetActiveUser()->email();
522 wallpaper_manager->RemoveUserWallpaperInfo(user_id); 516 wallpaper_manager->RemoveUserWallpaperInfo(user_id);
523 517
524 chromeos::WallpaperInfo info = { 518 chromeos::WallpaperInfo info = {"", ash::WALLPAPER_LAYOUT_CENTER,
Denis Kuznetsov (DE-MUC) 2014/07/22 10:56:55 nit: Rollback code layout change.
Nikita (slow) 2014/07/22 11:03:21 Done.
525 "", 519 user_manager::User::DEFAULT,
526 ash::WALLPAPER_LAYOUT_CENTER, 520 base::Time::Now().LocalMidnight()};
527 chromeos::User::DEFAULT,
528 base::Time::Now().LocalMidnight()
529 };
530 bool is_persistent = 521 bool is_persistent =
531 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); 522 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral();
532 wallpaper_manager->SetUserWallpaperInfo(user_id, info, is_persistent); 523 wallpaper_manager->SetUserWallpaperInfo(user_id, info, is_persistent);
533 524
534 wallpaper_manager->SetDefaultWallpaperNow(user_id); 525 wallpaper_manager->SetDefaultWallpaperNow(user_id);
535 Profile* profile = Profile::FromBrowserContext(browser_context()); 526 Profile* profile = Profile::FromBrowserContext(browser_context());
536 // This API is only available to the component wallpaper picker. We do not 527 // This API is only available to the component wallpaper picker. We do not
537 // need to show the app's name if it is the component wallpaper picker. So set 528 // need to show the app's name if it is the component wallpaper picker. So set
538 // the pref to empty string. 529 // the pref to empty string.
539 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, 530 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 568
578 ash::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( 569 ash::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum(
579 wallpaper_private::ToString(params->layout)); 570 wallpaper_private::ToString(params->layout));
580 571
581 bool update_wallpaper = 572 bool update_wallpaper =
582 user_id_ == chromeos::UserManager::Get()->GetActiveUser()->email(); 573 user_id_ == chromeos::UserManager::Get()->GetActiveUser()->email();
583 wallpaper_manager->SetCustomWallpaper(user_id_, 574 wallpaper_manager->SetCustomWallpaper(user_id_,
584 user_id_hash_, 575 user_id_hash_,
585 params->file_name, 576 params->file_name,
586 layout, 577 layout,
587 chromeos::User::CUSTOMIZED, 578 user_manager::User::CUSTOMIZED,
588 image, 579 image,
589 update_wallpaper); 580 update_wallpaper);
590 unsafe_wallpaper_decoder_ = NULL; 581 unsafe_wallpaper_decoder_ = NULL;
591 582
592 Profile* profile = Profile::FromBrowserContext(browser_context()); 583 Profile* profile = Profile::FromBrowserContext(browser_context());
593 // This API is only available to the component wallpaper picker. We do not 584 // This API is only available to the component wallpaper picker. We do not
594 // need to show the app's name if it is the component wallpaper picker. So set 585 // need to show the app's name if it is the component wallpaper picker. So set
595 // the pref to empty string. 586 // the pref to empty string.
596 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, 587 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName,
597 std::string()); 588 std::string());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 639
649 bool WallpaperPrivateSetCustomWallpaperLayoutFunction::RunAsync() { 640 bool WallpaperPrivateSetCustomWallpaperLayoutFunction::RunAsync() {
650 scoped_ptr<set_custom_wallpaper_layout::Params> params( 641 scoped_ptr<set_custom_wallpaper_layout::Params> params(
651 set_custom_wallpaper_layout::Params::Create(*args_)); 642 set_custom_wallpaper_layout::Params::Create(*args_));
652 EXTENSION_FUNCTION_VALIDATE(params); 643 EXTENSION_FUNCTION_VALIDATE(params);
653 644
654 chromeos::WallpaperManager* wallpaper_manager = 645 chromeos::WallpaperManager* wallpaper_manager =
655 chromeos::WallpaperManager::Get(); 646 chromeos::WallpaperManager::Get();
656 chromeos::WallpaperInfo info; 647 chromeos::WallpaperInfo info;
657 wallpaper_manager->GetLoggedInUserWallpaperInfo(&info); 648 wallpaper_manager->GetLoggedInUserWallpaperInfo(&info);
658 if (info.type != chromeos::User::CUSTOMIZED) { 649 if (info.type != user_manager::User::CUSTOMIZED) {
659 SetError("Only custom wallpaper can change layout."); 650 SetError("Only custom wallpaper can change layout.");
660 SendResponse(false); 651 SendResponse(false);
661 return false; 652 return false;
662 } 653 }
663 info.layout = wallpaper_api_util::GetLayoutEnum( 654 info.layout = wallpaper_api_util::GetLayoutEnum(
664 wallpaper_private::ToString(params->layout)); 655 wallpaper_private::ToString(params->layout));
665 656
666 std::string email = chromeos::UserManager::Get()->GetActiveUser()->email(); 657 std::string email = chromeos::UserManager::Get()->GetActiveUser()->email();
667 bool is_persistent = 658 bool is_persistent =
668 !chromeos::UserManager::Get()->IsCurrentUserNonCryptohomeDataEphemeral(); 659 !chromeos::UserManager::Get()->IsCurrentUserNonCryptohomeDataEphemeral();
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 this, file_list)); 876 this, file_list));
886 } 877 }
887 878
888 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( 879 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete(
889 const std::vector<std::string>& file_list) { 880 const std::vector<std::string>& file_list) {
890 base::ListValue* results = new base::ListValue(); 881 base::ListValue* results = new base::ListValue();
891 results->AppendStrings(file_list); 882 results->AppendStrings(file_list);
892 SetResult(results); 883 SetResult(results);
893 SendResponse(true); 884 SendResponse(true);
894 } 885 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698