OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/api/dial/dial_device_data.h" | 5 #include "chrome/browser/extensions/api/dial/dial_device_data.h" |
6 | 6 |
7 #include "chrome/common/extensions/api/dial.h" | 7 #include "chrome/common/extensions/api/dial.h" |
8 | 8 |
9 namespace extensions { | 9 namespace extensions { |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 const GURL& DialDeviceData::device_description_url() const { | 22 const GURL& DialDeviceData::device_description_url() const { |
23 return device_description_url_; | 23 return device_description_url_; |
24 } | 24 } |
25 | 25 |
26 void DialDeviceData::set_device_description_url(const GURL& url) { | 26 void DialDeviceData::set_device_description_url(const GURL& url) { |
27 device_description_url_ = url; | 27 device_description_url_ = url; |
28 } | 28 } |
29 | 29 |
30 // static | 30 // static |
31 bool DialDeviceData::IsDeviceDescriptionUrl(const GURL& url) { | 31 bool DialDeviceData::IsDeviceDescriptionUrl(const GURL& url) { |
32 return url.is_valid() && !url.is_empty() && | 32 return url.is_valid() && !url.is_empty() && url.SchemeIsHTTPOrHTTPS(); |
33 (url.SchemeIs("http") || url.SchemeIs("https")); | |
34 } | 33 } |
35 | 34 |
36 bool DialDeviceData::UpdateFrom(const DialDeviceData& new_data) { | 35 bool DialDeviceData::UpdateFrom(const DialDeviceData& new_data) { |
37 DCHECK(new_data.device_id() == device_id_); | 36 DCHECK(new_data.device_id() == device_id_); |
38 DCHECK(new_data.label().empty()); | 37 DCHECK(new_data.label().empty()); |
39 std::string label_tmp(label_); | 38 std::string label_tmp(label_); |
40 bool updated_api_visible_field = | 39 bool updated_api_visible_field = |
41 (new_data.device_description_url() != device_description_url_) || | 40 (new_data.device_description_url() != device_description_url_) || |
42 (new_data.config_id() != config_id_); | 41 (new_data.config_id() != config_id_); |
43 *this = new_data; | 42 *this = new_data; |
44 label_ = label_tmp; | 43 label_ = label_tmp; |
45 return updated_api_visible_field; | 44 return updated_api_visible_field; |
46 } | 45 } |
47 | 46 |
48 void DialDeviceData::FillDialDevice(api::dial::DialDevice* device) const { | 47 void DialDeviceData::FillDialDevice(api::dial::DialDevice* device) const { |
49 DCHECK(!device_id_.empty()); | 48 DCHECK(!device_id_.empty()); |
50 DCHECK(IsDeviceDescriptionUrl(device_description_url_)); | 49 DCHECK(IsDeviceDescriptionUrl(device_description_url_)); |
51 device->device_label = label_; | 50 device->device_label = label_; |
52 device->device_description_url = device_description_url_.spec(); | 51 device->device_description_url = device_description_url_.spec(); |
53 if (has_config_id()) | 52 if (has_config_id()) |
54 device->config_id.reset(new int(config_id_)); | 53 device->config_id.reset(new int(config_id_)); |
55 } | 54 } |
56 | 55 |
57 } // namespace extensions | 56 } // namespace extensions |
OLD | NEW |