Chromium Code Reviews| 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 17 matching lines...) Expand all Loading... | |
| 28 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 28 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 29 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 29 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 30 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 31 #include "chrome/browser/sync/profile_sync_service.h" | 31 #include "chrome/browser/sync/profile_sync_service.h" |
| 32 #include "chrome/browser/sync/profile_sync_service_factory.h" | 32 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 33 #include "chrome/common/chrome_paths.h" | 33 #include "chrome/common/chrome_paths.h" |
| 34 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
| 35 #include "chrome/grit/generated_resources.h" | 35 #include "chrome/grit/generated_resources.h" |
| 36 #include "chromeos/chromeos_switches.h" | 36 #include "chromeos/chromeos_switches.h" |
| 37 #include "components/user_manager/user.h" | 37 #include "components/user_manager/user.h" |
| 38 #include "components/user_manager/user_id.h" | |
| 38 #include "components/user_manager/user_manager.h" | 39 #include "components/user_manager/user_manager.h" |
| 39 #include "components/wallpaper/wallpaper_layout.h" | 40 #include "components/wallpaper/wallpaper_layout.h" |
| 40 #include "content/public/browser/browser_thread.h" | 41 #include "content/public/browser/browser_thread.h" |
| 41 #include "extensions/browser/event_router.h" | 42 #include "extensions/browser/event_router.h" |
| 42 #include "grit/components_strings.h" | 43 #include "grit/components_strings.h" |
| 43 #include "ui/base/l10n/l10n_util.h" | 44 #include "ui/base/l10n/l10n_util.h" |
| 44 #include "ui/base/webui/web_ui_util.h" | 45 #include "ui/base/webui/web_ui_util.h" |
| 45 #include "ui/strings/grit/app_locale_settings.h" | 46 #include "ui/strings/grit/app_locale_settings.h" |
| 46 #include "url/gurl.h" | 47 #include "url/gurl.h" |
| 47 | 48 |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 ProfileSyncService* sync = | 334 ProfileSyncService* sync = |
| 334 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); | 335 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); |
| 335 base::DictionaryValue* dict = new base::DictionaryValue(); | 336 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 336 SetResult(dict); | 337 SetResult(dict); |
| 337 dict->SetBoolean("syncThemes", | 338 dict->SetBoolean("syncThemes", |
| 338 sync->GetActiveDataTypes().Has(syncer::THEMES)); | 339 sync->GetActiveDataTypes().Has(syncer::THEMES)); |
| 339 return true; | 340 return true; |
| 340 } | 341 } |
| 341 | 342 |
| 342 WallpaperPrivateSetWallpaperIfExistsFunction:: | 343 WallpaperPrivateSetWallpaperIfExistsFunction:: |
| 343 WallpaperPrivateSetWallpaperIfExistsFunction() {} | 344 WallpaperPrivateSetWallpaperIfExistsFunction() : user_id_(std::string(), std ::string()) {} |
|
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:45
EmptyUserID() ?
| |
| 344 | 345 |
| 345 WallpaperPrivateSetWallpaperIfExistsFunction:: | 346 WallpaperPrivateSetWallpaperIfExistsFunction:: |
| 346 ~WallpaperPrivateSetWallpaperIfExistsFunction() {} | 347 ~WallpaperPrivateSetWallpaperIfExistsFunction() {} |
| 347 | 348 |
| 348 bool WallpaperPrivateSetWallpaperIfExistsFunction::RunAsync() { | 349 bool WallpaperPrivateSetWallpaperIfExistsFunction::RunAsync() { |
| 349 params = set_wallpaper_if_exists::Params::Create(*args_); | 350 params = set_wallpaper_if_exists::Params::Create(*args_); |
| 350 EXTENSION_FUNCTION_VALIDATE(params); | 351 EXTENSION_FUNCTION_VALIDATE(params); |
| 351 | 352 |
| 352 // Gets email address from caller, ensuring multiprofile compatibility. | 353 // Gets User ID from caller, ensuring multiprofile compatibility. |
| 353 const user_manager::User* user = GetUserFromBrowserContext(browser_context()); | 354 const user_manager::User* user = GetUserFromBrowserContext(browser_context()); |
| 354 user_id_ = user->email(); | 355 user_id_ = user->GetUserID(); |
| 355 | 356 |
| 356 base::FilePath wallpaper_path; | 357 base::FilePath wallpaper_path; |
| 357 base::FilePath fallback_path; | 358 base::FilePath fallback_path; |
| 358 chromeos::WallpaperManager::WallpaperResolution resolution = | 359 chromeos::WallpaperManager::WallpaperResolution resolution = |
| 359 chromeos::WallpaperManager::Get()->GetAppropriateResolution(); | 360 chromeos::WallpaperManager::Get()->GetAppropriateResolution(); |
| 360 | 361 |
| 361 std::string file_name = GURL(params->url).ExtractFileName(); | 362 std::string file_name = GURL(params->url).ExtractFileName(); |
| 362 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPERS, | 363 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPERS, |
| 363 &wallpaper_path)); | 364 &wallpaper_path)); |
| 364 fallback_path = wallpaper_path.Append(file_name); | 365 fallback_path = wallpaper_path.Append(file_name); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 417 const gfx::ImageSkia& image) { | 418 const gfx::ImageSkia& image) { |
| 418 // Set unsafe_wallpaper_decoder_ to null since the decoding already finished. | 419 // Set unsafe_wallpaper_decoder_ to null since the decoding already finished. |
| 419 unsafe_wallpaper_decoder_ = NULL; | 420 unsafe_wallpaper_decoder_ = NULL; |
| 420 | 421 |
| 421 chromeos::WallpaperManager* wallpaper_manager = | 422 chromeos::WallpaperManager* wallpaper_manager = |
| 422 chromeos::WallpaperManager::Get(); | 423 chromeos::WallpaperManager::Get(); |
| 423 wallpaper::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( | 424 wallpaper::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( |
| 424 wallpaper_base::ToString(params->layout)); | 425 wallpaper_base::ToString(params->layout)); |
| 425 | 426 |
| 426 bool update_wallpaper = | 427 bool update_wallpaper = |
| 427 user_id_ == user_manager::UserManager::Get()->GetActiveUser()->email(); | 428 user_id_ == user_manager::UserManager::Get()->GetActiveUser()->GetUserID() ; |
| 428 wallpaper_manager->SetWallpaperFromImageSkia( | 429 wallpaper_manager->SetWallpaperFromImageSkia( |
| 429 user_id_, image, layout, update_wallpaper); | 430 user_id_, image, layout, update_wallpaper); |
| 430 bool is_persistent = !user_manager::UserManager::Get() | 431 bool is_persistent = !user_manager::UserManager::Get() |
| 431 ->IsCurrentUserNonCryptohomeDataEphemeral(); | 432 ->IsCurrentUserNonCryptohomeDataEphemeral(); |
| 432 wallpaper::WallpaperInfo info = {params->url, | 433 wallpaper::WallpaperInfo info = {params->url, |
| 433 layout, | 434 layout, |
| 434 user_manager::User::ONLINE, | 435 user_manager::User::ONLINE, |
| 435 base::Time::Now().LocalMidnight()}; | 436 base::Time::Now().LocalMidnight()}; |
| 436 wallpaper_manager->SetUserWallpaperInfo(user_id_, info, is_persistent); | 437 wallpaper_manager->SetUserWallpaperInfo(user_id_, info, is_persistent); |
| 437 SetResult(new base::FundamentalValue(true)); | 438 SetResult(new base::FundamentalValue(true)); |
| 438 Profile* profile = Profile::FromBrowserContext(browser_context()); | 439 Profile* profile = Profile::FromBrowserContext(browser_context()); |
| 439 // This API is only available to the component wallpaper picker. We do not | 440 // This API is only available to the component wallpaper picker. We do not |
| 440 // need to show the app's name if it is the component wallpaper picker. So set | 441 // need to show the app's name if it is the component wallpaper picker. So set |
| 441 // the pref to empty string. | 442 // the pref to empty string. |
| 442 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, | 443 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, |
| 443 std::string()); | 444 std::string()); |
| 444 SendResponse(true); | 445 SendResponse(true); |
| 445 } | 446 } |
| 446 | 447 |
| 447 void WallpaperPrivateSetWallpaperIfExistsFunction::OnFileNotExists( | 448 void WallpaperPrivateSetWallpaperIfExistsFunction::OnFileNotExists( |
| 448 const std::string& error) { | 449 const std::string& error) { |
| 449 SetResult(new base::FundamentalValue(false)); | 450 SetResult(new base::FundamentalValue(false)); |
| 450 OnFailure(error); | 451 OnFailure(error); |
| 451 } | 452 } |
| 452 | 453 |
| 453 WallpaperPrivateSetWallpaperFunction::WallpaperPrivateSetWallpaperFunction() { | 454 WallpaperPrivateSetWallpaperFunction::WallpaperPrivateSetWallpaperFunction() : u ser_id_(std::string(), std::string()) { |
|
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:46
EmptyUserID() ?
| |
| 454 } | 455 } |
| 455 | 456 |
| 456 WallpaperPrivateSetWallpaperFunction::~WallpaperPrivateSetWallpaperFunction() { | 457 WallpaperPrivateSetWallpaperFunction::~WallpaperPrivateSetWallpaperFunction() { |
| 457 } | 458 } |
| 458 | 459 |
| 459 bool WallpaperPrivateSetWallpaperFunction::RunAsync() { | 460 bool WallpaperPrivateSetWallpaperFunction::RunAsync() { |
| 460 params = set_wallpaper::Params::Create(*args_); | 461 params = set_wallpaper::Params::Create(*args_); |
| 461 EXTENSION_FUNCTION_VALIDATE(params); | 462 EXTENSION_FUNCTION_VALIDATE(params); |
| 462 | 463 |
| 463 // Gets email address from caller, ensuring multiprofile compatibility. | 464 // Gets user ID address from caller, ensuring multiprofile compatibility. |
| 464 const user_manager::User* user = GetUserFromBrowserContext(browser_context()); | 465 const user_manager::User* user = GetUserFromBrowserContext(browser_context()); |
| 465 user_id_ = user->email(); | 466 user_id_ = user->GetUserID(); |
| 466 | 467 |
| 467 StartDecode(params->wallpaper); | 468 StartDecode(params->wallpaper); |
| 468 | 469 |
| 469 return true; | 470 return true; |
| 470 } | 471 } |
| 471 | 472 |
| 472 void WallpaperPrivateSetWallpaperFunction::OnWallpaperDecoded( | 473 void WallpaperPrivateSetWallpaperFunction::OnWallpaperDecoded( |
| 473 const gfx::ImageSkia& image) { | 474 const gfx::ImageSkia& image) { |
| 474 wallpaper_ = image; | 475 wallpaper_ = image; |
| 475 // Set unsafe_wallpaper_decoder_ to null since the decoding already finished. | 476 // Set unsafe_wallpaper_decoder_ to null since the decoding already finished. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 527 | 528 |
| 528 void WallpaperPrivateSetWallpaperFunction::SetDecodedWallpaper( | 529 void WallpaperPrivateSetWallpaperFunction::SetDecodedWallpaper( |
| 529 scoped_ptr<gfx::ImageSkia> image) { | 530 scoped_ptr<gfx::ImageSkia> image) { |
| 530 chromeos::WallpaperManager* wallpaper_manager = | 531 chromeos::WallpaperManager* wallpaper_manager = |
| 531 chromeos::WallpaperManager::Get(); | 532 chromeos::WallpaperManager::Get(); |
| 532 | 533 |
| 533 wallpaper::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( | 534 wallpaper::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( |
| 534 wallpaper_base::ToString(params->layout)); | 535 wallpaper_base::ToString(params->layout)); |
| 535 | 536 |
| 536 bool update_wallpaper = | 537 bool update_wallpaper = |
| 537 user_id_ == user_manager::UserManager::Get()->GetActiveUser()->email(); | 538 user_id_ == user_manager::UserManager::Get()->GetActiveUser()->GetUserID() ; |
| 538 wallpaper_manager->SetWallpaperFromImageSkia( | 539 wallpaper_manager->SetWallpaperFromImageSkia( |
| 539 user_id_, *image.get(), layout, update_wallpaper); | 540 user_id_, *image.get(), layout, update_wallpaper); |
| 540 | 541 |
| 541 bool is_persistent = !user_manager::UserManager::Get() | 542 bool is_persistent = !user_manager::UserManager::Get() |
| 542 ->IsCurrentUserNonCryptohomeDataEphemeral(); | 543 ->IsCurrentUserNonCryptohomeDataEphemeral(); |
| 543 wallpaper::WallpaperInfo info = {params->url, | 544 wallpaper::WallpaperInfo info = {params->url, |
| 544 layout, | 545 layout, |
| 545 user_manager::User::ONLINE, | 546 user_manager::User::ONLINE, |
| 546 base::Time::Now().LocalMidnight()}; | 547 base::Time::Now().LocalMidnight()}; |
| 547 Profile* profile = Profile::FromBrowserContext(browser_context()); | 548 Profile* profile = Profile::FromBrowserContext(browser_context()); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 558 WallpaperPrivateResetWallpaperFunction() {} | 559 WallpaperPrivateResetWallpaperFunction() {} |
| 559 | 560 |
| 560 WallpaperPrivateResetWallpaperFunction:: | 561 WallpaperPrivateResetWallpaperFunction:: |
| 561 ~WallpaperPrivateResetWallpaperFunction() {} | 562 ~WallpaperPrivateResetWallpaperFunction() {} |
| 562 | 563 |
| 563 bool WallpaperPrivateResetWallpaperFunction::RunAsync() { | 564 bool WallpaperPrivateResetWallpaperFunction::RunAsync() { |
| 564 chromeos::WallpaperManager* wallpaper_manager = | 565 chromeos::WallpaperManager* wallpaper_manager = |
| 565 chromeos::WallpaperManager::Get(); | 566 chromeos::WallpaperManager::Get(); |
| 566 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 567 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 567 | 568 |
| 568 std::string user_id = user_manager->GetActiveUser()->email(); | 569 user_manager::UserID user_id = user_manager->GetActiveUser()->GetUserID(); |
| 569 wallpaper_manager->RemoveUserWallpaperInfo(user_id); | 570 wallpaper_manager->RemoveUserWallpaperInfo(user_id); |
| 570 | 571 |
| 571 wallpaper::WallpaperInfo info = {std::string(), | 572 wallpaper::WallpaperInfo info = {std::string(), |
| 572 wallpaper::WALLPAPER_LAYOUT_CENTER, | 573 wallpaper::WALLPAPER_LAYOUT_CENTER, |
| 573 user_manager::User::DEFAULT, | 574 user_manager::User::DEFAULT, |
| 574 base::Time::Now().LocalMidnight()}; | 575 base::Time::Now().LocalMidnight()}; |
| 575 bool is_persistent = | 576 bool is_persistent = |
| 576 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); | 577 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); |
| 577 wallpaper_manager->SetUserWallpaperInfo(user_id, info, is_persistent); | 578 wallpaper_manager->SetUserWallpaperInfo(user_id, info, is_persistent); |
| 578 | 579 |
| 579 wallpaper_manager->SetDefaultWallpaperNow(user_id); | 580 wallpaper_manager->SetDefaultWallpaperNow(user_id); |
| 580 Profile* profile = Profile::FromBrowserContext(browser_context()); | 581 Profile* profile = Profile::FromBrowserContext(browser_context()); |
| 581 // 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 |
| 582 // 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 |
| 583 // the pref to empty string. | 584 // the pref to empty string. |
| 584 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, | 585 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, |
| 585 std::string()); | 586 std::string()); |
| 586 return true; | 587 return true; |
| 587 } | 588 } |
| 588 | 589 |
| 589 WallpaperPrivateSetCustomWallpaperFunction:: | 590 WallpaperPrivateSetCustomWallpaperFunction:: |
| 590 WallpaperPrivateSetCustomWallpaperFunction() {} | 591 WallpaperPrivateSetCustomWallpaperFunction() : user_id_(std::string(), std:: string()) {} |
|
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:45
EmptyUserID() ?
| |
| 591 | 592 |
| 592 WallpaperPrivateSetCustomWallpaperFunction:: | 593 WallpaperPrivateSetCustomWallpaperFunction:: |
| 593 ~WallpaperPrivateSetCustomWallpaperFunction() {} | 594 ~WallpaperPrivateSetCustomWallpaperFunction() {} |
| 594 | 595 |
| 595 bool WallpaperPrivateSetCustomWallpaperFunction::RunAsync() { | 596 bool WallpaperPrivateSetCustomWallpaperFunction::RunAsync() { |
| 596 params = set_custom_wallpaper::Params::Create(*args_); | 597 params = set_custom_wallpaper::Params::Create(*args_); |
| 597 EXTENSION_FUNCTION_VALIDATE(params); | 598 EXTENSION_FUNCTION_VALIDATE(params); |
| 598 | 599 |
| 599 // Gets email address from caller, ensuring multiprofile compatibility. | 600 // Gets User ID from caller, ensuring multiprofile compatibility. |
| 600 const user_manager::User* user = GetUserFromBrowserContext(browser_context()); | 601 const user_manager::User* user = GetUserFromBrowserContext(browser_context()); |
| 601 user_id_ = user->email(); | 602 user_id_ = user->GetUserID(); |
| 602 user_id_hash_ = user->username_hash(); | 603 user_id_hash_ = user->username_hash(); |
| 603 | 604 |
| 604 StartDecode(params->wallpaper); | 605 StartDecode(params->wallpaper); |
| 605 | 606 |
| 606 return true; | 607 return true; |
| 607 } | 608 } |
| 608 | 609 |
| 609 void WallpaperPrivateSetCustomWallpaperFunction::OnWallpaperDecoded( | 610 void WallpaperPrivateSetCustomWallpaperFunction::OnWallpaperDecoded( |
| 610 const gfx::ImageSkia& image) { | 611 const gfx::ImageSkia& image) { |
| 611 chromeos::WallpaperManager* wallpaper_manager = | 612 chromeos::WallpaperManager* wallpaper_manager = |
| 612 chromeos::WallpaperManager::Get(); | 613 chromeos::WallpaperManager::Get(); |
| 613 base::FilePath thumbnail_path = wallpaper_manager->GetCustomWallpaperPath( | 614 base::FilePath thumbnail_path = wallpaper_manager->GetCustomWallpaperPath( |
| 614 wallpaper::kThumbnailWallpaperSubDir, user_id_hash_, params->file_name); | 615 wallpaper::kThumbnailWallpaperSubDir, user_id_hash_, params->file_name); |
| 615 | 616 |
| 616 sequence_token_ = BrowserThread::GetBlockingPool()->GetNamedSequenceToken( | 617 sequence_token_ = BrowserThread::GetBlockingPool()->GetNamedSequenceToken( |
| 617 wallpaper::kWallpaperSequenceTokenName); | 618 wallpaper::kWallpaperSequenceTokenName); |
| 618 scoped_refptr<base::SequencedTaskRunner> task_runner = | 619 scoped_refptr<base::SequencedTaskRunner> task_runner = |
| 619 BrowserThread::GetBlockingPool()-> | 620 BrowserThread::GetBlockingPool()-> |
| 620 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, | 621 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, |
| 621 base::SequencedWorkerPool::BLOCK_SHUTDOWN); | 622 base::SequencedWorkerPool::BLOCK_SHUTDOWN); |
| 622 | 623 |
| 623 wallpaper::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( | 624 wallpaper::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( |
| 624 wallpaper_base::ToString(params->layout)); | 625 wallpaper_base::ToString(params->layout)); |
| 625 | 626 |
| 626 bool update_wallpaper = | 627 bool update_wallpaper = |
| 627 user_id_ == user_manager::UserManager::Get()->GetActiveUser()->email(); | 628 user_id_ == user_manager::UserManager::Get()->GetActiveUser()->GetUserID() ; |
| 628 wallpaper_manager->SetCustomWallpaper(user_id_, | 629 wallpaper_manager->SetCustomWallpaper(user_id_, |
| 629 user_id_hash_, | 630 user_id_hash_, |
| 630 params->file_name, | 631 params->file_name, |
| 631 layout, | 632 layout, |
| 632 user_manager::User::CUSTOMIZED, | 633 user_manager::User::CUSTOMIZED, |
| 633 image, | 634 image, |
| 634 update_wallpaper); | 635 update_wallpaper); |
| 635 unsafe_wallpaper_decoder_ = NULL; | 636 unsafe_wallpaper_decoder_ = NULL; |
| 636 | 637 |
| 637 Profile* profile = Profile::FromBrowserContext(browser_context()); | 638 Profile* profile = Profile::FromBrowserContext(browser_context()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 698 wallpaper::WallpaperInfo info; | 699 wallpaper::WallpaperInfo info; |
| 699 wallpaper_manager->GetLoggedInUserWallpaperInfo(&info); | 700 wallpaper_manager->GetLoggedInUserWallpaperInfo(&info); |
| 700 if (info.type != user_manager::User::CUSTOMIZED) { | 701 if (info.type != user_manager::User::CUSTOMIZED) { |
| 701 SetError("Only custom wallpaper can change layout."); | 702 SetError("Only custom wallpaper can change layout."); |
| 702 SendResponse(false); | 703 SendResponse(false); |
| 703 return false; | 704 return false; |
| 704 } | 705 } |
| 705 info.layout = wallpaper_api_util::GetLayoutEnum( | 706 info.layout = wallpaper_api_util::GetLayoutEnum( |
| 706 wallpaper_base::ToString(params->layout)); | 707 wallpaper_base::ToString(params->layout)); |
| 707 | 708 |
| 708 std::string email = | 709 const user_manager::UserID user_id = |
| 709 user_manager::UserManager::Get()->GetActiveUser()->email(); | 710 user_manager::UserManager::Get()->GetActiveUser()->GetUserID(); |
| 710 bool is_persistent = !user_manager::UserManager::Get() | 711 bool is_persistent = !user_manager::UserManager::Get() |
| 711 ->IsCurrentUserNonCryptohomeDataEphemeral(); | 712 ->IsCurrentUserNonCryptohomeDataEphemeral(); |
| 712 wallpaper_manager->SetUserWallpaperInfo(email, info, is_persistent); | 713 wallpaper_manager->SetUserWallpaperInfo(user_id, info, is_persistent); |
| 713 wallpaper_manager->UpdateWallpaper(false /* clear_cache */); | 714 wallpaper_manager->UpdateWallpaper(false /* clear_cache */); |
| 714 SendResponse(true); | 715 SendResponse(true); |
| 715 | 716 |
| 716 // Gets email address while at UI thread. | 717 // Gets email address while at UI thread. |
| 717 return true; | 718 return true; |
| 718 } | 719 } |
| 719 | 720 |
| 720 WallpaperPrivateMinimizeInactiveWindowsFunction:: | 721 WallpaperPrivateMinimizeInactiveWindowsFunction:: |
| 721 WallpaperPrivateMinimizeInactiveWindowsFunction() { | 722 WallpaperPrivateMinimizeInactiveWindowsFunction() { |
| 722 } | 723 } |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 750 | 751 |
| 751 WallpaperPrivateGetThumbnailFunction::~WallpaperPrivateGetThumbnailFunction() { | 752 WallpaperPrivateGetThumbnailFunction::~WallpaperPrivateGetThumbnailFunction() { |
| 752 } | 753 } |
| 753 | 754 |
| 754 bool WallpaperPrivateGetThumbnailFunction::RunAsync() { | 755 bool WallpaperPrivateGetThumbnailFunction::RunAsync() { |
| 755 scoped_ptr<get_thumbnail::Params> params( | 756 scoped_ptr<get_thumbnail::Params> params( |
| 756 get_thumbnail::Params::Create(*args_)); | 757 get_thumbnail::Params::Create(*args_)); |
| 757 EXTENSION_FUNCTION_VALIDATE(params); | 758 EXTENSION_FUNCTION_VALIDATE(params); |
| 758 | 759 |
| 759 base::FilePath thumbnail_path; | 760 base::FilePath thumbnail_path; |
| 760 std::string email = | |
| 761 user_manager::UserManager::Get()->GetActiveUser()->email(); | |
| 762 if (params->source == wallpaper_private::WALLPAPER_SOURCE_ONLINE) { | 761 if (params->source == wallpaper_private::WALLPAPER_SOURCE_ONLINE) { |
| 763 std::string file_name = GURL(params->url_or_file).ExtractFileName(); | 762 std::string file_name = GURL(params->url_or_file).ExtractFileName(); |
| 764 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPER_THUMBNAILS, | 763 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPER_THUMBNAILS, |
| 765 &thumbnail_path)); | 764 &thumbnail_path)); |
| 766 thumbnail_path = thumbnail_path.Append(file_name); | 765 thumbnail_path = thumbnail_path.Append(file_name); |
| 767 } else { | 766 } else { |
| 768 if (!IsOEMDefaultWallpaper()) { | 767 if (!IsOEMDefaultWallpaper()) { |
| 769 SetError("No OEM wallpaper."); | 768 SetError("No OEM wallpaper."); |
| 770 SendResponse(false); | 769 SendResponse(false); |
| 771 return false; | 770 return false; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 929 this, file_list)); | 928 this, file_list)); |
| 930 } | 929 } |
| 931 | 930 |
| 932 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( | 931 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( |
| 933 const std::vector<std::string>& file_list) { | 932 const std::vector<std::string>& file_list) { |
| 934 base::ListValue* results = new base::ListValue(); | 933 base::ListValue* results = new base::ListValue(); |
| 935 results->AppendStrings(file_list); | 934 results->AppendStrings(file_list); |
| 936 SetResult(results); | 935 SetResult(results); |
| 937 SendResponse(true); | 936 SendResponse(true); |
| 938 } | 937 } |
| OLD | NEW |