| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extension_rlz_module.h" | 5 #include "chrome/browser/extensions/extension_rlz_module.h" |
| 6 | 6 |
| 7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "chrome/browser/rlz/rlz.h" | 8 #include "chrome/browser/rlz/rlz.h" |
| 9 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
| 10 #include "rlz/win/lib/lib_values.h" | 10 #include "rlz/win/lib/lib_values.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 rlz_lib::AccessPoint access_point; | 95 rlz_lib::AccessPoint access_point; |
| 96 EXTENSION_FUNCTION_VALIDATE(rlz_lib::GetAccessPointFromName(ap_name.c_str(), | 96 EXTENSION_FUNCTION_VALIDATE(rlz_lib::GetAccessPointFromName(ap_name.c_str(), |
| 97 &access_point)); | 97 &access_point)); |
| 98 | 98 |
| 99 char rlz[rlz_lib::kMaxRlzLength + 1]; | 99 char rlz[rlz_lib::kMaxRlzLength + 1]; |
| 100 rlz_lib::GetAccessPointRlz(access_point, rlz, rlz_lib::kMaxRlzLength); | 100 rlz_lib::GetAccessPointRlz(access_point, rlz, rlz_lib::kMaxRlzLength); |
| 101 result_.reset(Value::CreateStringValue(rlz)); | 101 result_.reset(Value::CreateStringValue(rlz)); |
| 102 return true; | 102 return true; |
| 103 } | 103 } |
| 104 | 104 |
| 105 bool RlzSendFinancialPingFunction::RunImpl() { |
| 106 std::string product_name; |
| 107 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &product_name)); |
| 108 rlz_lib::Product product; |
| 109 EXTENSION_FUNCTION_VALIDATE(GetProductFromName(product_name, &product)); |
| 110 |
| 111 ListValue* access_points_list; |
| 112 EXTENSION_FUNCTION_VALIDATE(args_->GetList(1, &access_points_list)); |
| 113 if (access_points_list->GetSize() < 1) { |
| 114 EXTENSION_FUNCTION_ERROR("Access point array should not be empty."); |
| 115 } |
| 116 |
| 117 // Allocate an access point array to pass to ClearProductState(). The array |
| 118 // must be termindated with the value rlz_lib::NO_ACCESS_POINT, hence + 1 |
| 119 // when allocating the array. |
| 120 scoped_array<rlz_lib::AccessPoint> access_points( |
| 121 new rlz_lib::AccessPoint[access_points_list->GetSize() + 1]); |
| 122 |
| 123 size_t i; |
| 124 for (i = 0; i < access_points_list->GetSize(); ++i) { |
| 125 std::string ap_name; |
| 126 EXTENSION_FUNCTION_VALIDATE(access_points_list->GetString(i, &ap_name)); |
| 127 EXTENSION_FUNCTION_VALIDATE(rlz_lib::GetAccessPointFromName( |
| 128 ap_name.c_str(), &access_points[i])); |
| 129 } |
| 130 access_points[i] = rlz_lib::NO_ACCESS_POINT; |
| 131 |
| 132 std::string signature; |
| 133 EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &signature)); |
| 134 |
| 135 std::string brand; |
| 136 EXTENSION_FUNCTION_VALIDATE(args_->GetString(3, &brand)); |
| 137 |
| 138 std::string id; |
| 139 EXTENSION_FUNCTION_VALIDATE(args_->GetString(4, &id)); |
| 140 |
| 141 std::string lang; |
| 142 EXTENSION_FUNCTION_VALIDATE(args_->GetString(5, &lang)); |
| 143 |
| 144 bool exclude_machine_id; |
| 145 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(6, &exclude_machine_id)); |
| 146 |
| 147 return rlz_lib::SendFinancialPing(product, access_points.get(), |
| 148 signature.c_str(), brand.c_str(), |
| 149 id.c_str(), lang.c_str(), |
| 150 exclude_machine_id); |
| 151 } |
| 152 |
| 105 bool RlzClearProductStateFunction::RunImpl() { | 153 bool RlzClearProductStateFunction::RunImpl() { |
| 106 std::string product_name; | 154 std::string product_name; |
| 107 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &product_name)); | 155 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &product_name)); |
| 108 rlz_lib::Product product; | 156 rlz_lib::Product product; |
| 109 EXTENSION_FUNCTION_VALIDATE(GetProductFromName(product_name, &product)); | 157 EXTENSION_FUNCTION_VALIDATE(GetProductFromName(product_name, &product)); |
| 110 | 158 |
| 111 ListValue* access_points_list; | 159 ListValue* access_points_list; |
| 112 EXTENSION_FUNCTION_VALIDATE(args_->GetList(1, &access_points_list)); | 160 EXTENSION_FUNCTION_VALIDATE(args_->GetList(1, &access_points_list)); |
| 113 if (access_points_list->GetSize() < 1) { | 161 if (access_points_list->GetSize() < 1) { |
| 114 EXTENSION_FUNCTION_ERROR("Access point array should not be empty."); | 162 EXTENSION_FUNCTION_ERROR("Access point array should not be empty."); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 125 std::string ap_name; | 173 std::string ap_name; |
| 126 EXTENSION_FUNCTION_VALIDATE(access_points_list->GetString(i, &ap_name)); | 174 EXTENSION_FUNCTION_VALIDATE(access_points_list->GetString(i, &ap_name)); |
| 127 EXTENSION_FUNCTION_VALIDATE(rlz_lib::GetAccessPointFromName( | 175 EXTENSION_FUNCTION_VALIDATE(rlz_lib::GetAccessPointFromName( |
| 128 ap_name.c_str(), &access_points[i])); | 176 ap_name.c_str(), &access_points[i])); |
| 129 } | 177 } |
| 130 access_points[i] = rlz_lib::NO_ACCESS_POINT; | 178 access_points[i] = rlz_lib::NO_ACCESS_POINT; |
| 131 | 179 |
| 132 rlz_lib::ClearProductState(product, access_points.get()); | 180 rlz_lib::ClearProductState(product, access_points.get()); |
| 133 return true; | 181 return true; |
| 134 } | 182 } |
| OLD | NEW |