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

Side by Side Diff: chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.cc

Issue 2052013002: Adding ChromeLauncherController interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome_launcher_smaller_api
Patch Set: Rebase Created 4 years, 6 months 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ui/ash/launcher/arc_app_deferred_launcher_controller.h" 5 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h"
6 6
7 #include "chrome/browser/chromeos/arc/arc_support_host.h" 7 #include "chrome/browser/chromeos/arc/arc_support_host.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 9 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
10 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_item_controll er.h" 10 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_item_controll er.h"
11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h"
12 #include "ui/gfx/canvas.h" 12 #include "ui/gfx/canvas.h"
13 #include "ui/gfx/image/canvas_image_source.h" 13 #include "ui/gfx/image/canvas_image_source.h"
14 #include "ui/gfx/image/image_skia_operations.h" 14 #include "ui/gfx/image/image_skia_operations.h"
15 #include "ui/gfx/paint_throbber.h" 15 #include "ui/gfx/paint_throbber.h"
16 16
17 namespace { 17 namespace {
18 constexpr int kUpdateIconIntervalMs = 40; // 40ms for 25 frames per second. 18 constexpr int kUpdateIconIntervalMs = 40; // 40ms for 25 frames per second.
19 constexpr int kSpinningGapPercent = 25; 19 constexpr int kSpinningGapPercent = 25;
20 20
21 class SpinningEffectSource : public gfx::CanvasImageSource { 21 class SpinningEffectSource : public gfx::CanvasImageSource {
(...skipping 26 matching lines...) Expand all
48 private: 48 private:
49 base::WeakPtr<ArcAppDeferredLauncherController> host_; 49 base::WeakPtr<ArcAppDeferredLauncherController> host_;
50 const std::string app_id_; 50 const std::string app_id_;
51 const gfx::ImageSkia image_; 51 const gfx::ImageSkia image_;
52 52
53 DISALLOW_COPY_AND_ASSIGN(SpinningEffectSource); 53 DISALLOW_COPY_AND_ASSIGN(SpinningEffectSource);
54 }; 54 };
55 } // namespace 55 } // namespace
56 56
57 ArcAppDeferredLauncherController::ArcAppDeferredLauncherController( 57 ArcAppDeferredLauncherController::ArcAppDeferredLauncherController(
58 ChromeLauncherController* owner) 58 ChromeLauncherControllerImpl* owner)
59 : owner_(owner), weak_ptr_factory_(this) { 59 : owner_(owner), weak_ptr_factory_(this) {
60 if (arc::ArcAuthService::IsAllowedForProfile(owner->profile())) { 60 if (arc::ArcAuthService::IsAllowedForProfile(owner->GetProfile())) {
61 observed_profile_ = owner->profile(); 61 observed_profile_ = owner->GetProfile();
62 ArcAppListPrefs::Get(observed_profile_)->AddObserver(this); 62 ArcAppListPrefs::Get(observed_profile_)->AddObserver(this);
63 } 63 }
64 } 64 }
65 65
66 ArcAppDeferredLauncherController::~ArcAppDeferredLauncherController() { 66 ArcAppDeferredLauncherController::~ArcAppDeferredLauncherController() {
67 if (observed_profile_) 67 if (observed_profile_)
68 ArcAppListPrefs::Get(observed_profile_)->RemoveObserver(this); 68 ArcAppListPrefs::Get(observed_profile_)->RemoveObserver(this);
69 } 69 }
70 70
71 void ArcAppDeferredLauncherController::Apply(const std::string& app_id, 71 void ArcAppDeferredLauncherController::Apply(const std::string& app_id,
(...skipping 30 matching lines...) Expand all
102 bool ready) { 102 bool ready) {
103 if (!ready) 103 if (!ready)
104 return; 104 return;
105 105
106 AppControllerMap::const_iterator it = app_controller_map_.find(app_id); 106 AppControllerMap::const_iterator it = app_controller_map_.find(app_id);
107 if (it == app_controller_map_.end()) 107 if (it == app_controller_map_.end())
108 return; 108 return;
109 109
110 Close(app_id); 110 Close(app_id);
111 111
112 arc::LaunchApp(owner_->profile(), app_id); 112 arc::LaunchApp(owner_->GetProfile(), app_id);
113 } 113 }
114 114
115 void ArcAppDeferredLauncherController::OnAppRemoved(const std::string& app_id) { 115 void ArcAppDeferredLauncherController::OnAppRemoved(const std::string& app_id) {
116 Close(app_id); 116 Close(app_id);
117 } 117 }
118 118
119 base::TimeDelta ArcAppDeferredLauncherController::GetActiveTime( 119 base::TimeDelta ArcAppDeferredLauncherController::GetActiveTime(
120 const std::string& app_id) const { 120 const std::string& app_id) const {
121 AppControllerMap::const_iterator it = app_controller_map_.find(app_id); 121 AppControllerMap::const_iterator it = app_controller_map_.find(app_id);
122 if (it == app_controller_map_.end()) 122 if (it == app_controller_map_.end())
123 return base::TimeDelta(); 123 return base::TimeDelta();
124 124
125 return it->second->GetActiveTime(); 125 return it->second->GetActiveTime();
126 } 126 }
127 127
128 void ArcAppDeferredLauncherController::UpdateApps() { 128 void ArcAppDeferredLauncherController::UpdateApps() {
129 if (app_controller_map_.empty()) 129 if (app_controller_map_.empty())
130 return; 130 return;
131 131
132 RegisterNextUpdate(); 132 RegisterNextUpdate();
133 for (const auto pair : app_controller_map_) 133 for (const auto pair : app_controller_map_)
134 owner_->OnAppUpdated(owner_->profile(), pair.first); 134 owner_->OnAppUpdated(owner_->GetProfile(), pair.first);
135 } 135 }
136 136
137 void ArcAppDeferredLauncherController::RegisterNextUpdate() { 137 void ArcAppDeferredLauncherController::RegisterNextUpdate() {
138 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 138 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
139 FROM_HERE, base::Bind(&ArcAppDeferredLauncherController::UpdateApps, 139 FROM_HERE, base::Bind(&ArcAppDeferredLauncherController::UpdateApps,
140 weak_ptr_factory_.GetWeakPtr()), 140 weak_ptr_factory_.GetWeakPtr()),
141 base::TimeDelta::FromMilliseconds(kUpdateIconIntervalMs)); 141 base::TimeDelta::FromMilliseconds(kUpdateIconIntervalMs));
142 } 142 }
143 143
144 void ArcAppDeferredLauncherController::RegisterDeferredLaunch( 144 void ArcAppDeferredLauncherController::RegisterDeferredLaunch(
(...skipping 21 matching lines...) Expand all
166 } else { 166 } else {
167 owner_->SetItemController(shelf_id, controller); 167 owner_->SetItemController(shelf_id, controller);
168 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); 168 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING);
169 } 169 }
170 170
171 if (app_controller_map_.empty()) 171 if (app_controller_map_.empty())
172 RegisterNextUpdate(); 172 RegisterNextUpdate();
173 173
174 app_controller_map_[app_id] = controller; 174 app_controller_map_[app_id] = controller;
175 } 175 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698