OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
Yusuke Sato
2016/11/04 16:18:06
If you haven't, please run git cl format and git c
djacobo_
2016/11/04 17:43:43
I (almost) always do, lint/format didn't suggest a
Yusuke Sato
2016/11/04 17:48:57
no, not really. was just a reminder.
| |
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/chromeos/arc/intent_helper/arc_external_protocol_dialog .h" | 5 #include "chrome/browser/chromeos/arc/intent_helper/arc_external_protocol_dialog .h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
33 using content::WebContents; | 33 using content::WebContents; |
34 | 34 |
35 namespace arc { | 35 namespace arc { |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
39 constexpr uint32_t kMinVersionForHandleUrl = 2; | 39 constexpr uint32_t kMinVersionForHandleUrl = 2; |
40 constexpr uint32_t kMinVersionForRequestUrlHandlerList = 2; | 40 constexpr uint32_t kMinVersionForRequestUrlHandlerList = 2; |
41 constexpr uint32_t kMinVersionForAddPreferredPackage = 7; | 41 constexpr uint32_t kMinVersionForAddPreferredPackage = 7; |
42 | 42 |
43 void RecordUma(ArcNavigationThrottle::CloseReason close_reason) { | 43 void RecordUma(ArcNavigationThrottle::CloseReason close_reason, |
44 ArcNavigationThrottle::Platform platform) { | |
44 UMA_HISTOGRAM_ENUMERATION( | 45 UMA_HISTOGRAM_ENUMERATION( |
45 "Arc.IntentHandlerAction", static_cast<int>(close_reason), | 46 "Arc.IntentHandlerAction", static_cast<int>(close_reason), |
46 static_cast<int>(ArcNavigationThrottle::CloseReason::SIZE)); | 47 static_cast<int>(ArcNavigationThrottle::CloseReason::SIZE)); |
48 | |
49 UMA_HISTOGRAM_ENUMERATION( | |
50 "Arc.IntentHandlerDestinationPlatform", static_cast<int>(platform), | |
51 static_cast<int>(ArcNavigationThrottle::Platform::SIZE)); | |
47 } | 52 } |
48 | 53 |
49 // Shows the Chrome OS' original external protocol dialog as a fallback. | 54 // Shows the Chrome OS' original external protocol dialog as a fallback. |
50 void ShowFallbackExternalProtocolDialog(int render_process_host_id, | 55 void ShowFallbackExternalProtocolDialog(int render_process_host_id, |
51 int routing_id, | 56 int routing_id, |
52 const GURL& url) { | 57 const GURL& url) { |
53 WebContents* web_contents = | 58 WebContents* web_contents = |
54 tab_util::GetWebContentsByID(render_process_host_id, routing_id); | 59 tab_util::GetWebContentsByID(render_process_host_id, routing_id); |
55 new ExternalProtocolDialog(web_contents, url); | 60 new ExternalProtocolDialog(web_contents, url); |
56 } | 61 } |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 << ", handlers.size=" << handlers.size(); | 269 << ", handlers.size=" << handlers.size(); |
265 // fall through. | 270 // fall through. |
266 } | 271 } |
267 case ArcNavigationThrottle::CloseReason::DIALOG_DEACTIVATED: { | 272 case ArcNavigationThrottle::CloseReason::DIALOG_DEACTIVATED: { |
268 // The user didn't select any ARC activity. Show the Chrome OS dialog. | 273 // The user didn't select any ARC activity. Show the Chrome OS dialog. |
269 ShowFallbackExternalProtocolDialog(render_process_host_id, routing_id, | 274 ShowFallbackExternalProtocolDialog(render_process_host_id, routing_id, |
270 url); | 275 url); |
271 break; | 276 break; |
272 } | 277 } |
273 } | 278 } |
274 RecordUma(close_reason); | 279 |
280 ArcNavigationThrottle::Platform platform = | |
281 ArcNavigationThrottle::GetDestinationPlatform(selected_app_package, | |
282 close_reason); | |
283 RecordUma(close_reason, platform); | |
275 } | 284 } |
276 | 285 |
277 // Called when ARC returned activity icons for the |handlers|. | 286 // Called when ARC returned activity icons for the |handlers|. |
278 void OnAppIconsReceived( | 287 void OnAppIconsReceived( |
279 int render_process_host_id, | 288 int render_process_host_id, |
280 int routing_id, | 289 int routing_id, |
281 const GURL& url, | 290 const GURL& url, |
282 mojo::Array<mojom::IntentHandlerInfoPtr> handlers, | 291 mojo::Array<mojom::IntentHandlerInfoPtr> handlers, |
283 std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> icons) { | 292 std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> icons) { |
284 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 293 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 if (!instance || !icon_loader) { | 326 if (!instance || !icon_loader) { |
318 // ARC is not running anymore. Show the Chrome OS dialog. | 327 // ARC is not running anymore. Show the Chrome OS dialog. |
319 ShowFallbackExternalProtocolDialog(render_process_host_id, routing_id, url); | 328 ShowFallbackExternalProtocolDialog(render_process_host_id, routing_id, url); |
320 return; | 329 return; |
321 } | 330 } |
322 | 331 |
323 // Check if the |url| should be handled right away without showing the UI. | 332 // Check if the |url| should be handled right away without showing the UI. |
324 GetActionResult result; | 333 GetActionResult result; |
325 if (HandleUrl(render_process_host_id, routing_id, url, handlers, | 334 if (HandleUrl(render_process_host_id, routing_id, url, handlers, |
326 handlers.size(), &result)) { | 335 handlers.size(), &result)) { |
327 if (result == GetActionResult::HANDLE_URL_IN_ARC) | 336 if (result == GetActionResult::HANDLE_URL_IN_ARC) |
Yusuke Sato
2016/11/04 16:18:06
Since the RecordUma() call is multi-line, please u
djacobo_
2016/11/04 17:43:43
Done.
| |
328 RecordUma(ArcNavigationThrottle::CloseReason::PREFERRED_ACTIVITY_FOUND); | 337 RecordUma(ArcNavigationThrottle::CloseReason::PREFERRED_ACTIVITY_FOUND, |
338 ArcNavigationThrottle::Platform::ARC); | |
329 return; // the |url| has been handled. | 339 return; // the |url| has been handled. |
330 } | 340 } |
331 | 341 |
332 // Otherwise, retrieve icons of the activities. | 342 // Otherwise, retrieve icons of the activities. |
333 std::vector<ActivityIconLoader::ActivityName> activities; | 343 std::vector<ActivityIconLoader::ActivityName> activities; |
334 for (const auto& handler : handlers) { | 344 for (const auto& handler : handlers) { |
335 activities.emplace_back(handler->package_name, handler->activity_name); | 345 activities.emplace_back(handler->package_name, handler->activity_name); |
336 } | 346 } |
337 icon_loader->GetActivityIcons( | 347 icon_loader->GetActivityIcons( |
338 activities, base::Bind(OnAppIconsReceived, render_process_host_id, | 348 activities, base::Bind(OnAppIconsReceived, render_process_host_id, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 GetActionResult GetActionForTesting( | 403 GetActionResult GetActionForTesting( |
394 const GURL& original_url, | 404 const GURL& original_url, |
395 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, | 405 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, |
396 size_t selected_app_index, | 406 size_t selected_app_index, |
397 std::pair<GURL, std::string>* out_url_and_package) { | 407 std::pair<GURL, std::string>* out_url_and_package) { |
398 return GetAction(original_url, handlers, selected_app_index, | 408 return GetAction(original_url, handlers, selected_app_index, |
399 out_url_and_package); | 409 out_url_and_package); |
400 } | 410 } |
401 | 411 |
402 } // namespace arc | 412 } // namespace arc |
OLD | NEW |