 Chromium Code Reviews
 Chromium Code Reviews Issue 1756193008:
  Support uninstalling ARC app from Chrome launcher  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1756193008:
  Support uninstalling ARC app from Chrome launcher  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| 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 "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 7 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 
| 8 #include "components/arc/arc_bridge_service.h" | 8 #include "components/arc/arc_bridge_service.h" | 
| 9 | 9 | 
| 10 namespace arc { | 10 namespace arc { | 
| 11 | 11 | 
| 12 void GetAndroidAppTargetRect(gfx::Rect& target_rect) { | 12 void GetAndroidAppTargetRect(gfx::Rect& target_rect) { | 
| 13 // TODO: Figure out where to put the android window. | 13 // TODO: Figure out where to put the android window. | 
| 14 target_rect.SetRect(0, 0, 0, 0); | 14 target_rect.SetRect(0, 0, 0, 0); | 
| 15 } | 15 } | 
| 16 | 16 | 
| 17 bool LaunchApp(content::BrowserContext* context, const std::string& app_id) { | 17 bool LaunchApp(content::BrowserContext* context, const std::string& app_id) { | 
| 18 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); | 18 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); | 
| 19 CHECK(prefs); | 19 CHECK(prefs); | 
| 20 | 20 | 
| 21 scoped_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); | 21 scoped_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); | 
| 22 if (!app_info) { | 22 if (!app_info) { | 
| 23 VLOG(2) << "Cannot launch unavailable app:" << app_id << "."; | 23 VLOG(2) << "Cannot launch unavailable app: " << app_id << "."; | 
| 24 return false; | 24 return false; | 
| 25 } | 25 } | 
| 26 | 26 | 
| 27 if (!app_info->ready) { | 27 if (!app_info->ready) { | 
| 28 VLOG(2) << "Cannot launch not-ready app:" << app_id << "."; | 28 VLOG(2) << "Cannot launch not-ready app: " << app_id << "."; | 
| 29 return false; | 29 return false; | 
| 30 } | 30 } | 
| 31 | 31 | 
| 32 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); | 32 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); | 
| 33 if (!bridge_service) { | 33 if (!bridge_service) { | 
| 34 VLOG(2) << "Request to launch app when bridge service is not ready: " | 34 VLOG(2) << "Request to launch app when bridge service is not ready: " | 
| 35 << app_id << "."; | 35 << app_id << "."; | 
| 36 return false; | 36 return false; | 
| 37 } | 37 } | 
| 38 arc::AppInstance* app_instance = bridge_service->app_instance(); | 38 arc::AppInstance* app_instance = bridge_service->app_instance(); | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 screen_rect->right = rect.right(); | 91 screen_rect->right = rect.right(); | 
| 92 screen_rect->top = rect.y(); | 92 screen_rect->top = rect.y(); | 
| 93 screen_rect->bottom = rect.bottom(); | 93 screen_rect->bottom = rect.bottom(); | 
| 94 | 94 | 
| 95 app_instance->CanHandleResolution(app_info->package_name, app_info->activity, | 95 app_instance->CanHandleResolution(app_info->package_name, app_info->activity, | 
| 96 std::move(screen_rect), | 96 std::move(screen_rect), | 
| 97 callback); | 97 callback); | 
| 98 return true; | 98 return true; | 
| 99 } | 99 } | 
| 100 | 100 | 
| 101 bool UninstallApp(content::BrowserContext* context, | |
| 102 const std::string& package_name) { | |
| 103 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); | |
| 104 if (!bridge_service) { | |
| 105 VLOG(2) << "Request to uninstall app when bridge service is not ready: " | |
| 106 << package_name << "."; | |
| 107 return false; | |
| 108 } | |
| 109 arc::AppInstance* app_instance = bridge_service->app_instance(); | |
| 110 if (!app_instance) { | |
| 111 VLOG(2) << "Request to uninstall app when bridge service is not ready: " | |
| 112 << package_name << "."; | |
| 113 return false; | |
| 114 } | |
| 115 | |
| 116 if (bridge_service->app_version() >= 2) { | |
| 
khmel
2016/03/04 18:35:53
If you have UninstallApp available you already hav
 
Luis Héctor Chávez
2016/03/04 21:29:37
You will always have the method available (compile
 
victorhsieh0
2016/03/07 21:00:16
Done.
 | |
| 117 app_instance->UninstallApp(package_name); | |
| 118 } else { | |
| 119 LOG(ERROR) << "Require later version to uninstall"; | |
| 120 return false; | |
| 121 } | |
| 122 | |
| 123 return true; | |
| 124 } | |
| 125 | |
| 101 } // namespace arc | 126 } // namespace arc | 
| OLD | NEW |