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

Side by Side Diff: chrome/browser/ui/app_list/arc/arc_app_utils.cc

Issue 1756193008: Support uninstalling ARC app from Chrome launcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 9 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
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_utils.h ('k') | components/arc/common/app.mojom » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/app_list/arc/arc_app_utils.h" 5 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" 10 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } // namespace 121 } // namespace
122 122
123 bool LaunchAppWithRect(content::BrowserContext* context, 123 bool LaunchAppWithRect(content::BrowserContext* context,
124 const std::string& app_id, 124 const std::string& app_id,
125 const gfx::Rect& target_rect) { 125 const gfx::Rect& target_rect) {
126 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); 126 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context);
127 CHECK(prefs); 127 CHECK(prefs);
128 128
129 scoped_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); 129 scoped_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id);
130 if (!app_info) { 130 if (!app_info) {
131 VLOG(2) << "Cannot launch unavailable app:" << app_id << "."; 131 VLOG(2) << "Cannot launch unavailable app: " << app_id << ".";
132 return false; 132 return false;
133 } 133 }
134 134
135 if (!app_info->ready) { 135 if (!app_info->ready) {
136 VLOG(2) << "Cannot launch not-ready app:" << app_id << "."; 136 VLOG(2) << "Cannot launch not-ready app: " << app_id << ".";
137 return false; 137 return false;
138 } 138 }
139 139
140 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); 140 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get();
141 if (!bridge_service) { 141 if (!bridge_service) {
142 VLOG(2) << "Request to launch app when bridge service is not ready: " 142 VLOG(2) << "Request to launch app when bridge service is not ready: "
143 << app_id << "."; 143 << app_id << ".";
144 return false; 144 return false;
145 } 145 }
146 arc::AppInstance* app_instance = bridge_service->app_instance(); 146 arc::AppInstance* app_instance = bridge_service->app_instance();
(...skipping 16 matching lines...) Expand all
163 return true; 163 return true;
164 } 164 }
165 165
166 bool LaunchApp(content::BrowserContext* context, const std::string& app_id) { 166 bool LaunchApp(content::BrowserContext* context, const std::string& app_id) {
167 return (new LaunchAppWithoutSize(context, app_id))->LaunchAndRelease(); 167 return (new LaunchAppWithoutSize(context, app_id))->LaunchAndRelease();
168 } 168 }
169 169
170 bool CanHandleResolution(content::BrowserContext* context, 170 bool CanHandleResolution(content::BrowserContext* context,
171 const std::string& app_id, 171 const std::string& app_id,
172 const gfx::Rect& rect, 172 const gfx::Rect& rect,
173 const CanHandleResolutionCallback callback) { 173 const CanHandleResolutionCallback& callback) {
174 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); 174 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context);
175 scoped_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); 175 scoped_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id);
176 if (!app_info) { 176 if (!app_info) {
177 VLOG(2) << "Cannot test resolution capability of unavailable app:" << app_id 177 VLOG(2) << "Cannot test resolution capability of unavailable app:" << app_id
178 << "."; 178 << ".";
179 return false; 179 return false;
180 } 180 }
181 181
182 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); 182 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get();
183 arc::AppInstance* app_instance = 183 arc::AppInstance* app_instance =
(...skipping 16 matching lines...) Expand all
200 screen_rect->right = rect.right(); 200 screen_rect->right = rect.right();
201 screen_rect->top = rect.y(); 201 screen_rect->top = rect.y();
202 screen_rect->bottom = rect.bottom(); 202 screen_rect->bottom = rect.bottom();
203 203
204 app_instance->CanHandleResolution(app_info->package_name, app_info->activity, 204 app_instance->CanHandleResolution(app_info->package_name, app_info->activity,
205 std::move(screen_rect), 205 std::move(screen_rect),
206 callback); 206 callback);
207 return true; 207 return true;
208 } 208 }
209 209
210 void UninstallPackage(const std::string& package_name) {
211 VLOG(2) << "Uninstalling " << package_name;
212 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get();
213 if (!bridge_service) {
214 VLOG(2) << "Request to uninstall package when bridge service is not ready: "
215 << package_name << ".";
216 return;
217 }
218 arc::AppInstance* app_instance = bridge_service->app_instance();
219 if (!app_instance) {
220 VLOG(2) << "Request to uninstall package when bridge service is not ready: "
221 << package_name << ".";
222 return;
223 }
224
225 if (bridge_service->app_version() < 2) {
226 LOG(ERROR) << "Request to uninstall package when version "
227 << bridge_service->app_version() << " does not support it";
228 return;
229 }
230 app_instance->UninstallPackage(package_name);
231 }
232
210 } // namespace arc 233 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_utils.h ('k') | components/arc/common/app.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698