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

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

Issue 2323483004: [Merge-M53] arc: Support window recreation. (Closed)
Patch Set: resolve Created 4 years, 3 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/app_list/arc/arc_app_utils.h" 5 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 13 matching lines...) Expand all
24 // Default sizes to use. 24 // Default sizes to use.
25 constexpr int kNexus7Width = 960; 25 constexpr int kNexus7Width = 960;
26 constexpr int kNexus7Height = 600; 26 constexpr int kNexus7Height = 600;
27 constexpr int kNexus5Width = 410; 27 constexpr int kNexus5Width = 410;
28 constexpr int kNexus5Height = 690; 28 constexpr int kNexus5Height = 690;
29 29
30 // Minimum required versions. 30 // Minimum required versions.
31 constexpr int kMinVersion = 0; 31 constexpr int kMinVersion = 0;
32 constexpr int kCanHandleResolutionMinVersion = 1; 32 constexpr int kCanHandleResolutionMinVersion = 1;
33 constexpr int kUninstallPackageMinVersion = 2; 33 constexpr int kUninstallPackageMinVersion = 2;
34 constexpr int kTaskSupportMinVersion = 3;
34 constexpr int kShowPackageInfoMinVersion = 5; 35 constexpr int kShowPackageInfoMinVersion = 5;
35 constexpr int kRemoveIconMinVersion = 9; 36 constexpr int kRemoveIconMinVersion = 9;
36 constexpr int kShowPackageInfoOnPageMinVersion = 10; 37 constexpr int kShowPackageInfoOnPageMinVersion = 10;
37 38
38 // Service name strings. 39 // Service name strings.
39 constexpr char kCanHandleResolutionStr[] = "get resolution capability"; 40 constexpr char kCanHandleResolutionStr[] = "get resolution capability";
41 constexpr char kCloseTaskStr[] = "close task";
40 constexpr char kLaunchAppStr[] = "launch app"; 42 constexpr char kLaunchAppStr[] = "launch app";
43 constexpr char kRemoveIconStr[] = "remove icon";
44 constexpr char kSetActiveTaskStr[] = "set active task";
41 constexpr char kShowPackageInfoStr[] = "show package info"; 45 constexpr char kShowPackageInfoStr[] = "show package info";
42 constexpr char kUninstallPackageStr[] = "uninstall package"; 46 constexpr char kUninstallPackageStr[] = "uninstall package";
43 constexpr char kRemoveIconStr[] = "remove icon";
44 47
45 // Helper function which returns the AppInstance. Create related logs when error 48 // Helper function which returns the AppInstance. Create related logs when error
46 // happens. 49 // happens.
47 arc::mojom::AppInstance* GetAppInstance(int required_version, 50 arc::mojom::AppInstance* GetAppInstance(int required_version,
48 const std::string& service_name) { 51 const std::string& service_name) {
49 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); 52 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get();
50 if (!bridge_service) { 53 if (!bridge_service) {
51 VLOG(2) << "Request to " << service_name 54 VLOG(2) << "Request to " << service_name
52 << " when bridge service is not ready."; 55 << " when bridge service is not ready.";
53 return nullptr; 56 return nullptr;
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 ChromeLauncherController::instance(); 228 ChromeLauncherController::instance();
226 DCHECK(chrome_controller); 229 DCHECK(chrome_controller);
227 chrome_controller->GetArcDeferredLauncher()->RegisterDeferredLaunch(app_id); 230 chrome_controller->GetArcDeferredLauncher()->RegisterDeferredLaunch(app_id);
228 return true; 231 return true;
229 } 232 }
230 233
231 return (new LaunchAppWithoutSize(context, app_id, landscape_layout)) 234 return (new LaunchAppWithoutSize(context, app_id, landscape_layout))
232 ->LaunchAndRelease(); 235 ->LaunchAndRelease();
233 } 236 }
234 237
238 void SetTaskActive(int task_id) {
239 arc::mojom::AppInstance* app_instance =
240 GetAppInstance(kTaskSupportMinVersion, kSetActiveTaskStr);
241 if (!app_instance)
242 return;
243 app_instance->SetTaskActive(task_id);
244 }
245
246 void CloseTask(int task_id) {
247 arc::mojom::AppInstance* app_instance =
248 GetAppInstance(kTaskSupportMinVersion, kCloseTaskStr);
249 if (!app_instance)
250 return;
251 app_instance->CloseTask(task_id);
252 }
253
235 bool CanHandleResolution(content::BrowserContext* context, 254 bool CanHandleResolution(content::BrowserContext* context,
236 const std::string& app_id, 255 const std::string& app_id,
237 const gfx::Rect& rect, 256 const gfx::Rect& rect,
238 const CanHandleResolutionCallback& callback) { 257 const CanHandleResolutionCallback& callback) {
239 const ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); 258 const ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context);
240 DCHECK(prefs); 259 DCHECK(prefs);
241 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); 260 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id);
242 if (!app_info) { 261 if (!app_info) {
243 VLOG(2) << "Cannot test resolution capability of unavailable app:" << app_id 262 VLOG(2) << "Cannot test resolution capability of unavailable app:" << app_id
244 << "."; 263 << ".";
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 if (!app_instance) 319 if (!app_instance)
301 return false; 320 return false;
302 321
303 app_instance->ShowPackageInfoOnPage( 322 app_instance->ShowPackageInfoOnPage(
304 package_name, page, 323 package_name, page,
305 GetTargetRect(gfx::Size(kNexus7Width, kNexus7Height))); 324 GetTargetRect(gfx::Size(kNexus7Width, kNexus7Height)));
306 return true; 325 return true;
307 } 326 }
308 327
309 } // namespace arc 328 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_utils.h ('k') | chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698