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 <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_manager.h" | |
26 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 25 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
27 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
28 #include "chrome/common/chrome_paths.h" | 27 #include "chrome/common/chrome_paths.h" |
29 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
30 #include "chrome/grit/generated_resources.h" | 29 #include "chrome/grit/generated_resources.h" |
31 #include "chrome/grit/platform_locale_settings.h" | 30 #include "chrome/grit/platform_locale_settings.h" |
32 #include "components/user_manager/user.h" | 31 #include "components/user_manager/user.h" |
| 32 #include "components/user_manager/user_manager.h" |
33 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
34 #include "extensions/browser/event_router.h" | 34 #include "extensions/browser/event_router.h" |
35 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
36 #include "ui/base/webui/web_ui_util.h" | 36 #include "ui/base/webui/web_ui_util.h" |
37 #include "ui/strings/grit/app_locale_settings.h" | 37 #include "ui/strings/grit/app_locale_settings.h" |
38 #include "url/gurl.h" | 38 #include "url/gurl.h" |
39 | 39 |
40 using base::BinaryValue; | 40 using base::BinaryValue; |
41 using content::BrowserThread; | 41 using content::BrowserThread; |
42 namespace wallpaper_private = extensions::api::wallpaper_private; | 42 namespace wallpaper_private = extensions::api::wallpaper_private; |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 WallpaperPrivateSetWallpaperIfExistsFunction:: | 294 WallpaperPrivateSetWallpaperIfExistsFunction:: |
295 WallpaperPrivateSetWallpaperIfExistsFunction() {} | 295 WallpaperPrivateSetWallpaperIfExistsFunction() {} |
296 | 296 |
297 WallpaperPrivateSetWallpaperIfExistsFunction:: | 297 WallpaperPrivateSetWallpaperIfExistsFunction:: |
298 ~WallpaperPrivateSetWallpaperIfExistsFunction() {} | 298 ~WallpaperPrivateSetWallpaperIfExistsFunction() {} |
299 | 299 |
300 bool WallpaperPrivateSetWallpaperIfExistsFunction::RunAsync() { | 300 bool WallpaperPrivateSetWallpaperIfExistsFunction::RunAsync() { |
301 params = set_wallpaper_if_exists::Params::Create(*args_); | 301 params = set_wallpaper_if_exists::Params::Create(*args_); |
302 EXTENSION_FUNCTION_VALIDATE(params); | 302 EXTENSION_FUNCTION_VALIDATE(params); |
303 | 303 |
304 user_id_ = chromeos::UserManager::Get()->GetActiveUser()->email(); | 304 user_id_ = user_manager::UserManager::Get()->GetActiveUser()->email(); |
305 | 305 |
306 base::FilePath wallpaper_path; | 306 base::FilePath wallpaper_path; |
307 base::FilePath fallback_path; | 307 base::FilePath fallback_path; |
308 chromeos::WallpaperManager::WallpaperResolution resolution = | 308 chromeos::WallpaperManager::WallpaperResolution resolution = |
309 chromeos::WallpaperManager::GetAppropriateResolution(); | 309 chromeos::WallpaperManager::GetAppropriateResolution(); |
310 | 310 |
311 std::string file_name = GURL(params->url).ExtractFileName(); | 311 std::string file_name = GURL(params->url).ExtractFileName(); |
312 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPERS, | 312 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPERS, |
313 &wallpaper_path)); | 313 &wallpaper_path)); |
314 fallback_path = wallpaper_path.Append(file_name); | 314 fallback_path = wallpaper_path.Append(file_name); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 const gfx::ImageSkia& image) { | 365 const gfx::ImageSkia& image) { |
366 // Set unsafe_wallpaper_decoder_ to null since the decoding already finished. | 366 // Set unsafe_wallpaper_decoder_ to null since the decoding already finished. |
367 unsafe_wallpaper_decoder_ = NULL; | 367 unsafe_wallpaper_decoder_ = NULL; |
368 | 368 |
369 chromeos::WallpaperManager* wallpaper_manager = | 369 chromeos::WallpaperManager* wallpaper_manager = |
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_ == user_manager::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 = !user_manager::UserManager::Get() |
379 !chromeos::UserManager::Get()->IsCurrentUserNonCryptohomeDataEphemeral(); | 379 ->IsCurrentUserNonCryptohomeDataEphemeral(); |
380 chromeos::WallpaperInfo info = {params->url, layout, | 380 chromeos::WallpaperInfo info = {params->url, layout, |
381 user_manager::User::ONLINE, | 381 user_manager::User::ONLINE, |
382 base::Time::Now().LocalMidnight()}; | 382 base::Time::Now().LocalMidnight()}; |
383 wallpaper_manager->SetUserWallpaperInfo(user_id_, info, is_persistent); | 383 wallpaper_manager->SetUserWallpaperInfo(user_id_, info, is_persistent); |
384 SetResult(new base::FundamentalValue(true)); | 384 SetResult(new base::FundamentalValue(true)); |
385 Profile* profile = Profile::FromBrowserContext(browser_context()); | 385 Profile* profile = Profile::FromBrowserContext(browser_context()); |
386 // 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 |
387 // 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 |
388 // the pref to empty string. | 388 // the pref to empty string. |
389 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, | 389 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, |
(...skipping 11 matching lines...) Expand all Loading... |
401 } | 401 } |
402 | 402 |
403 WallpaperPrivateSetWallpaperFunction::~WallpaperPrivateSetWallpaperFunction() { | 403 WallpaperPrivateSetWallpaperFunction::~WallpaperPrivateSetWallpaperFunction() { |
404 } | 404 } |
405 | 405 |
406 bool WallpaperPrivateSetWallpaperFunction::RunAsync() { | 406 bool WallpaperPrivateSetWallpaperFunction::RunAsync() { |
407 params = set_wallpaper::Params::Create(*args_); | 407 params = set_wallpaper::Params::Create(*args_); |
408 EXTENSION_FUNCTION_VALIDATE(params); | 408 EXTENSION_FUNCTION_VALIDATE(params); |
409 | 409 |
410 // Gets email address while at UI thread. | 410 // Gets email address while at UI thread. |
411 user_id_ = chromeos::UserManager::Get()->GetActiveUser()->email(); | 411 user_id_ = user_manager::UserManager::Get()->GetActiveUser()->email(); |
412 | 412 |
413 StartDecode(params->wallpaper); | 413 StartDecode(params->wallpaper); |
414 | 414 |
415 return true; | 415 return true; |
416 } | 416 } |
417 | 417 |
418 void WallpaperPrivateSetWallpaperFunction::OnWallpaperDecoded( | 418 void WallpaperPrivateSetWallpaperFunction::OnWallpaperDecoded( |
419 const gfx::ImageSkia& image) { | 419 const gfx::ImageSkia& image) { |
420 wallpaper_ = image; | 420 wallpaper_ = image; |
421 // Set unsafe_wallpaper_decoder_ to null since the decoding already finished. | 421 // Set unsafe_wallpaper_decoder_ to null since the decoding already finished. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 | 475 |
476 void WallpaperPrivateSetWallpaperFunction::SetDecodedWallpaper( | 476 void WallpaperPrivateSetWallpaperFunction::SetDecodedWallpaper( |
477 scoped_ptr<gfx::ImageSkia> image) { | 477 scoped_ptr<gfx::ImageSkia> image) { |
478 chromeos::WallpaperManager* wallpaper_manager = | 478 chromeos::WallpaperManager* wallpaper_manager = |
479 chromeos::WallpaperManager::Get(); | 479 chromeos::WallpaperManager::Get(); |
480 | 480 |
481 ash::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( | 481 ash::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( |
482 wallpaper_private::ToString(params->layout)); | 482 wallpaper_private::ToString(params->layout)); |
483 | 483 |
484 bool update_wallpaper = | 484 bool update_wallpaper = |
485 user_id_ == chromeos::UserManager::Get()->GetActiveUser()->email(); | 485 user_id_ == user_manager::UserManager::Get()->GetActiveUser()->email(); |
486 wallpaper_manager->SetWallpaperFromImageSkia( | 486 wallpaper_manager->SetWallpaperFromImageSkia( |
487 user_id_, *image.get(), layout, update_wallpaper); | 487 user_id_, *image.get(), layout, update_wallpaper); |
488 | 488 |
489 bool is_persistent = | 489 bool is_persistent = !user_manager::UserManager::Get() |
490 !chromeos::UserManager::Get()->IsCurrentUserNonCryptohomeDataEphemeral(); | 490 ->IsCurrentUserNonCryptohomeDataEphemeral(); |
491 chromeos::WallpaperInfo info = {params->url, layout, | 491 chromeos::WallpaperInfo info = {params->url, layout, |
492 user_manager::User::ONLINE, | 492 user_manager::User::ONLINE, |
493 base::Time::Now().LocalMidnight()}; | 493 base::Time::Now().LocalMidnight()}; |
494 Profile* profile = Profile::FromBrowserContext(browser_context()); | 494 Profile* profile = Profile::FromBrowserContext(browser_context()); |
495 // 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 |
496 // 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 |
497 // the pref to empty string. | 497 // the pref to empty string. |
498 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, | 498 profile->GetPrefs()->SetString(prefs::kCurrentWallpaperAppName, |
499 std::string()); | 499 std::string()); |
500 wallpaper_manager->SetUserWallpaperInfo(user_id_, info, is_persistent); | 500 wallpaper_manager->SetUserWallpaperInfo(user_id_, info, is_persistent); |
501 SendResponse(true); | 501 SendResponse(true); |
502 } | 502 } |
503 | 503 |
504 WallpaperPrivateResetWallpaperFunction:: | 504 WallpaperPrivateResetWallpaperFunction:: |
505 WallpaperPrivateResetWallpaperFunction() {} | 505 WallpaperPrivateResetWallpaperFunction() {} |
506 | 506 |
507 WallpaperPrivateResetWallpaperFunction:: | 507 WallpaperPrivateResetWallpaperFunction:: |
508 ~WallpaperPrivateResetWallpaperFunction() {} | 508 ~WallpaperPrivateResetWallpaperFunction() {} |
509 | 509 |
510 bool WallpaperPrivateResetWallpaperFunction::RunAsync() { | 510 bool WallpaperPrivateResetWallpaperFunction::RunAsync() { |
511 chromeos::WallpaperManager* wallpaper_manager = | 511 chromeos::WallpaperManager* wallpaper_manager = |
512 chromeos::WallpaperManager::Get(); | 512 chromeos::WallpaperManager::Get(); |
513 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); | 513 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
514 | 514 |
515 std::string user_id = user_manager->GetActiveUser()->email(); | 515 std::string user_id = user_manager->GetActiveUser()->email(); |
516 wallpaper_manager->RemoveUserWallpaperInfo(user_id); | 516 wallpaper_manager->RemoveUserWallpaperInfo(user_id); |
517 | 517 |
518 chromeos::WallpaperInfo info = {std::string(), | 518 chromeos::WallpaperInfo info = {std::string(), |
519 ash::WALLPAPER_LAYOUT_CENTER, | 519 ash::WALLPAPER_LAYOUT_CENTER, |
520 user_manager::User::DEFAULT, | 520 user_manager::User::DEFAULT, |
521 base::Time::Now().LocalMidnight()}; | 521 base::Time::Now().LocalMidnight()}; |
522 bool is_persistent = | 522 bool is_persistent = |
523 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); | 523 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); |
(...skipping 13 matching lines...) Expand all Loading... |
537 WallpaperPrivateSetCustomWallpaperFunction() {} | 537 WallpaperPrivateSetCustomWallpaperFunction() {} |
538 | 538 |
539 WallpaperPrivateSetCustomWallpaperFunction:: | 539 WallpaperPrivateSetCustomWallpaperFunction:: |
540 ~WallpaperPrivateSetCustomWallpaperFunction() {} | 540 ~WallpaperPrivateSetCustomWallpaperFunction() {} |
541 | 541 |
542 bool WallpaperPrivateSetCustomWallpaperFunction::RunAsync() { | 542 bool WallpaperPrivateSetCustomWallpaperFunction::RunAsync() { |
543 params = set_custom_wallpaper::Params::Create(*args_); | 543 params = set_custom_wallpaper::Params::Create(*args_); |
544 EXTENSION_FUNCTION_VALIDATE(params); | 544 EXTENSION_FUNCTION_VALIDATE(params); |
545 | 545 |
546 // Gets email address and username hash while at UI thread. | 546 // Gets email address and username hash while at UI thread. |
547 user_id_ = chromeos::UserManager::Get()->GetActiveUser()->email(); | 547 user_id_ = user_manager::UserManager::Get()->GetActiveUser()->email(); |
548 user_id_hash_ = | 548 user_id_hash_ = |
549 chromeos::UserManager::Get()->GetActiveUser()->username_hash(); | 549 user_manager::UserManager::Get()->GetActiveUser()->username_hash(); |
550 | 550 |
551 StartDecode(params->wallpaper); | 551 StartDecode(params->wallpaper); |
552 | 552 |
553 return true; | 553 return true; |
554 } | 554 } |
555 | 555 |
556 void WallpaperPrivateSetCustomWallpaperFunction::OnWallpaperDecoded( | 556 void WallpaperPrivateSetCustomWallpaperFunction::OnWallpaperDecoded( |
557 const gfx::ImageSkia& image) { | 557 const gfx::ImageSkia& image) { |
558 chromeos::WallpaperManager* wallpaper_manager = | 558 chromeos::WallpaperManager* wallpaper_manager = |
559 chromeos::WallpaperManager::Get(); | 559 chromeos::WallpaperManager::Get(); |
560 base::FilePath thumbnail_path = wallpaper_manager->GetCustomWallpaperPath( | 560 base::FilePath thumbnail_path = wallpaper_manager->GetCustomWallpaperPath( |
561 chromeos::kThumbnailWallpaperSubDir, user_id_hash_, params->file_name); | 561 chromeos::kThumbnailWallpaperSubDir, user_id_hash_, params->file_name); |
562 | 562 |
563 sequence_token_ = BrowserThread::GetBlockingPool()-> | 563 sequence_token_ = BrowserThread::GetBlockingPool()-> |
564 GetNamedSequenceToken(chromeos::kWallpaperSequenceTokenName); | 564 GetNamedSequenceToken(chromeos::kWallpaperSequenceTokenName); |
565 scoped_refptr<base::SequencedTaskRunner> task_runner = | 565 scoped_refptr<base::SequencedTaskRunner> task_runner = |
566 BrowserThread::GetBlockingPool()-> | 566 BrowserThread::GetBlockingPool()-> |
567 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, | 567 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, |
568 base::SequencedWorkerPool::BLOCK_SHUTDOWN); | 568 base::SequencedWorkerPool::BLOCK_SHUTDOWN); |
569 | 569 |
570 ash::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( | 570 ash::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( |
571 wallpaper_private::ToString(params->layout)); | 571 wallpaper_private::ToString(params->layout)); |
572 | 572 |
573 bool update_wallpaper = | 573 bool update_wallpaper = |
574 user_id_ == chromeos::UserManager::Get()->GetActiveUser()->email(); | 574 user_id_ == user_manager::UserManager::Get()->GetActiveUser()->email(); |
575 wallpaper_manager->SetCustomWallpaper(user_id_, | 575 wallpaper_manager->SetCustomWallpaper(user_id_, |
576 user_id_hash_, | 576 user_id_hash_, |
577 params->file_name, | 577 params->file_name, |
578 layout, | 578 layout, |
579 user_manager::User::CUSTOMIZED, | 579 user_manager::User::CUSTOMIZED, |
580 image, | 580 image, |
581 update_wallpaper); | 581 update_wallpaper); |
582 unsafe_wallpaper_decoder_ = NULL; | 582 unsafe_wallpaper_decoder_ = NULL; |
583 | 583 |
584 Profile* profile = Profile::FromBrowserContext(browser_context()); | 584 Profile* profile = Profile::FromBrowserContext(browser_context()); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 chromeos::WallpaperInfo info; | 648 chromeos::WallpaperInfo info; |
649 wallpaper_manager->GetLoggedInUserWallpaperInfo(&info); | 649 wallpaper_manager->GetLoggedInUserWallpaperInfo(&info); |
650 if (info.type != user_manager::User::CUSTOMIZED) { | 650 if (info.type != user_manager::User::CUSTOMIZED) { |
651 SetError("Only custom wallpaper can change layout."); | 651 SetError("Only custom wallpaper can change layout."); |
652 SendResponse(false); | 652 SendResponse(false); |
653 return false; | 653 return false; |
654 } | 654 } |
655 info.layout = wallpaper_api_util::GetLayoutEnum( | 655 info.layout = wallpaper_api_util::GetLayoutEnum( |
656 wallpaper_private::ToString(params->layout)); | 656 wallpaper_private::ToString(params->layout)); |
657 | 657 |
658 std::string email = chromeos::UserManager::Get()->GetActiveUser()->email(); | 658 std::string email = |
659 bool is_persistent = | 659 user_manager::UserManager::Get()->GetActiveUser()->email(); |
660 !chromeos::UserManager::Get()->IsCurrentUserNonCryptohomeDataEphemeral(); | 660 bool is_persistent = !user_manager::UserManager::Get() |
| 661 ->IsCurrentUserNonCryptohomeDataEphemeral(); |
661 wallpaper_manager->SetUserWallpaperInfo(email, info, is_persistent); | 662 wallpaper_manager->SetUserWallpaperInfo(email, info, is_persistent); |
662 wallpaper_manager->UpdateWallpaper(false /* clear_cache */); | 663 wallpaper_manager->UpdateWallpaper(false /* clear_cache */); |
663 SendResponse(true); | 664 SendResponse(true); |
664 | 665 |
665 // Gets email address while at UI thread. | 666 // Gets email address while at UI thread. |
666 return true; | 667 return true; |
667 } | 668 } |
668 | 669 |
669 WallpaperPrivateMinimizeInactiveWindowsFunction:: | 670 WallpaperPrivateMinimizeInactiveWindowsFunction:: |
670 WallpaperPrivateMinimizeInactiveWindowsFunction() { | 671 WallpaperPrivateMinimizeInactiveWindowsFunction() { |
671 } | 672 } |
672 | 673 |
673 WallpaperPrivateMinimizeInactiveWindowsFunction:: | 674 WallpaperPrivateMinimizeInactiveWindowsFunction:: |
674 ~WallpaperPrivateMinimizeInactiveWindowsFunction() { | 675 ~WallpaperPrivateMinimizeInactiveWindowsFunction() { |
675 } | 676 } |
676 | 677 |
677 bool WallpaperPrivateMinimizeInactiveWindowsFunction::RunAsync() { | 678 bool WallpaperPrivateMinimizeInactiveWindowsFunction::RunAsync() { |
678 WindowStateManager::MinimizeInactiveWindows( | 679 WindowStateManager::MinimizeInactiveWindows( |
679 chromeos::UserManager::Get()->GetActiveUser()->username_hash()); | 680 user_manager::UserManager::Get()->GetActiveUser()->username_hash()); |
680 return true; | 681 return true; |
681 } | 682 } |
682 | 683 |
683 WallpaperPrivateRestoreMinimizedWindowsFunction:: | 684 WallpaperPrivateRestoreMinimizedWindowsFunction:: |
684 WallpaperPrivateRestoreMinimizedWindowsFunction() { | 685 WallpaperPrivateRestoreMinimizedWindowsFunction() { |
685 } | 686 } |
686 | 687 |
687 WallpaperPrivateRestoreMinimizedWindowsFunction:: | 688 WallpaperPrivateRestoreMinimizedWindowsFunction:: |
688 ~WallpaperPrivateRestoreMinimizedWindowsFunction() { | 689 ~WallpaperPrivateRestoreMinimizedWindowsFunction() { |
689 } | 690 } |
690 | 691 |
691 bool WallpaperPrivateRestoreMinimizedWindowsFunction::RunAsync() { | 692 bool WallpaperPrivateRestoreMinimizedWindowsFunction::RunAsync() { |
692 WindowStateManager::RestoreWindows( | 693 WindowStateManager::RestoreWindows( |
693 chromeos::UserManager::Get()->GetActiveUser()->username_hash()); | 694 user_manager::UserManager::Get()->GetActiveUser()->username_hash()); |
694 return true; | 695 return true; |
695 } | 696 } |
696 | 697 |
697 WallpaperPrivateGetThumbnailFunction::WallpaperPrivateGetThumbnailFunction() { | 698 WallpaperPrivateGetThumbnailFunction::WallpaperPrivateGetThumbnailFunction() { |
698 } | 699 } |
699 | 700 |
700 WallpaperPrivateGetThumbnailFunction::~WallpaperPrivateGetThumbnailFunction() { | 701 WallpaperPrivateGetThumbnailFunction::~WallpaperPrivateGetThumbnailFunction() { |
701 } | 702 } |
702 | 703 |
703 bool WallpaperPrivateGetThumbnailFunction::RunAsync() { | 704 bool WallpaperPrivateGetThumbnailFunction::RunAsync() { |
704 scoped_ptr<get_thumbnail::Params> params( | 705 scoped_ptr<get_thumbnail::Params> params( |
705 get_thumbnail::Params::Create(*args_)); | 706 get_thumbnail::Params::Create(*args_)); |
706 EXTENSION_FUNCTION_VALIDATE(params); | 707 EXTENSION_FUNCTION_VALIDATE(params); |
707 | 708 |
708 base::FilePath thumbnail_path; | 709 base::FilePath thumbnail_path; |
709 std::string email = chromeos::UserManager::Get()->GetActiveUser()->email(); | 710 std::string email = |
| 711 user_manager::UserManager::Get()->GetActiveUser()->email(); |
710 if (params->source == get_thumbnail::Params::SOURCE_ONLINE) { | 712 if (params->source == get_thumbnail::Params::SOURCE_ONLINE) { |
711 std::string file_name = GURL(params->url_or_file).ExtractFileName(); | 713 std::string file_name = GURL(params->url_or_file).ExtractFileName(); |
712 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPER_THUMBNAILS, | 714 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPER_THUMBNAILS, |
713 &thumbnail_path)); | 715 &thumbnail_path)); |
714 thumbnail_path = thumbnail_path.Append(file_name); | 716 thumbnail_path = thumbnail_path.Append(file_name); |
715 } else { | 717 } else { |
716 if (!IsOEMDefaultWallpaper()) { | 718 if (!IsOEMDefaultWallpaper()) { |
717 SetError("No OEM wallpaper."); | 719 SetError("No OEM wallpaper."); |
718 SendResponse(false); | 720 SendResponse(false); |
719 return false; | 721 return false; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 this, file_list)); | 879 this, file_list)); |
878 } | 880 } |
879 | 881 |
880 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( | 882 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( |
881 const std::vector<std::string>& file_list) { | 883 const std::vector<std::string>& file_list) { |
882 base::ListValue* results = new base::ListValue(); | 884 base::ListValue* results = new base::ListValue(); |
883 results->AppendStrings(file_list); | 885 results->AppendStrings(file_list); |
884 SetResult(results); | 886 SetResult(results); |
885 SendResponse(true); | 887 SendResponse(true); |
886 } | 888 } |
OLD | NEW |