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

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

Issue 2557513004: Remove explicit singletonness of ArcBridgeService part 3. (Closed)
Patch Set: Address comments. 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 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 <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
13 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" 16 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
17 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" 17 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h"
18 #include "chrome/browser/ui/ash/launcher/arc_app_shelf_id.h" 18 #include "chrome/browser/ui/ash/launcher/arc_app_shelf_id.h"
19 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 19 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
20 #include "chromeos/dbus/dbus_thread_manager.h" 20 #include "chromeos/dbus/dbus_thread_manager.h"
21 #include "chromeos/dbus/session_manager_client.h" 21 #include "chromeos/dbus/session_manager_client.h"
22 #include "components/arc/arc_bridge_service.h" 22 #include "components/arc/arc_bridge_service.h"
23 #include "components/arc/arc_service_manager.h"
23 #include "components/arc/common/intent_helper.mojom.h" 24 #include "components/arc/common/intent_helper.mojom.h"
24 #include "ui/aura/window.h" 25 #include "ui/aura/window.h"
25 #include "ui/display/display.h" 26 #include "ui/display/display.h"
26 #include "ui/display/screen.h" 27 #include "ui/display/screen.h"
27 #include "ui/events/event_constants.h" 28 #include "ui/events/event_constants.h"
28 29
29 namespace arc { 30 namespace arc {
30 31
31 namespace { 32 namespace {
32 33
(...skipping 29 matching lines...) Expand all
62 constexpr char kSendBroadcastStr[] = "SendBroadcast"; 63 constexpr char kSendBroadcastStr[] = "SendBroadcast";
63 constexpr char kSetInTouchModeIntent[] = 64 constexpr char kSetInTouchModeIntent[] =
64 "org.chromium.arc.intent_helper.SET_IN_TOUCH_MODE"; 65 "org.chromium.arc.intent_helper.SET_IN_TOUCH_MODE";
65 constexpr char kShowTalkbackSettingsIntent[] = 66 constexpr char kShowTalkbackSettingsIntent[] =
66 "org.chromium.arc.intent_helper.SHOW_TALKBACK_SETTINGS"; 67 "org.chromium.arc.intent_helper.SHOW_TALKBACK_SETTINGS";
67 68
68 // Helper function which returns the AppInstance. Create related logs when error 69 // Helper function which returns the AppInstance. Create related logs when error
69 // happens. 70 // happens.
70 arc::mojom::AppInstance* GetAppInstance(uint32_t required_version, 71 arc::mojom::AppInstance* GetAppInstance(uint32_t required_version,
71 const std::string& service_name) { 72 const std::string& service_name) {
72 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); 73 auto* arc_service_manager = arc::ArcServiceManager::Get();
73 if (!bridge_service) { 74 if (!arc_service_manager) {
74 VLOG(2) << "Request to " << service_name 75 VLOG(2) << "Request to " << service_name
75 << " when bridge service is not ready."; 76 << " when bridge service is not ready.";
76 return nullptr; 77 return nullptr;
77 } 78 }
78 79
79 return bridge_service->app()->GetInstanceForMethod(service_name.c_str(), 80 return arc_service_manager->arc_bridge_service()->app()->GetInstanceForMethod(
80 required_version); 81 service_name, required_version);
81 } 82 }
82 83
83 // Helper function which returns the IntentHelperInstance. Create related logs 84 // Helper function which returns the IntentHelperInstance. Create related logs
84 // when error happens. 85 // when error happens.
85 arc::mojom::IntentHelperInstance* GetIntentHelperInstance( 86 arc::mojom::IntentHelperInstance* GetIntentHelperInstance(
86 uint32_t required_version, 87 uint32_t required_version,
87 const std::string& service_name) { 88 const std::string& service_name) {
88 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); 89 auto* arc_service_manager = arc::ArcServiceManager::Get();
89 if (!bridge_service) { 90 if (!arc_service_manager) {
90 VLOG(2) << "Request to " << service_name 91 VLOG(2) << "Request to " << service_name
91 << " when bridge service is not ready."; 92 << " when bridge service is not ready.";
92 return nullptr; 93 return nullptr;
93 } 94 }
94 95
95 return bridge_service->intent_helper()->GetInstanceForMethod( 96 return arc_service_manager->arc_bridge_service()
96 service_name.c_str(), required_version); 97 ->intent_helper()
98 ->GetInstanceForMethod(service_name, required_version);
97 } 99 }
98 100
99 void PrioritizeArcInstanceCallback(bool success) { 101 void PrioritizeArcInstanceCallback(bool success) {
100 VLOG(2) << "Finished prioritizing the instance: result=" << success; 102 VLOG(2) << "Finished prioritizing the instance: result=" << success;
101 if (!success) 103 if (!success)
102 LOG(ERROR) << "Failed to prioritize ARC"; 104 LOG(ERROR) << "Failed to prioritize ARC";
103 } 105 }
104 106
105 // Find a proper size and position for a given rectangle on the screen. 107 // Find a proper size and position for a given rectangle on the screen.
106 // TODO(skuhne): This needs more consideration, but it is lacking 108 // TODO(skuhne): This needs more consideration, but it is lacking
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 return false; 460 return false;
459 461
460 const ArcAppListPrefs* const arc_prefs = ArcAppListPrefs::Get(context); 462 const ArcAppListPrefs* const arc_prefs = ArcAppListPrefs::Get(context);
461 if (!arc_prefs) 463 if (!arc_prefs)
462 return false; 464 return false;
463 465
464 return arc_prefs->IsRegistered(ArcAppShelfId::FromString(id).app_id()); 466 return arc_prefs->IsRegistered(ArcAppShelfId::FromString(id).app_id());
465 } 467 }
466 468
467 } // namespace arc 469 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_test.cc ('k') | chrome/browser/ui/views/arc_app_dialog_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698