| 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 <vector> | 10 #include <vector> |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 WallpaperPrivateSetWallpaperIfExistsFunction:: | 341 WallpaperPrivateSetWallpaperIfExistsFunction:: |
| 342 WallpaperPrivateSetWallpaperIfExistsFunction() {} | 342 WallpaperPrivateSetWallpaperIfExistsFunction() {} |
| 343 | 343 |
| 344 WallpaperPrivateSetWallpaperIfExistsFunction:: | 344 WallpaperPrivateSetWallpaperIfExistsFunction:: |
| 345 ~WallpaperPrivateSetWallpaperIfExistsFunction() {} | 345 ~WallpaperPrivateSetWallpaperIfExistsFunction() {} |
| 346 | 346 |
| 347 bool WallpaperPrivateSetWallpaperIfExistsFunction::RunAsync() { | 347 bool WallpaperPrivateSetWallpaperIfExistsFunction::RunAsync() { |
| 348 params = set_wallpaper_if_exists::Params::Create(*args_); | 348 params = set_wallpaper_if_exists::Params::Create(*args_); |
| 349 EXTENSION_FUNCTION_VALIDATE(params); | 349 EXTENSION_FUNCTION_VALIDATE(params); |
| 350 | 350 |
| 351 // Gets email address from caller, ensuring multiprofile compatibility. | 351 // Gets account id from the caller, ensuring multiprofile compatibility. |
| 352 const user_manager::User* user = GetUserFromBrowserContext(browser_context()); | 352 const user_manager::User* user = GetUserFromBrowserContext(browser_context()); |
| 353 user_id_ = user->email(); | 353 account_id_ = user->GetAccountId(); |
| 354 | 354 |
| 355 base::FilePath wallpaper_path; | 355 base::FilePath wallpaper_path; |
| 356 base::FilePath fallback_path; | 356 base::FilePath fallback_path; |
| 357 chromeos::WallpaperManager::WallpaperResolution resolution = | 357 chromeos::WallpaperManager::WallpaperResolution resolution = |
| 358 chromeos::WallpaperManager::Get()->GetAppropriateResolution(); | 358 chromeos::WallpaperManager::Get()->GetAppropriateResolution(); |
| 359 | 359 |
| 360 std::string file_name = GURL(params->url).ExtractFileName(); | 360 std::string file_name = GURL(params->url).ExtractFileName(); |
| 361 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPERS, | 361 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPERS, |
| 362 &wallpaper_path)); | 362 &wallpaper_path)); |
| 363 fallback_path = wallpaper_path.Append(file_name); | 363 fallback_path = wallpaper_path.Append(file_name); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 const gfx::ImageSkia& image) { | 416 const gfx::ImageSkia& image) { |
| 417 // Set unsafe_wallpaper_decoder_ to null since the decoding already finished. | 417 // Set unsafe_wallpaper_decoder_ to null since the decoding already finished. |
| 418 unsafe_wallpaper_decoder_ = NULL; | 418 unsafe_wallpaper_decoder_ = NULL; |
| 419 | 419 |
| 420 chromeos::WallpaperManager* wallpaper_manager = | 420 chromeos::WallpaperManager* wallpaper_manager = |
| 421 chromeos::WallpaperManager::Get(); | 421 chromeos::WallpaperManager::Get(); |
| 422 wallpaper::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( | 422 wallpaper::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( |
| 423 wallpaper_base::ToString(params->layout)); | 423 wallpaper_base::ToString(params->layout)); |
| 424 | 424 |
| 425 bool update_wallpaper = | 425 bool update_wallpaper = |
| 426 user_id_ == user_manager::UserManager::Get()->GetActiveUser()->email(); | 426 account_id_ == |
| 427 wallpaper_manager->SetWallpaperFromImageSkia( | 427 user_manager::UserManager::Get()->GetActiveUser()->GetAccountId(); |
| 428 user_id_, image, layout, update_wallpaper); | 428 wallpaper_manager->SetWallpaperFromImageSkia(account_id_, image, layout, |
| 429 update_wallpaper); |
| 429 bool is_persistent = !user_manager::UserManager::Get() | 430 bool is_persistent = !user_manager::UserManager::Get() |
| 430 ->IsCurrentUserNonCryptohomeDataEphemeral(); | 431 ->IsCurrentUserNonCryptohomeDataEphemeral(); |
| 431 wallpaper::WallpaperInfo info = {params->url, | 432 wallpaper::WallpaperInfo info = {params->url, |
| 432 layout, | 433 layout, |
| 433 user_manager::User::ONLINE, | 434 user_manager::User::ONLINE, |
| 434 base::Time::Now().LocalMidnight()}; | 435 base::Time::Now().LocalMidnight()}; |
| 435 wallpaper_manager->SetUserWallpaperInfo(user_id_, info, is_persistent); | 436 wallpaper_manager->SetUserWallpaperInfo(account_id_, info, is_persistent); |
| 436 SetResult(new base::FundamentalValue(true)); | 437 SetResult(new base::FundamentalValue(true)); |
| 437 Profile* profile = Profile::FromBrowserContext(browser_context()); | 438 Profile* profile = Profile::FromBrowserContext(browser_context()); |
| 438 // This API is only available to the component wallpaper picker. We do not | 439 // This API is only available to the component wallpaper picker. We do not |
| 439 // need to show the app's name if it is the component wallpaper picker. So set | 440 // need to show the app's name if it is the component wallpaper picker. So set |
| 440 // the pref to empty string. | 441 // the pref to empty string. |
| 441 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, | 442 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, |
| 442 std::string()); | 443 std::string()); |
| 443 SendResponse(true); | 444 SendResponse(true); |
| 444 } | 445 } |
| 445 | 446 |
| 446 void WallpaperPrivateSetWallpaperIfExistsFunction::OnFileNotExists( | 447 void WallpaperPrivateSetWallpaperIfExistsFunction::OnFileNotExists( |
| 447 const std::string& error) { | 448 const std::string& error) { |
| 448 SetResult(new base::FundamentalValue(false)); | 449 SetResult(new base::FundamentalValue(false)); |
| 449 OnFailure(error); | 450 OnFailure(error); |
| 450 } | 451 } |
| 451 | 452 |
| 452 WallpaperPrivateSetWallpaperFunction::WallpaperPrivateSetWallpaperFunction() { | 453 WallpaperPrivateSetWallpaperFunction::WallpaperPrivateSetWallpaperFunction() { |
| 453 } | 454 } |
| 454 | 455 |
| 455 WallpaperPrivateSetWallpaperFunction::~WallpaperPrivateSetWallpaperFunction() { | 456 WallpaperPrivateSetWallpaperFunction::~WallpaperPrivateSetWallpaperFunction() { |
| 456 } | 457 } |
| 457 | 458 |
| 458 bool WallpaperPrivateSetWallpaperFunction::RunAsync() { | 459 bool WallpaperPrivateSetWallpaperFunction::RunAsync() { |
| 459 params = set_wallpaper::Params::Create(*args_); | 460 params = set_wallpaper::Params::Create(*args_); |
| 460 EXTENSION_FUNCTION_VALIDATE(params); | 461 EXTENSION_FUNCTION_VALIDATE(params); |
| 461 | 462 |
| 462 // Gets email address from caller, ensuring multiprofile compatibility. | 463 // Gets account id from the caller, ensuring multiprofile compatibility. |
| 463 const user_manager::User* user = GetUserFromBrowserContext(browser_context()); | 464 const user_manager::User* user = GetUserFromBrowserContext(browser_context()); |
| 464 user_id_ = user->email(); | 465 account_id_ = user->GetAccountId(); |
| 465 | 466 |
| 466 StartDecode(params->wallpaper); | 467 StartDecode(params->wallpaper); |
| 467 | 468 |
| 468 return true; | 469 return true; |
| 469 } | 470 } |
| 470 | 471 |
| 471 void WallpaperPrivateSetWallpaperFunction::OnWallpaperDecoded( | 472 void WallpaperPrivateSetWallpaperFunction::OnWallpaperDecoded( |
| 472 const gfx::ImageSkia& image) { | 473 const gfx::ImageSkia& image) { |
| 473 wallpaper_ = image; | 474 wallpaper_ = image; |
| 474 // Set unsafe_wallpaper_decoder_ to null since the decoding already finished. | 475 // Set unsafe_wallpaper_decoder_ to null since the decoding already finished. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 | 527 |
| 527 void WallpaperPrivateSetWallpaperFunction::SetDecodedWallpaper( | 528 void WallpaperPrivateSetWallpaperFunction::SetDecodedWallpaper( |
| 528 scoped_ptr<gfx::ImageSkia> image) { | 529 scoped_ptr<gfx::ImageSkia> image) { |
| 529 chromeos::WallpaperManager* wallpaper_manager = | 530 chromeos::WallpaperManager* wallpaper_manager = |
| 530 chromeos::WallpaperManager::Get(); | 531 chromeos::WallpaperManager::Get(); |
| 531 | 532 |
| 532 wallpaper::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( | 533 wallpaper::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( |
| 533 wallpaper_base::ToString(params->layout)); | 534 wallpaper_base::ToString(params->layout)); |
| 534 | 535 |
| 535 bool update_wallpaper = | 536 bool update_wallpaper = |
| 536 user_id_ == user_manager::UserManager::Get()->GetActiveUser()->email(); | 537 account_id_ == |
| 537 wallpaper_manager->SetWallpaperFromImageSkia( | 538 user_manager::UserManager::Get()->GetActiveUser()->GetAccountId(); |
| 538 user_id_, *image.get(), layout, update_wallpaper); | 539 wallpaper_manager->SetWallpaperFromImageSkia(account_id_, *image.get(), |
| 540 layout, update_wallpaper); |
| 539 | 541 |
| 540 bool is_persistent = !user_manager::UserManager::Get() | 542 bool is_persistent = !user_manager::UserManager::Get() |
| 541 ->IsCurrentUserNonCryptohomeDataEphemeral(); | 543 ->IsCurrentUserNonCryptohomeDataEphemeral(); |
| 542 wallpaper::WallpaperInfo info = {params->url, | 544 wallpaper::WallpaperInfo info = {params->url, |
| 543 layout, | 545 layout, |
| 544 user_manager::User::ONLINE, | 546 user_manager::User::ONLINE, |
| 545 base::Time::Now().LocalMidnight()}; | 547 base::Time::Now().LocalMidnight()}; |
| 546 Profile* profile = Profile::FromBrowserContext(browser_context()); | 548 Profile* profile = Profile::FromBrowserContext(browser_context()); |
| 547 // This API is only available to the component wallpaper picker. We do not | 549 // This API is only available to the component wallpaper picker. We do not |
| 548 // need to show the app's name if it is the component wallpaper picker. So set | 550 // need to show the app's name if it is the component wallpaper picker. So set |
| 549 // the pref to empty string. | 551 // the pref to empty string. |
| 550 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, | 552 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, |
| 551 std::string()); | 553 std::string()); |
| 552 wallpaper_manager->SetUserWallpaperInfo(user_id_, info, is_persistent); | 554 wallpaper_manager->SetUserWallpaperInfo(account_id_, info, is_persistent); |
| 553 SendResponse(true); | 555 SendResponse(true); |
| 554 } | 556 } |
| 555 | 557 |
| 556 WallpaperPrivateResetWallpaperFunction:: | 558 WallpaperPrivateResetWallpaperFunction:: |
| 557 WallpaperPrivateResetWallpaperFunction() {} | 559 WallpaperPrivateResetWallpaperFunction() {} |
| 558 | 560 |
| 559 WallpaperPrivateResetWallpaperFunction:: | 561 WallpaperPrivateResetWallpaperFunction:: |
| 560 ~WallpaperPrivateResetWallpaperFunction() {} | 562 ~WallpaperPrivateResetWallpaperFunction() {} |
| 561 | 563 |
| 562 bool WallpaperPrivateResetWallpaperFunction::RunAsync() { | 564 bool WallpaperPrivateResetWallpaperFunction::RunAsync() { |
| 563 chromeos::WallpaperManager* wallpaper_manager = | 565 chromeos::WallpaperManager* wallpaper_manager = |
| 564 chromeos::WallpaperManager::Get(); | 566 chromeos::WallpaperManager::Get(); |
| 565 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 567 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 566 | 568 |
| 567 std::string user_id = user_manager->GetActiveUser()->email(); | 569 const AccountId& account_id = user_manager->GetActiveUser()->GetAccountId(); |
| 568 wallpaper_manager->RemoveUserWallpaperInfo(user_id); | 570 wallpaper_manager->RemoveUserWallpaperInfo(account_id); |
| 569 | 571 |
| 570 wallpaper::WallpaperInfo info = {std::string(), | 572 wallpaper::WallpaperInfo info = {std::string(), |
| 571 wallpaper::WALLPAPER_LAYOUT_CENTER, | 573 wallpaper::WALLPAPER_LAYOUT_CENTER, |
| 572 user_manager::User::DEFAULT, | 574 user_manager::User::DEFAULT, |
| 573 base::Time::Now().LocalMidnight()}; | 575 base::Time::Now().LocalMidnight()}; |
| 574 bool is_persistent = | 576 bool is_persistent = |
| 575 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); | 577 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); |
| 576 wallpaper_manager->SetUserWallpaperInfo(user_id, info, is_persistent); | 578 wallpaper_manager->SetUserWallpaperInfo(account_id, info, is_persistent); |
| 577 | 579 |
| 578 wallpaper_manager->SetDefaultWallpaperNow(user_id); | 580 wallpaper_manager->SetDefaultWallpaperNow(account_id); |
| 579 Profile* profile = Profile::FromBrowserContext(browser_context()); | 581 Profile* profile = Profile::FromBrowserContext(browser_context()); |
| 580 // This API is only available to the component wallpaper picker. We do not | 582 // This API is only available to the component wallpaper picker. We do not |
| 581 // need to show the app's name if it is the component wallpaper picker. So set | 583 // need to show the app's name if it is the component wallpaper picker. So set |
| 582 // the pref to empty string. | 584 // the pref to empty string. |
| 583 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, | 585 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, |
| 584 std::string()); | 586 std::string()); |
| 585 return true; | 587 return true; |
| 586 } | 588 } |
| 587 | 589 |
| 588 WallpaperPrivateSetCustomWallpaperFunction:: | 590 WallpaperPrivateSetCustomWallpaperFunction:: |
| 589 WallpaperPrivateSetCustomWallpaperFunction() {} | 591 WallpaperPrivateSetCustomWallpaperFunction() {} |
| 590 | 592 |
| 591 WallpaperPrivateSetCustomWallpaperFunction:: | 593 WallpaperPrivateSetCustomWallpaperFunction:: |
| 592 ~WallpaperPrivateSetCustomWallpaperFunction() {} | 594 ~WallpaperPrivateSetCustomWallpaperFunction() {} |
| 593 | 595 |
| 594 bool WallpaperPrivateSetCustomWallpaperFunction::RunAsync() { | 596 bool WallpaperPrivateSetCustomWallpaperFunction::RunAsync() { |
| 595 params = set_custom_wallpaper::Params::Create(*args_); | 597 params = set_custom_wallpaper::Params::Create(*args_); |
| 596 EXTENSION_FUNCTION_VALIDATE(params); | 598 EXTENSION_FUNCTION_VALIDATE(params); |
| 597 | 599 |
| 598 // Gets email address from caller, ensuring multiprofile compatibility. | 600 // Gets account id from the caller, ensuring multiprofile compatibility. |
| 599 const user_manager::User* user = GetUserFromBrowserContext(browser_context()); | 601 const user_manager::User* user = GetUserFromBrowserContext(browser_context()); |
| 600 user_id_ = user->email(); | 602 account_id_ = user->GetAccountId(); |
| 601 user_id_hash_ = user->username_hash(); | 603 user_id_hash_ = user->username_hash(); |
| 602 | 604 |
| 603 StartDecode(params->wallpaper); | 605 StartDecode(params->wallpaper); |
| 604 | 606 |
| 605 return true; | 607 return true; |
| 606 } | 608 } |
| 607 | 609 |
| 608 void WallpaperPrivateSetCustomWallpaperFunction::OnWallpaperDecoded( | 610 void WallpaperPrivateSetCustomWallpaperFunction::OnWallpaperDecoded( |
| 609 const gfx::ImageSkia& image) { | 611 const gfx::ImageSkia& image) { |
| 610 chromeos::WallpaperManager* wallpaper_manager = | 612 chromeos::WallpaperManager* wallpaper_manager = |
| 611 chromeos::WallpaperManager::Get(); | 613 chromeos::WallpaperManager::Get(); |
| 612 base::FilePath thumbnail_path = wallpaper_manager->GetCustomWallpaperPath( | 614 base::FilePath thumbnail_path = wallpaper_manager->GetCustomWallpaperPath( |
| 613 wallpaper::kThumbnailWallpaperSubDir, user_id_hash_, params->file_name); | 615 wallpaper::kThumbnailWallpaperSubDir, user_id_hash_, params->file_name); |
| 614 | 616 |
| 615 sequence_token_ = BrowserThread::GetBlockingPool()->GetNamedSequenceToken( | 617 sequence_token_ = BrowserThread::GetBlockingPool()->GetNamedSequenceToken( |
| 616 wallpaper::kWallpaperSequenceTokenName); | 618 wallpaper::kWallpaperSequenceTokenName); |
| 617 scoped_refptr<base::SequencedTaskRunner> task_runner = | 619 scoped_refptr<base::SequencedTaskRunner> task_runner = |
| 618 BrowserThread::GetBlockingPool()-> | 620 BrowserThread::GetBlockingPool()-> |
| 619 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, | 621 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, |
| 620 base::SequencedWorkerPool::BLOCK_SHUTDOWN); | 622 base::SequencedWorkerPool::BLOCK_SHUTDOWN); |
| 621 | 623 |
| 622 wallpaper::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( | 624 wallpaper::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( |
| 623 wallpaper_base::ToString(params->layout)); | 625 wallpaper_base::ToString(params->layout)); |
| 624 wallpaper_api_util::RecordCustomWallpaperLayout(layout); | 626 wallpaper_api_util::RecordCustomWallpaperLayout(layout); |
| 625 | 627 |
| 626 bool update_wallpaper = | 628 bool update_wallpaper = |
| 627 user_id_ == user_manager::UserManager::Get()->GetActiveUser()->email(); | 629 account_id_ == |
| 628 wallpaper_manager->SetCustomWallpaper(user_id_, | 630 user_manager::UserManager::Get()->GetActiveUser()->GetAccountId(); |
| 629 user_id_hash_, | 631 wallpaper_manager->SetCustomWallpaper( |
| 630 params->file_name, | 632 account_id_, user_id_hash_, params->file_name, layout, |
| 631 layout, | 633 user_manager::User::CUSTOMIZED, image, update_wallpaper); |
| 632 user_manager::User::CUSTOMIZED, | |
| 633 image, | |
| 634 update_wallpaper); | |
| 635 unsafe_wallpaper_decoder_ = NULL; | 634 unsafe_wallpaper_decoder_ = NULL; |
| 636 | 635 |
| 637 Profile* profile = Profile::FromBrowserContext(browser_context()); | 636 Profile* profile = Profile::FromBrowserContext(browser_context()); |
| 638 // This API is only available to the component wallpaper picker. We do not | 637 // This API is only available to the component wallpaper picker. We do not |
| 639 // need to show the app's name if it is the component wallpaper picker. So set | 638 // need to show the app's name if it is the component wallpaper picker. So set |
| 640 // the pref to empty string. | 639 // the pref to empty string. |
| 641 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, | 640 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, |
| 642 std::string()); | 641 std::string()); |
| 643 | 642 |
| 644 if (params->generate_thumbnail) { | 643 if (params->generate_thumbnail) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 wallpaper_manager->GetLoggedInUserWallpaperInfo(&info); | 698 wallpaper_manager->GetLoggedInUserWallpaperInfo(&info); |
| 700 if (info.type != user_manager::User::CUSTOMIZED) { | 699 if (info.type != user_manager::User::CUSTOMIZED) { |
| 701 SetError("Only custom wallpaper can change layout."); | 700 SetError("Only custom wallpaper can change layout."); |
| 702 SendResponse(false); | 701 SendResponse(false); |
| 703 return false; | 702 return false; |
| 704 } | 703 } |
| 705 info.layout = wallpaper_api_util::GetLayoutEnum( | 704 info.layout = wallpaper_api_util::GetLayoutEnum( |
| 706 wallpaper_base::ToString(params->layout)); | 705 wallpaper_base::ToString(params->layout)); |
| 707 wallpaper_api_util::RecordCustomWallpaperLayout(info.layout); | 706 wallpaper_api_util::RecordCustomWallpaperLayout(info.layout); |
| 708 | 707 |
| 709 std::string email = | 708 const AccountId& account_id = |
| 710 user_manager::UserManager::Get()->GetActiveUser()->email(); | 709 user_manager::UserManager::Get()->GetActiveUser()->GetAccountId(); |
| 711 bool is_persistent = !user_manager::UserManager::Get() | 710 bool is_persistent = !user_manager::UserManager::Get() |
| 712 ->IsCurrentUserNonCryptohomeDataEphemeral(); | 711 ->IsCurrentUserNonCryptohomeDataEphemeral(); |
| 713 wallpaper_manager->SetUserWallpaperInfo(email, info, is_persistent); | 712 wallpaper_manager->SetUserWallpaperInfo(account_id, info, is_persistent); |
| 714 wallpaper_manager->UpdateWallpaper(false /* clear_cache */); | 713 wallpaper_manager->UpdateWallpaper(false /* clear_cache */); |
| 715 SendResponse(true); | 714 SendResponse(true); |
| 716 | 715 |
| 717 // Gets email address while at UI thread. | |
| 718 return true; | 716 return true; |
| 719 } | 717 } |
| 720 | 718 |
| 721 WallpaperPrivateMinimizeInactiveWindowsFunction:: | 719 WallpaperPrivateMinimizeInactiveWindowsFunction:: |
| 722 WallpaperPrivateMinimizeInactiveWindowsFunction() { | 720 WallpaperPrivateMinimizeInactiveWindowsFunction() { |
| 723 } | 721 } |
| 724 | 722 |
| 725 WallpaperPrivateMinimizeInactiveWindowsFunction:: | 723 WallpaperPrivateMinimizeInactiveWindowsFunction:: |
| 726 ~WallpaperPrivateMinimizeInactiveWindowsFunction() { | 724 ~WallpaperPrivateMinimizeInactiveWindowsFunction() { |
| 727 } | 725 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 751 | 749 |
| 752 WallpaperPrivateGetThumbnailFunction::~WallpaperPrivateGetThumbnailFunction() { | 750 WallpaperPrivateGetThumbnailFunction::~WallpaperPrivateGetThumbnailFunction() { |
| 753 } | 751 } |
| 754 | 752 |
| 755 bool WallpaperPrivateGetThumbnailFunction::RunAsync() { | 753 bool WallpaperPrivateGetThumbnailFunction::RunAsync() { |
| 756 scoped_ptr<get_thumbnail::Params> params( | 754 scoped_ptr<get_thumbnail::Params> params( |
| 757 get_thumbnail::Params::Create(*args_)); | 755 get_thumbnail::Params::Create(*args_)); |
| 758 EXTENSION_FUNCTION_VALIDATE(params); | 756 EXTENSION_FUNCTION_VALIDATE(params); |
| 759 | 757 |
| 760 base::FilePath thumbnail_path; | 758 base::FilePath thumbnail_path; |
| 761 std::string email = | |
| 762 user_manager::UserManager::Get()->GetActiveUser()->email(); | |
| 763 if (params->source == wallpaper_private::WALLPAPER_SOURCE_ONLINE) { | 759 if (params->source == wallpaper_private::WALLPAPER_SOURCE_ONLINE) { |
| 764 std::string file_name = GURL(params->url_or_file).ExtractFileName(); | 760 std::string file_name = GURL(params->url_or_file).ExtractFileName(); |
| 765 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPER_THUMBNAILS, | 761 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPER_THUMBNAILS, |
| 766 &thumbnail_path)); | 762 &thumbnail_path)); |
| 767 thumbnail_path = thumbnail_path.Append(file_name); | 763 thumbnail_path = thumbnail_path.Append(file_name); |
| 768 } else { | 764 } else { |
| 769 if (!IsOEMDefaultWallpaper()) { | 765 if (!IsOEMDefaultWallpaper()) { |
| 770 SetError("No OEM wallpaper."); | 766 SetError("No OEM wallpaper."); |
| 771 SendResponse(false); | 767 SendResponse(false); |
| 772 return false; | 768 return false; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 this, file_list)); | 927 this, file_list)); |
| 932 } | 928 } |
| 933 | 929 |
| 934 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( | 930 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( |
| 935 const std::vector<std::string>& file_list) { | 931 const std::vector<std::string>& file_list) { |
| 936 base::ListValue* results = new base::ListValue(); | 932 base::ListValue* results = new base::ListValue(); |
| 937 results->AppendStrings(file_list); | 933 results->AppendStrings(file_list); |
| 938 SetResult(results); | 934 SetResult(results); |
| 939 SendResponse(true); | 935 SendResponse(true); |
| 940 } | 936 } |
| OLD | NEW |