OLD | NEW |
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 "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" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/metrics/histogram_macros.h" | |
14 #include "chrome/browser/chromeos/arc/intent_helper/arc_navigation_throttle.h" | 13 #include "chrome/browser/chromeos/arc/intent_helper/arc_navigation_throttle.h" |
15 #include "chrome/browser/chromeos/external_protocol_dialog.h" | 14 #include "chrome/browser/chromeos/external_protocol_dialog.h" |
16 #include "chrome/browser/tab_contents/tab_util.h" | 15 #include "chrome/browser/tab_contents/tab_util.h" |
17 #include "chrome/browser/ui/browser_dialogs.h" | 16 #include "chrome/browser/ui/browser_dialogs.h" |
18 #include "components/arc/arc_bridge_service.h" | 17 #include "components/arc/arc_bridge_service.h" |
19 #include "components/arc/arc_service_manager.h" | 18 #include "components/arc/arc_service_manager.h" |
20 #include "components/arc/intent_helper/activity_icon_loader.h" | 19 #include "components/arc/intent_helper/activity_icon_loader.h" |
21 #include "components/arc/intent_helper/arc_intent_helper_bridge.h" | 20 #include "components/arc/intent_helper/arc_intent_helper_bridge.h" |
22 #include "components/arc/intent_helper/page_transition_util.h" | 21 #include "components/arc/intent_helper/page_transition_util.h" |
23 #include "content/public/browser/browser_context.h" | 22 #include "content/public/browser/browser_context.h" |
24 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
25 #include "content/public/browser/page_navigator.h" | 24 #include "content/public/browser/page_navigator.h" |
26 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
27 #include "content/public/common/referrer.h" | 26 #include "content/public/common/referrer.h" |
28 #include "ui/base/page_transition_types.h" | 27 #include "ui/base/page_transition_types.h" |
29 #include "ui/base/window_open_disposition.h" | 28 #include "ui/base/window_open_disposition.h" |
30 #include "ui/gfx/image/image.h" | 29 #include "ui/gfx/image/image.h" |
31 #include "url/gurl.h" | 30 #include "url/gurl.h" |
32 | 31 |
33 using content::WebContents; | 32 using content::WebContents; |
34 | 33 |
35 namespace arc { | 34 namespace arc { |
36 | 35 |
37 namespace { | 36 namespace { |
38 | 37 |
39 constexpr uint32_t kMinVersionForHandleUrl = 2; | 38 constexpr uint32_t kMinVersionForHandleUrl = 2; |
40 constexpr uint32_t kMinVersionForRequestUrlHandlerList = 2; | 39 constexpr uint32_t kMinVersionForRequestUrlHandlerList = 2; |
41 constexpr uint32_t kMinVersionForAddPreferredPackage = 7; | 40 constexpr uint32_t kMinVersionForAddPreferredPackage = 7; |
42 | 41 |
43 void RecordUma(ArcNavigationThrottle::CloseReason close_reason) { | |
44 UMA_HISTOGRAM_ENUMERATION( | |
45 "Arc.IntentHandlerAction", static_cast<int>(close_reason), | |
46 static_cast<int>(ArcNavigationThrottle::CloseReason::SIZE)); | |
47 } | |
48 | |
49 // Shows the Chrome OS' original external protocol dialog as a fallback. | 42 // Shows the Chrome OS' original external protocol dialog as a fallback. |
50 void ShowFallbackExternalProtocolDialog(int render_process_host_id, | 43 void ShowFallbackExternalProtocolDialog(int render_process_host_id, |
51 int routing_id, | 44 int routing_id, |
52 const GURL& url) { | 45 const GURL& url) { |
53 WebContents* web_contents = | 46 WebContents* web_contents = |
54 tab_util::GetWebContentsByID(render_process_host_id, routing_id); | 47 tab_util::GetWebContentsByID(render_process_host_id, routing_id); |
55 new ExternalProtocolDialog(web_contents, url); | 48 new ExternalProtocolDialog(web_contents, url); |
56 } | 49 } |
57 | 50 |
58 scoped_refptr<ActivityIconLoader> GetIconLoader() { | 51 scoped_refptr<ActivityIconLoader> GetIconLoader() { |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 << ", handlers.size=" << handlers.size(); | 257 << ", handlers.size=" << handlers.size(); |
265 // fall through. | 258 // fall through. |
266 } | 259 } |
267 case ArcNavigationThrottle::CloseReason::DIALOG_DEACTIVATED: { | 260 case ArcNavigationThrottle::CloseReason::DIALOG_DEACTIVATED: { |
268 // The user didn't select any ARC activity. Show the Chrome OS dialog. | 261 // The user didn't select any ARC activity. Show the Chrome OS dialog. |
269 ShowFallbackExternalProtocolDialog(render_process_host_id, routing_id, | 262 ShowFallbackExternalProtocolDialog(render_process_host_id, routing_id, |
270 url); | 263 url); |
271 break; | 264 break; |
272 } | 265 } |
273 } | 266 } |
274 RecordUma(close_reason); | 267 |
| 268 ArcNavigationThrottle::Platform platform = |
| 269 ArcNavigationThrottle::GetDestinationPlatform(selected_app_package, |
| 270 close_reason); |
| 271 ArcNavigationThrottle::RecordUma(close_reason, platform); |
275 } | 272 } |
276 | 273 |
277 // Called when ARC returned activity icons for the |handlers|. | 274 // Called when ARC returned activity icons for the |handlers|. |
278 void OnAppIconsReceived( | 275 void OnAppIconsReceived( |
279 int render_process_host_id, | 276 int render_process_host_id, |
280 int routing_id, | 277 int routing_id, |
281 const GURL& url, | 278 const GURL& url, |
282 mojo::Array<mojom::IntentHandlerInfoPtr> handlers, | 279 mojo::Array<mojom::IntentHandlerInfoPtr> handlers, |
283 std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> icons) { | 280 std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> icons) { |
284 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 281 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 if (!instance || !icon_loader) { | 314 if (!instance || !icon_loader) { |
318 // ARC is not running anymore. Show the Chrome OS dialog. | 315 // ARC is not running anymore. Show the Chrome OS dialog. |
319 ShowFallbackExternalProtocolDialog(render_process_host_id, routing_id, url); | 316 ShowFallbackExternalProtocolDialog(render_process_host_id, routing_id, url); |
320 return; | 317 return; |
321 } | 318 } |
322 | 319 |
323 // Check if the |url| should be handled right away without showing the UI. | 320 // Check if the |url| should be handled right away without showing the UI. |
324 GetActionResult result; | 321 GetActionResult result; |
325 if (HandleUrl(render_process_host_id, routing_id, url, handlers, | 322 if (HandleUrl(render_process_host_id, routing_id, url, handlers, |
326 handlers.size(), &result)) { | 323 handlers.size(), &result)) { |
327 if (result == GetActionResult::HANDLE_URL_IN_ARC) | 324 if (result == GetActionResult::HANDLE_URL_IN_ARC) { |
328 RecordUma(ArcNavigationThrottle::CloseReason::PREFERRED_ACTIVITY_FOUND); | 325 ArcNavigationThrottle::RecordUma( |
| 326 ArcNavigationThrottle::CloseReason::PREFERRED_ACTIVITY_FOUND, |
| 327 ArcNavigationThrottle::Platform::ARC); |
| 328 } |
329 return; // the |url| has been handled. | 329 return; // the |url| has been handled. |
330 } | 330 } |
331 | 331 |
332 // Otherwise, retrieve icons of the activities. | 332 // Otherwise, retrieve icons of the activities. |
333 std::vector<ActivityIconLoader::ActivityName> activities; | 333 std::vector<ActivityIconLoader::ActivityName> activities; |
334 for (const auto& handler : handlers) { | 334 for (const auto& handler : handlers) { |
335 activities.emplace_back(handler->package_name, handler->activity_name); | 335 activities.emplace_back(handler->package_name, handler->activity_name); |
336 } | 336 } |
337 icon_loader->GetActivityIcons( | 337 icon_loader->GetActivityIcons( |
338 activities, base::Bind(OnAppIconsReceived, render_process_host_id, | 338 activities, base::Bind(OnAppIconsReceived, render_process_host_id, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 GetActionResult GetActionForTesting( | 393 GetActionResult GetActionForTesting( |
394 const GURL& original_url, | 394 const GURL& original_url, |
395 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, | 395 const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers, |
396 size_t selected_app_index, | 396 size_t selected_app_index, |
397 std::pair<GURL, std::string>* out_url_and_package) { | 397 std::pair<GURL, std::string>* out_url_and_package) { |
398 return GetAction(original_url, handlers, selected_app_index, | 398 return GetAction(original_url, handlers, selected_app_index, |
399 out_url_and_package); | 399 out_url_and_package); |
400 } | 400 } |
401 | 401 |
402 } // namespace arc | 402 } // namespace arc |
OLD | NEW |