| OLD | NEW |
| 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 <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 chromeos::WallpaperManager::Get(); | 310 chromeos::WallpaperManager::Get(); |
| 311 wallpaper::WallpaperInfo info; | 311 wallpaper::WallpaperInfo info; |
| 312 | 312 |
| 313 if (wallpaper_manager->GetLoggedInUserWallpaperInfo(&info)) | 313 if (wallpaper_manager->GetLoggedInUserWallpaperInfo(&info)) |
| 314 dict->SetString("currentWallpaper", info.location); | 314 dict->SetString("currentWallpaper", info.location); |
| 315 | 315 |
| 316 #if defined(GOOGLE_CHROME_BUILD) | 316 #if defined(GOOGLE_CHROME_BUILD) |
| 317 dict->SetString("manifestBaseURL", kWallpaperManifestBaseURL); | 317 dict->SetString("manifestBaseURL", kWallpaperManifestBaseURL); |
| 318 #endif | 318 #endif |
| 319 | 319 |
| 320 Profile* profile = Profile::FromBrowserContext(browser_context()); | |
| 321 std::string app_name( | |
| 322 profile->GetPrefs()->GetString(prefs::kCurrentWallpaperAppName)); | |
| 323 if (!app_name.empty()) | |
| 324 dict->SetString("wallpaperAppName", app_name); | |
| 325 | |
| 326 dict->SetBoolean("isOEMDefaultWallpaper", IsOEMDefaultWallpaper()); | 320 dict->SetBoolean("isOEMDefaultWallpaper", IsOEMDefaultWallpaper()); |
| 327 dict->SetString("canceledWallpaper", | 321 dict->SetString("canceledWallpaper", |
| 328 wallpaper_api_util::kCancelWallpaperMessage); | 322 wallpaper_api_util::kCancelWallpaperMessage); |
| 329 return true; | 323 return true; |
| 330 } | 324 } |
| 331 | 325 |
| 332 bool WallpaperPrivateGetSyncSettingFunction::RunSync() { | 326 bool WallpaperPrivateGetSyncSettingFunction::RunSync() { |
| 333 Profile* profile = Profile::FromBrowserContext(browser_context()); | 327 Profile* profile = Profile::FromBrowserContext(browser_context()); |
| 334 ProfileSyncService* sync = | 328 ProfileSyncService* sync = |
| 335 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); | 329 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 wallpaper_manager->SetWallpaperFromImageSkia(account_id_, image, layout, | 424 wallpaper_manager->SetWallpaperFromImageSkia(account_id_, image, layout, |
| 431 update_wallpaper); | 425 update_wallpaper); |
| 432 bool is_persistent = !user_manager::UserManager::Get() | 426 bool is_persistent = !user_manager::UserManager::Get() |
| 433 ->IsCurrentUserNonCryptohomeDataEphemeral(); | 427 ->IsCurrentUserNonCryptohomeDataEphemeral(); |
| 434 wallpaper::WallpaperInfo info = {params->url, | 428 wallpaper::WallpaperInfo info = {params->url, |
| 435 layout, | 429 layout, |
| 436 user_manager::User::ONLINE, | 430 user_manager::User::ONLINE, |
| 437 base::Time::Now().LocalMidnight()}; | 431 base::Time::Now().LocalMidnight()}; |
| 438 wallpaper_manager->SetUserWallpaperInfo(account_id_, info, is_persistent); | 432 wallpaper_manager->SetUserWallpaperInfo(account_id_, info, is_persistent); |
| 439 SetResult(new base::FundamentalValue(true)); | 433 SetResult(new base::FundamentalValue(true)); |
| 440 Profile* profile = Profile::FromBrowserContext(browser_context()); | |
| 441 // This API is only available to the component wallpaper picker. We do not | |
| 442 // need to show the app's name if it is the component wallpaper picker. So set | |
| 443 // the pref to empty string. | |
| 444 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, | |
| 445 std::string()); | |
| 446 SendResponse(true); | 434 SendResponse(true); |
| 447 } | 435 } |
| 448 | 436 |
| 449 void WallpaperPrivateSetWallpaperIfExistsFunction::OnFileNotExists( | 437 void WallpaperPrivateSetWallpaperIfExistsFunction::OnFileNotExists( |
| 450 const std::string& error) { | 438 const std::string& error) { |
| 451 SetResult(new base::FundamentalValue(false)); | 439 SetResult(new base::FundamentalValue(false)); |
| 452 OnFailure(error); | 440 OnFailure(error); |
| 453 } | 441 } |
| 454 | 442 |
| 455 WallpaperPrivateSetWallpaperFunction::WallpaperPrivateSetWallpaperFunction() { | 443 WallpaperPrivateSetWallpaperFunction::WallpaperPrivateSetWallpaperFunction() { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 user_manager::UserManager::Get()->GetActiveUser()->GetAccountId(); | 526 user_manager::UserManager::Get()->GetActiveUser()->GetAccountId(); |
| 539 wallpaper_manager->SetWallpaperFromImageSkia(account_id_, *image.get(), | 527 wallpaper_manager->SetWallpaperFromImageSkia(account_id_, *image.get(), |
| 540 layout, update_wallpaper); | 528 layout, update_wallpaper); |
| 541 | 529 |
| 542 bool is_persistent = !user_manager::UserManager::Get() | 530 bool is_persistent = !user_manager::UserManager::Get() |
| 543 ->IsCurrentUserNonCryptohomeDataEphemeral(); | 531 ->IsCurrentUserNonCryptohomeDataEphemeral(); |
| 544 wallpaper::WallpaperInfo info = {params->url, | 532 wallpaper::WallpaperInfo info = {params->url, |
| 545 layout, | 533 layout, |
| 546 user_manager::User::ONLINE, | 534 user_manager::User::ONLINE, |
| 547 base::Time::Now().LocalMidnight()}; | 535 base::Time::Now().LocalMidnight()}; |
| 548 Profile* profile = Profile::FromBrowserContext(browser_context()); | |
| 549 // This API is only available to the component wallpaper picker. We do not | |
| 550 // need to show the app's name if it is the component wallpaper picker. So set | |
| 551 // the pref to empty string. | |
| 552 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, | |
| 553 std::string()); | |
| 554 wallpaper_manager->SetUserWallpaperInfo(account_id_, info, is_persistent); | 536 wallpaper_manager->SetUserWallpaperInfo(account_id_, info, is_persistent); |
| 555 SendResponse(true); | 537 SendResponse(true); |
| 556 } | 538 } |
| 557 | 539 |
| 558 WallpaperPrivateResetWallpaperFunction:: | 540 WallpaperPrivateResetWallpaperFunction:: |
| 559 WallpaperPrivateResetWallpaperFunction() {} | 541 WallpaperPrivateResetWallpaperFunction() {} |
| 560 | 542 |
| 561 WallpaperPrivateResetWallpaperFunction:: | 543 WallpaperPrivateResetWallpaperFunction:: |
| 562 ~WallpaperPrivateResetWallpaperFunction() {} | 544 ~WallpaperPrivateResetWallpaperFunction() {} |
| 563 | 545 |
| 564 bool WallpaperPrivateResetWallpaperFunction::RunAsync() { | 546 bool WallpaperPrivateResetWallpaperFunction::RunAsync() { |
| 565 chromeos::WallpaperManager* wallpaper_manager = | 547 chromeos::WallpaperManager* wallpaper_manager = |
| 566 chromeos::WallpaperManager::Get(); | 548 chromeos::WallpaperManager::Get(); |
| 567 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 549 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 568 | 550 |
| 569 const AccountId& account_id = user_manager->GetActiveUser()->GetAccountId(); | 551 const AccountId& account_id = user_manager->GetActiveUser()->GetAccountId(); |
| 570 wallpaper_manager->RemoveUserWallpaperInfo(account_id); | 552 wallpaper_manager->RemoveUserWallpaperInfo(account_id); |
| 571 | 553 |
| 572 wallpaper::WallpaperInfo info = {std::string(), | 554 wallpaper::WallpaperInfo info = {std::string(), |
| 573 wallpaper::WALLPAPER_LAYOUT_CENTER, | 555 wallpaper::WALLPAPER_LAYOUT_CENTER, |
| 574 user_manager::User::DEFAULT, | 556 user_manager::User::DEFAULT, |
| 575 base::Time::Now().LocalMidnight()}; | 557 base::Time::Now().LocalMidnight()}; |
| 576 bool is_persistent = | 558 bool is_persistent = |
| 577 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); | 559 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); |
| 578 wallpaper_manager->SetUserWallpaperInfo(account_id, info, is_persistent); | 560 wallpaper_manager->SetUserWallpaperInfo(account_id, info, is_persistent); |
| 579 | 561 |
| 580 wallpaper_manager->SetDefaultWallpaperNow(account_id); | 562 wallpaper_manager->SetDefaultWallpaperNow(account_id); |
| 581 Profile* profile = Profile::FromBrowserContext(browser_context()); | |
| 582 // This API is only available to the component wallpaper picker. We do not | |
| 583 // need to show the app's name if it is the component wallpaper picker. So set | |
| 584 // the pref to empty string. | |
| 585 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, | |
| 586 std::string()); | |
| 587 return true; | 563 return true; |
| 588 } | 564 } |
| 589 | 565 |
| 590 WallpaperPrivateSetCustomWallpaperFunction:: | 566 WallpaperPrivateSetCustomWallpaperFunction:: |
| 591 WallpaperPrivateSetCustomWallpaperFunction() {} | 567 WallpaperPrivateSetCustomWallpaperFunction() {} |
| 592 | 568 |
| 593 WallpaperPrivateSetCustomWallpaperFunction:: | 569 WallpaperPrivateSetCustomWallpaperFunction:: |
| 594 ~WallpaperPrivateSetCustomWallpaperFunction() {} | 570 ~WallpaperPrivateSetCustomWallpaperFunction() {} |
| 595 | 571 |
| 596 bool WallpaperPrivateSetCustomWallpaperFunction::RunAsync() { | 572 bool WallpaperPrivateSetCustomWallpaperFunction::RunAsync() { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 626 wallpaper_api_util::RecordCustomWallpaperLayout(layout); | 602 wallpaper_api_util::RecordCustomWallpaperLayout(layout); |
| 627 | 603 |
| 628 bool update_wallpaper = | 604 bool update_wallpaper = |
| 629 account_id_ == | 605 account_id_ == |
| 630 user_manager::UserManager::Get()->GetActiveUser()->GetAccountId(); | 606 user_manager::UserManager::Get()->GetActiveUser()->GetAccountId(); |
| 631 wallpaper_manager->SetCustomWallpaper( | 607 wallpaper_manager->SetCustomWallpaper( |
| 632 account_id_, user_id_hash_, params->file_name, layout, | 608 account_id_, user_id_hash_, params->file_name, layout, |
| 633 user_manager::User::CUSTOMIZED, image, update_wallpaper); | 609 user_manager::User::CUSTOMIZED, image, update_wallpaper); |
| 634 unsafe_wallpaper_decoder_ = NULL; | 610 unsafe_wallpaper_decoder_ = NULL; |
| 635 | 611 |
| 636 Profile* profile = Profile::FromBrowserContext(browser_context()); | |
| 637 // This API is only available to the component wallpaper picker. We do not | |
| 638 // need to show the app's name if it is the component wallpaper picker. So set | |
| 639 // the pref to empty string. | |
| 640 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, | |
| 641 std::string()); | |
| 642 | 612 |
| 643 if (params->generate_thumbnail) { | 613 if (params->generate_thumbnail) { |
| 644 image.EnsureRepsForSupportedScales(); | 614 image.EnsureRepsForSupportedScales(); |
| 645 scoped_ptr<gfx::ImageSkia> deep_copy(image.DeepCopy()); | 615 scoped_ptr<gfx::ImageSkia> deep_copy(image.DeepCopy()); |
| 646 // Generates thumbnail before call api function callback. We can then | 616 // Generates thumbnail before call api function callback. We can then |
| 647 // request thumbnail in the javascript callback. | 617 // request thumbnail in the javascript callback. |
| 648 task_runner->PostTask(FROM_HERE, | 618 task_runner->PostTask(FROM_HERE, |
| 649 base::Bind( | 619 base::Bind( |
| 650 &WallpaperPrivateSetCustomWallpaperFunction::GenerateThumbnail, | 620 &WallpaperPrivateSetCustomWallpaperFunction::GenerateThumbnail, |
| 651 this, thumbnail_path, base::Passed(&deep_copy))); | 621 this, thumbnail_path, base::Passed(&deep_copy))); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 this, file_list)); | 897 this, file_list)); |
| 928 } | 898 } |
| 929 | 899 |
| 930 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( | 900 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( |
| 931 const std::vector<std::string>& file_list) { | 901 const std::vector<std::string>& file_list) { |
| 932 base::ListValue* results = new base::ListValue(); | 902 base::ListValue* results = new base::ListValue(); |
| 933 results->AppendStrings(file_list); | 903 results->AppendStrings(file_list); |
| 934 SetResult(results); | 904 SetResult(results); |
| 935 SendResponse(true); | 905 SendResponse(true); |
| 936 } | 906 } |
| OLD | NEW |