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

Side by Side Diff: chrome/browser/usb/web_usb_detector.cc

Issue 2505433002: Open link from WebUSB in the last used profile. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698