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

Unified Diff: components/arc/intent_helper/arc_intent_helper_bridge.cc

Issue 2337193005: Consolidate 4 GetIntentHelper functions (Closed)
Patch Set: Address comments 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 side-by-side diff with in-line comments
Download patch
Index: components/arc/intent_helper/arc_intent_helper_bridge.cc
diff --git a/components/arc/intent_helper/arc_intent_helper_bridge.cc b/components/arc/intent_helper/arc_intent_helper_bridge.cc
index b502d0cd32dd331fb667f9895b052ed5e9beb363..75b43cc02f4f672b873902ab403b7352fa4f923c 100644
--- a/components/arc/intent_helper/arc_intent_helper_bridge.cc
+++ b/components/arc/intent_helper/arc_intent_helper_bridge.cc
@@ -12,6 +12,7 @@
#include "ash/common/wallpaper/wallpaper_delegate.h"
#include "ash/common/wm_shell.h"
#include "ash/shell.h"
+#include "base/command_line.h"
#include "base/memory/weak_ptr.h"
#include "components/arc/intent_helper/activity_icon_loader.h"
#include "components/arc/intent_helper/link_handler_model_impl.h"
@@ -126,6 +127,48 @@ ArcIntentHelperBridge::FilterOutIntentHelper(
return handlers_filtered;
}
+// static
+mojom::IntentHelperInstance* ArcIntentHelperBridge::GetIntentHelperInstance(
+ int min_instance_version,
+ GetResult* out_error_code) {
+ if (!ArcBridgeService::GetEnabled(base::CommandLine::ForCurrentProcess())) {
Luis Héctor Chávez 2016/09/14 21:09:12 Maybe only do this if |bridge_service| is nullptr.
Yusuke Sato 2016/09/14 21:21:49 Done.
+ VLOG(2) << "ARC bridge is not supported.";
+ if (out_error_code)
+ *out_error_code = GetResult::FAILED_ARC_NOT_SUPPORTED;
+ return nullptr;
+ }
+ ArcBridgeService* bridge_service = ArcBridgeService::Get();
+ if (!bridge_service) {
+ VLOG(2) << "ARC bridge is not ready.";
+ if (out_error_code)
+ *out_error_code = GetResult::FAILED_ARC_NOT_READY;
+ return nullptr;
+ }
+ mojom::IntentHelperInstance* intent_helper_instance =
+ bridge_service->intent_helper()->instance();
+ if (!intent_helper_instance) {
+ VLOG(2) << "ARC intent helper instance is not ready.";
+ if (out_error_code)
+ *out_error_code = GetResult::FAILED_ARC_NOT_READY;
+ return nullptr;
+ }
+ const int version = bridge_service->intent_helper()->version();
+ if (version < min_instance_version) {
+ VLOG(1) << "ARC intent helper instance is too old. required: "
+ << min_instance_version << ", actual: " << version;
+ if (out_error_code)
+ *out_error_code = GetResult::FAILED_ARC_NOT_SUPPORTED;
+ return nullptr;
+ }
+ return intent_helper_instance;
+}
+
+// static
+mojom::IntentHelperInstance* ArcIntentHelperBridge::GetIntentHelperInstance(
+ int min_instance_version) {
+ return GetIntentHelperInstance(min_instance_version, nullptr);
+}
+
void ArcIntentHelperBridge::OnIntentFiltersUpdated(
mojo::Array<mojom::IntentFilterPtr> filters) {
DCHECK(thread_checker_.CalledOnValidThread());
« no previous file with comments | « components/arc/intent_helper/arc_intent_helper_bridge.h ('k') | components/arc/intent_helper/link_handler_model_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698