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

Side by Side Diff: chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc

Issue 2559503003: mash: Have chrome set itself as the wallpaper picker. (Closed)
Patch Set: Check for a null service manager connection. Created 4 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/login/users/wallpaper/wallpaper_manager.h" 5 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/ash_constants.h" 9 #include "ash/common/ash_constants.h"
10 #include "ash/common/wallpaper/wallpaper_controller.h" 10 #include "ash/common/wallpaper/wallpaper_controller.h"
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 return wallpaper_manager; 362 return wallpaper_manager;
363 } 363 }
364 364
365 // static 365 // static
366 void WallpaperManager::Shutdown() { 366 void WallpaperManager::Shutdown() {
367 CHECK(wallpaper_manager); 367 CHECK(wallpaper_manager);
368 delete wallpaper_manager; 368 delete wallpaper_manager;
369 wallpaper_manager = nullptr; 369 wallpaper_manager = nullptr;
370 } 370 }
371 371
372 void WallpaperManager::BindRequest(
373 ash::mojom::WallpaperManagerRequest request) {
374 bindings_.AddBinding(this, std::move(request));
375 }
376
377 WallpaperManager::WallpaperResolution 372 WallpaperManager::WallpaperResolution
378 WallpaperManager::GetAppropriateResolution() { 373 WallpaperManager::GetAppropriateResolution() {
379 DCHECK_CURRENTLY_ON(BrowserThread::UI); 374 DCHECK_CURRENTLY_ON(BrowserThread::UI);
380 gfx::Size size = ash::WallpaperController::GetMaxDisplaySizeInNative(); 375 gfx::Size size = ash::WallpaperController::GetMaxDisplaySizeInNative();
381 return (size.width() > wallpaper::kSmallWallpaperMaxWidth || 376 return (size.width() > wallpaper::kSmallWallpaperMaxWidth ||
382 size.height() > wallpaper::kSmallWallpaperMaxHeight) 377 size.height() > wallpaper::kSmallWallpaperMaxHeight)
383 ? WALLPAPER_RESOLUTION_LARGE 378 ? WALLPAPER_RESOLUTION_LARGE
384 : WALLPAPER_RESOLUTION_SMALL; 379 : WALLPAPER_RESOLUTION_SMALL;
385 } 380 }
386 381
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 // be set. It could result a black screen on external monitors. 795 // be set. It could result a black screen on external monitors.
801 // See http://crbug.com/265689 for detail. 796 // See http://crbug.com/265689 for detail.
802 if (last_selected_user_.empty()) 797 if (last_selected_user_.empty())
803 SetDefaultWallpaperNow(user_manager::SignInAccountId()); 798 SetDefaultWallpaperNow(user_manager::SignInAccountId());
804 WallpaperManagerBase::UpdateWallpaper(clear_cache); 799 WallpaperManagerBase::UpdateWallpaper(clear_cache);
805 } 800 }
806 801
807 // WallpaperManager, private: -------------------------------------------------- 802 // WallpaperManager, private: --------------------------------------------------
808 803
809 WallpaperManager::WallpaperManager() 804 WallpaperManager::WallpaperManager()
810 : pending_inactive_(NULL), weak_factory_(this) { 805 : binding_(this), pending_inactive_(nullptr), weak_factory_(this) {
811 DCHECK_CURRENTLY_ON(BrowserThread::UI); 806 DCHECK_CURRENTLY_ON(BrowserThread::UI);
812 wallpaper::WallpaperManagerBase::SetPathIds( 807 wallpaper::WallpaperManagerBase::SetPathIds(
813 chrome::DIR_USER_DATA, chrome::DIR_CHROMEOS_WALLPAPERS, 808 chrome::DIR_USER_DATA, chrome::DIR_CHROMEOS_WALLPAPERS,
814 chrome::DIR_CHROMEOS_CUSTOM_WALLPAPERS); 809 chrome::DIR_CHROMEOS_CUSTOM_WALLPAPERS);
815 SetDefaultWallpaperPathsFromCommandLine( 810 SetDefaultWallpaperPathsFromCommandLine(
816 base::CommandLine::ForCurrentProcess()); 811 base::CommandLine::ForCurrentProcess());
817 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_CHANGED, 812 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_CHANGED,
818 content::NotificationService::AllSources()); 813 content::NotificationService::AllSources());
819 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, 814 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
820 content::NotificationService::AllSources()); 815 content::NotificationService::AllSources());
821 registrar_.Add(this, chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, 816 registrar_.Add(this, chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED,
822 content::NotificationService::AllSources()); 817 content::NotificationService::AllSources());
823 sequence_token_ = BrowserThread::GetBlockingPool()->GetNamedSequenceToken( 818 sequence_token_ = BrowserThread::GetBlockingPool()->GetNamedSequenceToken(
824 wallpaper::kWallpaperSequenceTokenName); 819 wallpaper::kWallpaperSequenceTokenName);
825 task_runner_ = 820 task_runner_ =
826 BrowserThread::GetBlockingPool() 821 BrowserThread::GetBlockingPool()
827 ->GetSequencedTaskRunnerWithShutdownBehavior( 822 ->GetSequencedTaskRunnerWithShutdownBehavior(
828 sequence_token_, base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); 823 sequence_token_, base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
829 824
830 user_manager::UserManager::Get()->AddSessionStateObserver(this); 825 user_manager::UserManager::Get()->AddSessionStateObserver(this);
826
827 content::ServiceManagerConnection* connection =
828 content::ServiceManagerConnection::GetForProcess();
829 if (connection && connection->GetConnector()) {
James Cook 2016/12/07 23:03:47 Are you sure these can be null? Is that in tests?
msw 2016/12/07 23:12:55 Yes, the earlier patch sets failed because the con
830 // Connect to the wallpaper controller interface in the ash service.
831 ash::mojom::WallpaperControllerPtr wallpaper_controller_ptr;
832 connection->GetConnector()->ConnectToInterface(
833 ash_util::GetAshServiceName(), &wallpaper_controller_ptr);
834 // Register this object as the wallpaper picker.
835 wallpaper_controller_ptr->SetWallpaperPicker(
836 binding_.CreateInterfacePtrAndBind());
837 }
831 } 838 }
832 839
833 WallpaperManager::PendingWallpaper* WallpaperManager::GetPendingWallpaper( 840 WallpaperManager::PendingWallpaper* WallpaperManager::GetPendingWallpaper(
834 const AccountId& account_id, 841 const AccountId& account_id,
835 bool delayed) { 842 bool delayed) {
836 if (!pending_inactive_) { 843 if (!pending_inactive_) {
837 loading_.push_back(new WallpaperManager::PendingWallpaper( 844 loading_.push_back(new WallpaperManager::PendingWallpaper(
838 (delayed ? GetWallpaperLoadDelay() 845 (delayed ? GetWallpaperLoadDelay()
839 : base::TimeDelta::FromMilliseconds(0)), 846 : base::TimeDelta::FromMilliseconds(0)),
840 account_id)); 847 account_id));
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 &stored_value)) { 1163 &stored_value)) {
1157 return wallpaper::WallpaperFilesId::FromString(stored_value); 1164 return wallpaper::WallpaperFilesId::FromString(stored_value);
1158 } 1165 }
1159 const std::string& old_id = account_id.GetUserEmail(); // Migrated 1166 const std::string& old_id = account_id.GetUserEmail(); // Migrated
1160 const wallpaper::WallpaperFilesId files_id = HashWallpaperFilesIdStr(old_id); 1167 const wallpaper::WallpaperFilesId files_id = HashWallpaperFilesIdStr(old_id);
1161 SetKnownUserWallpaperFilesId(account_id, files_id); 1168 SetKnownUserWallpaperFilesId(account_id, files_id);
1162 return files_id; 1169 return files_id;
1163 } 1170 }
1164 1171
1165 } // namespace chromeos 1172 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698