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

Side by Side Diff: chrome/browser/web_resource/promo_resource_service.cc

Issue 7661009: base: Add Is* functions to Value class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tony review Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/sync_setup_handler.cc ('k') | chrome/common/extensions/extension.cc » ('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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/web_resource/promo_resource_service.h" 5 #include "chrome/browser/web_resource/promo_resource_service.h"
6 6
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/threading/thread_restrictions.h" 8 #include "base/threading/thread_restrictions.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 if (parsed_json.GetDictionary("topic", &topic_dict)) { 219 if (parsed_json.GetDictionary("topic", &topic_dict)) {
220 if (topic_dict->GetList("answers", &answer_list)) { 220 if (topic_dict->GetList("answers", &answer_list)) {
221 std::string promo_start_string = ""; 221 std::string promo_start_string = "";
222 std::string promo_end_string = ""; 222 std::string promo_end_string = "";
223 std::string promo_string = ""; 223 std::string promo_string = "";
224 std::string promo_build = ""; 224 std::string promo_build = "";
225 int promo_build_type = 0; 225 int promo_build_type = 0;
226 int time_slice_hrs = 0; 226 int time_slice_hrs = 0;
227 for (ListValue::const_iterator answer_iter = answer_list->begin(); 227 for (ListValue::const_iterator answer_iter = answer_list->begin();
228 answer_iter != answer_list->end(); ++answer_iter) { 228 answer_iter != answer_list->end(); ++answer_iter) {
229 if (!(*answer_iter)->IsType(Value::TYPE_DICTIONARY)) 229 if (!(*answer_iter)->IsDictionary())
230 continue; 230 continue;
231 DictionaryValue* a_dic = 231 DictionaryValue* a_dic =
232 static_cast<DictionaryValue*>(*answer_iter); 232 static_cast<DictionaryValue*>(*answer_iter);
233 std::string promo_signal; 233 std::string promo_signal;
234 if (a_dic->GetString("name", &promo_signal)) { 234 if (a_dic->GetString("name", &promo_signal)) {
235 if (promo_signal == "promo_start") { 235 if (promo_signal == "promo_start") {
236 a_dic->GetString("question", &promo_build); 236 a_dic->GetString("question", &promo_build);
237 size_t split = promo_build.find(":"); 237 size_t split = promo_build.find(":");
238 if (split != std::string::npos && 238 if (split != std::string::npos &&
239 base::StringToInt(promo_build.substr(0, split), 239 base::StringToInt(promo_build.substr(0, split),
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 std::string promo_logo = ""; 311 std::string promo_logo = "";
312 int maximize_setting = 0; 312 int maximize_setting = 0;
313 int target_builds = 0; 313 int target_builds = 0;
314 314
315 if (!parsed_json.GetDictionary("topic", &topic_dict) || 315 if (!parsed_json.GetDictionary("topic", &topic_dict) ||
316 !topic_dict->GetList("answers", &answer_list)) 316 !topic_dict->GetList("answers", &answer_list))
317 return; 317 return;
318 318
319 for (ListValue::const_iterator answer_iter = answer_list->begin(); 319 for (ListValue::const_iterator answer_iter = answer_list->begin();
320 answer_iter != answer_list->end(); ++answer_iter) { 320 answer_iter != answer_list->end(); ++answer_iter) {
321 if (!(*answer_iter)->IsType(Value::TYPE_DICTIONARY)) 321 if (!(*answer_iter)->IsDictionary())
322 continue; 322 continue;
323 DictionaryValue* a_dic = 323 DictionaryValue* a_dic =
324 static_cast<DictionaryValue*>(*answer_iter); 324 static_cast<DictionaryValue*>(*answer_iter);
325 325
326 // The "name" field has three different values packed into it, each 326 // The "name" field has three different values packed into it, each
327 // separated by a ':'. 327 // separated by a ':'.
328 std::string name; 328 std::string name;
329 if (!a_dic->GetString("name", &name)) 329 if (!a_dic->GetString("name", &name))
330 continue; 330 continue;
331 331
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 old_logo_end = prefs_->GetDouble(prefs::kNTPCustomLogoEnd); 403 old_logo_end = prefs_->GetDouble(prefs::kNTPCustomLogoEnd);
404 } 404 }
405 405
406 // Check for newly received start and end values. 406 // Check for newly received start and end values.
407 if (parsed_json.GetDictionary("topic", &topic_dict)) { 407 if (parsed_json.GetDictionary("topic", &topic_dict)) {
408 if (topic_dict->GetList("answers", &answer_list)) { 408 if (topic_dict->GetList("answers", &answer_list)) {
409 std::string logo_start_string = ""; 409 std::string logo_start_string = "";
410 std::string logo_end_string = ""; 410 std::string logo_end_string = "";
411 for (ListValue::const_iterator answer_iter = answer_list->begin(); 411 for (ListValue::const_iterator answer_iter = answer_list->begin();
412 answer_iter != answer_list->end(); ++answer_iter) { 412 answer_iter != answer_list->end(); ++answer_iter) {
413 if (!(*answer_iter)->IsType(Value::TYPE_DICTIONARY)) 413 if (!(*answer_iter)->IsDictionary())
414 continue; 414 continue;
415 DictionaryValue* a_dic = 415 DictionaryValue* a_dic =
416 static_cast<DictionaryValue*>(*answer_iter); 416 static_cast<DictionaryValue*>(*answer_iter);
417 std::string logo_signal; 417 std::string logo_signal;
418 if (a_dic->GetString("name", &logo_signal)) { 418 if (a_dic->GetString("name", &logo_signal)) {
419 if (logo_signal == "custom_logo_start") { 419 if (logo_signal == "custom_logo_start") {
420 a_dic->GetString("inproduct", &logo_start_string); 420 a_dic->GetString("inproduct", &logo_start_string);
421 } else if (logo_signal == "custom_logo_end") { 421 } else if (logo_signal == "custom_logo_end") {
422 a_dic->GetString("inproduct", &logo_end_string); 422 a_dic->GetString("inproduct", &logo_end_string);
423 } 423 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 base::ThreadRestrictions::ScopedAllowIO allow_io; 473 base::ThreadRestrictions::ScopedAllowIO allow_io;
474 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); 474 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
475 is_promo_build = PromoResourceService::IsBuildTargeted( 475 is_promo_build = PromoResourceService::IsBuildTargeted(
476 channel, prefs->GetInteger(prefs::kNTPPromoBuild)); 476 channel, prefs->GetInteger(prefs::kNTPPromoBuild));
477 } 477 }
478 478
479 return !promo_closed && !is_synced && is_promo_build; 479 return !promo_closed && !is_synced && is_promo_build;
480 } 480 }
481 481
482 } // namespace PromoResourceServiceUtil 482 } // namespace PromoResourceServiceUtil
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/sync_setup_handler.cc ('k') | chrome/common/extensions/extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698