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/web_resource/notification_promo.h" | 5 #include "chrome/browser/web_resource/notification_promo.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
13 #include "base/time.h" | 13 #include "base/time.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/net/browser_url_util.h" | |
16 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
17 #include "chrome/browser/profiles/profile_impl.h" | 16 #include "chrome/browser/profiles/profile_impl.h" |
18 #include "chrome/browser/web_resource/promo_resource_service.h" | 17 #include "chrome/browser/web_resource/promo_resource_service.h" |
19 #include "chrome/common/chrome_version_info.h" | 18 #include "chrome/common/chrome_version_info.h" |
| 19 #include "chrome/common/net/url_util.h" |
20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
21 #include "content/public/browser/user_metrics.h" | 21 #include "content/public/browser/user_metrics.h" |
22 #include "googleurl/src/gurl.h" | 22 #include "googleurl/src/gurl.h" |
23 | 23 |
24 using content::UserMetricsAction; | 24 using content::UserMetricsAction; |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 // Users are randomly assigned to one of kDefaultGroupSize + 1 buckets, in order | 28 // Users are randomly assigned to one of kDefaultGroupSize + 1 buckets, in order |
29 // to be able to roll out promos slowly, or display different promos to | 29 // to be able to roll out promos slowly, or display different promos to |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 #elif defined(OS_LINUX) | 438 #elif defined(OS_LINUX) |
439 return PLATFORM_LINUX; | 439 return PLATFORM_LINUX; |
440 #else | 440 #else |
441 return PLATFORM_NONE; | 441 return PLATFORM_NONE; |
442 #endif | 442 #endif |
443 } | 443 } |
444 | 444 |
445 // static | 445 // static |
446 GURL NotificationPromo::PromoServerURL() { | 446 GURL NotificationPromo::PromoServerURL() { |
447 GURL url(promo_server_url); | 447 GURL url(promo_server_url); |
448 url = chrome_browser_net::AppendQueryParameter( | 448 url = chrome_common_net::AppendQueryParameter( |
449 url, "dist", ChannelString()); | 449 url, "dist", ChannelString()); |
450 url = chrome_browser_net::AppendQueryParameter( | 450 url = chrome_common_net::AppendQueryParameter( |
451 url, "osname", PlatformString()); | 451 url, "osname", PlatformString()); |
452 url = chrome_browser_net::AppendQueryParameter( | 452 url = chrome_common_net::AppendQueryParameter( |
453 url, "branding", chrome::VersionInfo().Version()); | 453 url, "branding", chrome::VersionInfo().Version()); |
454 DVLOG(1) << "PromoServerURL=" << url.spec(); | 454 DVLOG(1) << "PromoServerURL=" << url.spec(); |
455 // Note that locale param is added by WebResourceService. | 455 // Note that locale param is added by WebResourceService. |
456 return url; | 456 return url; |
457 } | 457 } |
458 | 458 |
459 double NotificationPromo::StartTimeForGroup() const { | 459 double NotificationPromo::StartTimeForGroup() const { |
460 // TODO(achuith): Write unittests for this. | 460 // TODO(achuith): Write unittests for this. |
461 if (group_ < initial_segment_) | 461 if (group_ < initial_segment_) |
462 return start_; | 462 return start_; |
(...skipping 11 matching lines...) Expand all Loading... |
474 | 474 |
475 size_t new_index = question.find(':', *index); | 475 size_t new_index = question.find(':', *index); |
476 // Note that substr correctly handles npos. | 476 // Note that substr correctly handles npos. |
477 std::string fragment(question.substr(*index, new_index - *index)); | 477 std::string fragment(question.substr(*index, new_index - *index)); |
478 *index = new_index + 1; | 478 *index = new_index + 1; |
479 | 479 |
480 int value; | 480 int value; |
481 *err = !base::StringToInt(fragment, &value); | 481 *err = !base::StringToInt(fragment, &value); |
482 return *err ? 0 : value; | 482 return *err ? 0 : value; |
483 } | 483 } |
OLD | NEW |