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

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: review 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> 9 #include <vector>
Luis Héctor Chávez 2016/11/16 03:22:02 nit: remove?
Yusuke Sato 2016/11/16 06:10:21 Done.
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "components/arc/arc_bridge_service.h" 12 #include "components/arc/arc_bridge_service.h"
13 #include "components/arc/intent_helper/arc_intent_helper_bridge.h" 13 #include "components/arc/intent_helper/arc_intent_helper_bridge.h"
14 #include "components/google/core/browser/google_util.h" 14 #include "components/google/core/browser/google_util.h"
15 #include "url/gurl.h" 15 #include "url/gurl.h"
16 #include "url/url_util.h" 16 #include "url/url_util.h"
17 17
18 namespace arc { 18 namespace arc {
19 19
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 "HandleUrl", kMinInstanceVersion); 82 "HandleUrl", kMinInstanceVersion);
83 if (!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 instance->HandleUrl(rewritten.spec(), handlers_[handler_id]->package_name); 88 instance->HandleUrl(rewritten.spec(), handlers_[handler_id]->package_name);
89 } 89 }
90 90
91 void LinkHandlerModelImpl::OnUrlHandlerList( 91 void LinkHandlerModelImpl::OnUrlHandlerList(
92 mojo::Array<mojom::IntentHandlerInfoPtr> handlers) { 92 std::vector<mojom::IntentHandlerInfoPtr> handlers) {
93 handlers_ = ArcIntentHelperBridge::FilterOutIntentHelper(std::move(handlers)); 93 handlers_ = ArcIntentHelperBridge::FilterOutIntentHelper(std::move(handlers));
94 94
95 bool icon_info_notified = false; 95 bool icon_info_notified = false;
96 if (icon_loader_) { 96 if (icon_loader_) {
97 std::vector<ActivityIconLoader::ActivityName> activities; 97 std::vector<ActivityIconLoader::ActivityName> activities;
98 for (size_t i = 0; i < handlers_.size(); ++i) { 98 for (size_t i = 0; i < handlers_.size(); ++i) {
99 activities.emplace_back(handlers_[i]->package_name, 99 activities.emplace_back(handlers_[i]->package_name,
100 handlers_[i]->activity_name); 100 handlers_[i]->activity_name);
101 } 101 }
102 const ActivityIconLoader::GetResult result = icon_loader_->GetActivityIcons( 102 const ActivityIconLoader::GetResult result = icon_loader_->GetActivityIcons(
(...skipping 19 matching lines...) Expand all
122 122
123 std::vector<ash::LinkHandlerInfo> handlers; 123 std::vector<ash::LinkHandlerInfo> handlers;
124 for (size_t i = 0; i < handlers_.size(); ++i) { 124 for (size_t i = 0; i < handlers_.size(); ++i) {
125 gfx::Image icon; 125 gfx::Image icon;
126 const ActivityIconLoader::ActivityName activity( 126 const ActivityIconLoader::ActivityName activity(
127 handlers_[i]->package_name, handlers_[i]->activity_name); 127 handlers_[i]->package_name, handlers_[i]->activity_name);
128 const auto it = icons_.find(activity); 128 const auto it = icons_.find(activity);
129 if (it != icons_.end()) 129 if (it != icons_.end())
130 icon = it->second.icon16; 130 icon = it->second.icon16;
131 // Use the handler's index as an ID. 131 // Use the handler's index as an ID.
132 ash::LinkHandlerInfo handler = {handlers_[i]->name.get(), icon, i}; 132 ash::LinkHandlerInfo handler = {handlers_[i]->name, icon, i};
133 handlers.push_back(handler); 133 handlers.push_back(handler);
134 } 134 }
135 for (auto& observer : observer_list_) 135 for (auto& observer : observer_list_)
136 observer.ModelChanged(handlers); 136 observer.ModelChanged(handlers);
137 } 137 }
138 138
139 // static 139 // static
140 GURL LinkHandlerModelImpl::RewriteUrlFromQueryIfAvailableForTesting( 140 GURL LinkHandlerModelImpl::RewriteUrlFromQueryIfAvailableForTesting(
141 const GURL& url) { 141 const GURL& url) {
142 return RewriteUrlFromQueryIfAvailable(url); 142 return RewriteUrlFromQueryIfAvailable(url);
(...skipping 15 matching lines...) Expand all
158 if (!GetQueryValue(url, kKeyToFind, &value)) 158 if (!GetQueryValue(url, kKeyToFind, &value))
159 return url; 159 return url;
160 160
161 const GURL new_url(value); 161 const GURL new_url(value);
162 if (!new_url.is_valid()) 162 if (!new_url.is_valid())
163 return url; 163 return url;
164 return new_url; 164 return new_url;
165 } 165 }
166 166
167 } // namespace arc 167 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698