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

Side by Side Diff: components/arc/intent_helper/link_handler_model_impl.cc

Issue 2357053002: Always use arc::InstanceHolder<T>::GetInstanceForMethod (Closed)
Patch Set: rebased to catch up tot 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 "components/arc/intent_helper/link_handler_model_impl.h" 5 #include "components/arc/intent_helper/link_handler_model_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 } // namespace 50 } // namespace
51 51
52 LinkHandlerModelImpl::LinkHandlerModelImpl( 52 LinkHandlerModelImpl::LinkHandlerModelImpl(
53 scoped_refptr<ActivityIconLoader> icon_loader) 53 scoped_refptr<ActivityIconLoader> icon_loader)
54 : icon_loader_(icon_loader), weak_ptr_factory_(this) {} 54 : icon_loader_(icon_loader), weak_ptr_factory_(this) {}
55 55
56 LinkHandlerModelImpl::~LinkHandlerModelImpl() {} 56 LinkHandlerModelImpl::~LinkHandlerModelImpl() {}
57 57
58 bool LinkHandlerModelImpl::Init(const GURL& url) { 58 bool LinkHandlerModelImpl::Init(const GURL& url) {
59 mojom::IntentHelperInstance* intent_helper_instance = 59 auto* instance = ArcIntentHelperBridge::GetIntentHelperInstance(
60 ArcIntentHelperBridge::GetIntentHelperInstance(kMinInstanceVersion); 60 "RequestUrlHandlerList", kMinInstanceVersion);
Luis Héctor Chávez 2016/09/23 22:51:04 This is MinVersion=4.
Yusuke Sato 2016/09/24 00:15:22 There are two similarly-named functions (oops..),
61 if (!intent_helper_instance) 61 if (!instance)
62 return false; 62 return false;
63 63
64 // Check if ARC apps can handle the |url|. Since the information is held in 64 // Check if ARC apps can handle the |url|. Since the information is held in
65 // a different (ARC) process, issue a mojo IPC request. Usually, the 65 // a different (ARC) process, issue a mojo IPC request. Usually, the
66 // callback function, OnUrlHandlerList, is called within a few milliseconds 66 // callback function, OnUrlHandlerList, is called within a few milliseconds
67 // even on the slowest Chromebook we support. 67 // even on the slowest Chromebook we support.
68 const GURL rewritten(RewriteUrlFromQueryIfAvailable(url)); 68 const GURL rewritten(RewriteUrlFromQueryIfAvailable(url));
69 intent_helper_instance->RequestUrlHandlerList( 69 instance->RequestUrlHandlerList(
70 rewritten.spec(), base::Bind(&LinkHandlerModelImpl::OnUrlHandlerList, 70 rewritten.spec(), base::Bind(&LinkHandlerModelImpl::OnUrlHandlerList,
71 weak_ptr_factory_.GetWeakPtr())); 71 weak_ptr_factory_.GetWeakPtr()));
72 return true; 72 return true;
73 } 73 }
74 74
75 void LinkHandlerModelImpl::AddObserver(Observer* observer) { 75 void LinkHandlerModelImpl::AddObserver(Observer* observer) {
76 observer_list_.AddObserver(observer); 76 observer_list_.AddObserver(observer);
77 } 77 }
78 78
79 void LinkHandlerModelImpl::OpenLinkWithHandler(const GURL& url, 79 void LinkHandlerModelImpl::OpenLinkWithHandler(const GURL& url,
80 uint32_t handler_id) { 80 uint32_t handler_id) {
81 mojom::IntentHelperInstance* intent_helper_instance = 81 auto* instance = ArcIntentHelperBridge::GetIntentHelperInstance(
82 ArcIntentHelperBridge::GetIntentHelperInstance(kMinInstanceVersion); 82 "HandleUrl", kMinInstanceVersion);
83 if (!intent_helper_instance) 83 if (!instance)
84 return; 84 return;
85 if (handler_id >= handlers_.size()) 85 if (handler_id >= handlers_.size())
86 return; 86 return;
87 const GURL rewritten(RewriteUrlFromQueryIfAvailable(url)); 87 const GURL rewritten(RewriteUrlFromQueryIfAvailable(url));
88 intent_helper_instance->HandleUrl(rewritten.spec(), 88 instance->HandleUrl(rewritten.spec(), handlers_[handler_id]->package_name);
89 handlers_[handler_id]->package_name);
90 } 89 }
91 90
92 void LinkHandlerModelImpl::OnUrlHandlerList( 91 void LinkHandlerModelImpl::OnUrlHandlerList(
93 mojo::Array<mojom::UrlHandlerInfoPtr> handlers) { 92 mojo::Array<mojom::UrlHandlerInfoPtr> handlers) {
94 handlers_ = ArcIntentHelperBridge::FilterOutIntentHelper(std::move(handlers)); 93 handlers_ = ArcIntentHelperBridge::FilterOutIntentHelper(std::move(handlers));
95 94
96 bool icon_info_notified = false; 95 bool icon_info_notified = false;
97 if (icon_loader_) { 96 if (icon_loader_) {
98 std::vector<ActivityIconLoader::ActivityName> activities; 97 std::vector<ActivityIconLoader::ActivityName> activities;
99 for (size_t i = 0; i < handlers_.size(); ++i) { 98 for (size_t i = 0; i < handlers_.size(); ++i) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 if (!GetQueryValue(url, kKeyToFind, &value)) 157 if (!GetQueryValue(url, kKeyToFind, &value))
159 return url; 158 return url;
160 159
161 const GURL new_url(value); 160 const GURL new_url(value);
162 if (!new_url.is_valid()) 161 if (!new_url.is_valid())
163 return url; 162 return url;
164 return new_url; 163 return new_url;
165 } 164 }
166 165
167 } // namespace arc 166 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698