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

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

Issue 2498223002: arc: enable use_new_wrapper_types for intent_helper.mojom (Closed)
Patch Set: rebase Created 4 years, 1 month 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>
10 9
11 #include "base/bind.h" 10 #include "base/bind.h"
12 #include "components/arc/arc_bridge_service.h" 11 #include "components/arc/arc_bridge_service.h"
13 #include "components/arc/intent_helper/arc_intent_helper_bridge.h" 12 #include "components/arc/intent_helper/arc_intent_helper_bridge.h"
14 #include "components/google/core/browser/google_util.h" 13 #include "components/google/core/browser/google_util.h"
15 #include "url/gurl.h" 14 #include "url/gurl.h"
16 #include "url/url_util.h" 15 #include "url/url_util.h"
17 16
18 namespace arc { 17 namespace arc {
19 18
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 "HandleUrl", kMinInstanceVersion); 81 "HandleUrl", kMinInstanceVersion);
83 if (!instance) 82 if (!instance)
84 return; 83 return;
85 if (handler_id >= handlers_.size()) 84 if (handler_id >= handlers_.size())
86 return; 85 return;
87 const GURL rewritten(RewriteUrlFromQueryIfAvailable(url)); 86 const GURL rewritten(RewriteUrlFromQueryIfAvailable(url));
88 instance->HandleUrl(rewritten.spec(), handlers_[handler_id]->package_name); 87 instance->HandleUrl(rewritten.spec(), handlers_[handler_id]->package_name);
89 } 88 }
90 89
91 void LinkHandlerModelImpl::OnUrlHandlerList( 90 void LinkHandlerModelImpl::OnUrlHandlerList(
92 mojo::Array<mojom::IntentHandlerInfoPtr> handlers) { 91 std::vector<mojom::IntentHandlerInfoPtr> handlers) {
93 handlers_ = ArcIntentHelperBridge::FilterOutIntentHelper(std::move(handlers)); 92 handlers_ = ArcIntentHelperBridge::FilterOutIntentHelper(std::move(handlers));
94 93
95 bool icon_info_notified = false; 94 bool icon_info_notified = false;
96 if (icon_loader_) { 95 if (icon_loader_) {
97 std::vector<ActivityIconLoader::ActivityName> activities; 96 std::vector<ActivityIconLoader::ActivityName> activities;
98 for (size_t i = 0; i < handlers_.size(); ++i) { 97 for (size_t i = 0; i < handlers_.size(); ++i) {
99 activities.emplace_back(handlers_[i]->package_name, 98 activities.emplace_back(handlers_[i]->package_name,
100 handlers_[i]->activity_name); 99 handlers_[i]->activity_name);
101 } 100 }
102 const ActivityIconLoader::GetResult result = icon_loader_->GetActivityIcons( 101 const ActivityIconLoader::GetResult result = icon_loader_->GetActivityIcons(
(...skipping 19 matching lines...) Expand all
122 121
123 std::vector<ash::LinkHandlerInfo> handlers; 122 std::vector<ash::LinkHandlerInfo> handlers;
124 for (size_t i = 0; i < handlers_.size(); ++i) { 123 for (size_t i = 0; i < handlers_.size(); ++i) {
125 gfx::Image icon; 124 gfx::Image icon;
126 const ActivityIconLoader::ActivityName activity( 125 const ActivityIconLoader::ActivityName activity(
127 handlers_[i]->package_name, handlers_[i]->activity_name); 126 handlers_[i]->package_name, handlers_[i]->activity_name);
128 const auto it = icons_.find(activity); 127 const auto it = icons_.find(activity);
129 if (it != icons_.end()) 128 if (it != icons_.end())
130 icon = it->second.icon16; 129 icon = it->second.icon16;
131 // Use the handler's index as an ID. 130 // Use the handler's index as an ID.
132 ash::LinkHandlerInfo handler = {handlers_[i]->name.get(), icon, i}; 131 ash::LinkHandlerInfo handler = {handlers_[i]->name, icon, i};
133 handlers.push_back(handler); 132 handlers.push_back(handler);
134 } 133 }
135 for (auto& observer : observer_list_) 134 for (auto& observer : observer_list_)
136 observer.ModelChanged(handlers); 135 observer.ModelChanged(handlers);
137 } 136 }
138 137
139 // static 138 // static
140 GURL LinkHandlerModelImpl::RewriteUrlFromQueryIfAvailableForTesting( 139 GURL LinkHandlerModelImpl::RewriteUrlFromQueryIfAvailableForTesting(
141 const GURL& url) { 140 const GURL& url) {
142 return RewriteUrlFromQueryIfAvailable(url); 141 return RewriteUrlFromQueryIfAvailable(url);
(...skipping 15 matching lines...) Expand all
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
« no previous file with comments | « components/arc/intent_helper/link_handler_model_impl.h ('k') | components/arc/intent_helper/local_activity_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698