| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/usb/web_usb_detector.h" | 5 #include "chrome/browser/usb/web_usb_detector.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 WEBUSB_NOTIFICATION_CLOSED_MAX | 60 WEBUSB_NOTIFICATION_CLOSED_MAX |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 void RecordNotificationClosure(WebUsbNotificationClosed disposition) { | 63 void RecordNotificationClosure(WebUsbNotificationClosed disposition) { |
| 64 UMA_HISTOGRAM_ENUMERATION("WebUsb.NotificationClosed", disposition, | 64 UMA_HISTOGRAM_ENUMERATION("WebUsb.NotificationClosed", disposition, |
| 65 WEBUSB_NOTIFICATION_CLOSED_MAX); | 65 WEBUSB_NOTIFICATION_CLOSED_MAX); |
| 66 } | 66 } |
| 67 | 67 |
| 68 Browser* GetBrowser() { | 68 Browser* GetBrowser() { |
| 69 chrome::ScopedTabbedBrowserDisplayer browser_displayer( | 69 chrome::ScopedTabbedBrowserDisplayer browser_displayer( |
| 70 ProfileManager::GetActiveUserProfile()); | 70 ProfileManager::GetLastUsedProfileAllowedByPolicy()); |
| 71 DCHECK(browser_displayer.browser()); | 71 DCHECK(browser_displayer.browser()); |
| 72 return browser_displayer.browser(); | 72 return browser_displayer.browser(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void OpenURL(const GURL& url) { | 75 void OpenURL(const GURL& url) { |
| 76 GetBrowser()->OpenURL(content::OpenURLParams( | 76 GetBrowser()->OpenURL(content::OpenURLParams( |
| 77 url, content::Referrer(), WindowOpenDisposition::NEW_FOREGROUND_TAB, | 77 url, content::Referrer(), WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 78 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, false /* is_renderer_initialized */)); | 78 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, false /* is_renderer_initialized */)); |
| 79 } | 79 } |
| 80 | 80 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } | 167 } |
| 168 | 168 |
| 169 void WebUsbDetector::OnDeviceRemoved(scoped_refptr<device::UsbDevice> device) { | 169 void WebUsbDetector::OnDeviceRemoved(scoped_refptr<device::UsbDevice> device) { |
| 170 std::string notification_id = device->guid(); | 170 std::string notification_id = device->guid(); |
| 171 message_center::MessageCenter* message_center = | 171 message_center::MessageCenter* message_center = |
| 172 message_center::MessageCenter::Get(); | 172 message_center::MessageCenter::Get(); |
| 173 if (message_center->FindVisibleNotificationById(notification_id)) { | 173 if (message_center->FindVisibleNotificationById(notification_id)) { |
| 174 message_center->RemoveNotification(notification_id, false /* by_user */); | 174 message_center->RemoveNotification(notification_id, false /* by_user */); |
| 175 } | 175 } |
| 176 } | 176 } |
| OLD | NEW |