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

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

Issue 2746313002: Remove RenderFrameHost pointer from ChooserController. (Closed)
Patch Set: Fix Android build and juncai@ comment. Created 3 years, 9 months 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 | « chrome/browser/usb/usb_chooser_context.h ('k') | chrome/browser/usb/usb_chooser_controller.h » ('j') | 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/usb_chooser_context.h" 5 #include "chrome/browser/usb/usb_chooser_context.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 bool CanStorePersistentEntry(const scoped_refptr<const UsbDevice>& device) { 48 bool CanStorePersistentEntry(const scoped_refptr<const UsbDevice>& device) {
49 return !device->serial_number().empty(); 49 return !device->serial_number().empty();
50 } 50 }
51 51
52 } // namespace 52 } // namespace
53 53
54 UsbChooserContext::UsbChooserContext(Profile* profile) 54 UsbChooserContext::UsbChooserContext(Profile* profile)
55 : ChooserContextBase(profile, CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA), 55 : ChooserContextBase(profile, CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA),
56 is_incognito_(profile->IsOffTheRecord()), 56 is_incognito_(profile->IsOffTheRecord()),
57 observer_(this) { 57 observer_(this),
58 weak_factory_(this) {
58 usb_service_ = device::DeviceClient::Get()->GetUsbService(); 59 usb_service_ = device::DeviceClient::Get()->GetUsbService();
59 if (usb_service_) 60 if (usb_service_)
60 observer_.Add(usb_service_); 61 observer_.Add(usb_service_);
61 } 62 }
62 63
63 UsbChooserContext::~UsbChooserContext() {} 64 UsbChooserContext::~UsbChooserContext() {}
64 65
65 std::vector<std::unique_ptr<base::DictionaryValue>> 66 std::vector<std::unique_ptr<base::DictionaryValue>>
66 UsbChooserContext::GetGrantedObjects(const GURL& requesting_origin, 67 UsbChooserContext::GetGrantedObjects(const GURL& requesting_origin,
67 const GURL& embedding_origin) { 68 const GURL& embedding_origin) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 device->product_id() == product_id && 177 device->product_id() == product_id &&
177 device_dict->GetString(kSerialNumberKey, &serial_number) && 178 device_dict->GetString(kSerialNumberKey, &serial_number) &&
178 device->serial_number() == serial_number) { 179 device->serial_number() == serial_number) {
179 return true; 180 return true;
180 } 181 }
181 } 182 }
182 183
183 return false; 184 return false;
184 } 185 }
185 186
187 base::WeakPtr<UsbChooserContext> UsbChooserContext::AsWeakPtr() {
188 return weak_factory_.GetWeakPtr();
189 }
190
186 bool UsbChooserContext::IsValidObject(const base::DictionaryValue& object) { 191 bool UsbChooserContext::IsValidObject(const base::DictionaryValue& object) {
187 return object.size() == 4 && object.HasKey(kDeviceNameKey) && 192 return object.size() == 4 && object.HasKey(kDeviceNameKey) &&
188 object.HasKey(kVendorIdKey) && object.HasKey(kProductIdKey) && 193 object.HasKey(kVendorIdKey) && object.HasKey(kProductIdKey) &&
189 object.HasKey(kSerialNumberKey); 194 object.HasKey(kSerialNumberKey);
190 } 195 }
191 196
192 void UsbChooserContext::OnDeviceRemoved(scoped_refptr<UsbDevice> device) { 197 void UsbChooserContext::OnDeviceRemoved(scoped_refptr<UsbDevice> device) {
193 for (auto& map_entry : ephemeral_devices_) 198 for (auto& map_entry : ephemeral_devices_)
194 map_entry.second.erase(device->guid()); 199 map_entry.second.erase(device->guid());
195 } 200 }
OLDNEW
« no previous file with comments | « chrome/browser/usb/usb_chooser_context.h ('k') | chrome/browser/usb/usb_chooser_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698