Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/extensions/echo_private_api.h" | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "base/logging.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/values.h" | |
| 13 #include "chrome/browser/chromeos/system/statistics_provider.h" | |
| 14 #include "chrome/browser/extensions/extension_host.h" | |
| 15 #include "chrome/browser/extensions/extension_process_manager.h" | |
| 16 #include "chrome/browser/extensions/extension_tab_util.h" | |
| 17 #include "chrome/browser/extensions/extension_window_controller.h" | |
| 18 #include "chrome/browser/infobars/infobar_tab_helper.h" | |
| 19 #include "chrome/browser/profiles/profile.h" | |
| 20 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | |
| 21 #include "chrome/browser/ui/browser.h" | |
| 22 #include "chrome/browser/ui/browser_list.h" | |
| 23 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | |
| 24 #include "chrome/common/chrome_notification_types.h" | |
| 25 #include "chrome/common/extensions/extension.h" | |
| 26 #include "content/public/browser/notification_details.h" | |
|
tbarzic
2012/04/17 18:23:04
includes could use some cleanup :)
gauravsh
2012/04/17 19:05:52
Done.
| |
| 27 #include "content/public/browser/notification_observer.h" | |
| 28 #include "content/public/browser/notification_registrar.h" | |
| 29 #include "content/public/browser/notification_source.h" | |
| 30 #include "content/public/browser/web_contents.h" | |
| 31 #include "grit/generated_resources.h" | |
| 32 #include "ui/base/l10n/l10n_util.h" | |
| 33 | |
| 34 namespace { | |
| 35 | |
| 36 // For a given registration code type, returns the code value from the | |
| 37 // underlying system. | |
| 38 std::string GetValueForRegistrationCodeType(std::string& type) { | |
| 39 // Possible ECHO code type and corresponding key name in StatisticsProvider. | |
| 40 const std::string kCouponType = "COUPON_CODE"; | |
| 41 const std::string kCouponCodeKey = "ubind_attribute"; | |
| 42 const std::string kGroupType = "GROUP_CODE"; | |
| 43 const std::string kGroupCodeKey = "gbind_attribute"; | |
| 44 | |
| 45 chromeos::system::StatisticsProvider* provider = | |
| 46 chromeos::system::StatisticsProvider::GetInstance(); | |
| 47 std::string result; | |
| 48 if (type == kCouponType) | |
| 49 provider->GetMachineStatistic(kCouponCodeKey, &result); | |
| 50 else if (type == kGroupType) | |
| 51 provider->GetMachineStatistic(kGroupCodeKey, &result); | |
| 52 return result; | |
| 53 } | |
| 54 | |
| 55 } // namespace | |
| 56 | |
| 57 | |
| 58 GetRegistrationCodeFunction::GetRegistrationCodeFunction() { | |
| 59 } | |
| 60 | |
| 61 GetRegistrationCodeFunction::~GetRegistrationCodeFunction() { | |
| 62 } | |
| 63 | |
| 64 bool GetRegistrationCodeFunction::RunImpl() { | |
| 65 std::string type; | |
| 66 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &type)); | |
| 67 result_.reset(Value::CreateStringValue( | |
| 68 GetValueForRegistrationCodeType(type))); | |
|
tbarzic
2012/04/17 18:23:04
This would probably look nicer if GetValueForRegis
gauravsh
2012/04/17 19:05:52
Done.
| |
| 69 return true; | |
| 70 } | |
| OLD | NEW |