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

Side by Side Diff: chrome/browser/extensions/api/dial/dial_device_data.cc

Issue 23064011: Consolidate scheme checks into an easy GURL method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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
OLDNEW
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
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
OLDNEW
« no previous file with comments | « chrome/browser/android/intercept_download_resource_throttle.cc ('k') | chrome/browser/google/google_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698