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/chromeos/extensions/echo_private_api.h" | 5 #include "chrome/browser/chromeos/extensions/echo_private_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/prefs/pref_registry_simple.h" | 12 #include "base/prefs/pref_registry_simple.h" |
13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
14 #include "base/prefs/scoped_user_pref_update.h" | 14 #include "base/prefs/scoped_user_pref_update.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/chromeos/settings/cros_settings.h" | 20 #include "chrome/browser/chromeos/settings/cros_settings.h" |
21 #include "chrome/browser/chromeos/ui/echo_dialog_view.h" | 21 #include "chrome/browser/chromeos/ui/echo_dialog_view.h" |
22 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/browser/ui/browser_navigator_params.h" |
23 #include "chrome/common/extensions/api/echo_private.h" | 24 #include "chrome/common/extensions/api/echo_private.h" |
24 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
25 #include "chromeos/system/statistics_provider.h" | 26 #include "chromeos/system/statistics_provider.h" |
26 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
27 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
28 #include "extensions/common/extension.h" | 29 #include "extensions/common/extension.h" |
29 | 30 |
30 namespace echo_api = extensions::api::echo_private; | 31 namespace echo_api = extensions::api::echo_private; |
31 | 32 |
32 using content::BrowserThread; | 33 using content::BrowserThread; |
33 | 34 |
34 namespace { | 35 namespace { |
35 | 36 |
36 // URL of "More info" link shown in echo dialog in GetUserConsent function. | 37 // URL of "More info" link shown in echo dialog in GetUserConsent function. |
37 const char kMoreInfoLink[] = | 38 const char kMoreInfoLink[] = |
38 "chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html?" | 39 "chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html?" |
39 "answer=2677280"; | 40 "answer=2677280"; |
40 | 41 |
41 } // namespace | 42 } // namespace |
42 | 43 |
43 namespace chromeos { | 44 namespace chromeos { |
44 | 45 |
45 namespace echo_offer { | 46 namespace echo_offer { |
46 | 47 |
47 void RegisterPrefs(PrefRegistrySimple* registry) { | 48 void RegisterPrefs(PrefRegistrySimple* registry) { |
48 registry->RegisterDictionaryPref(prefs::kEchoCheckedOffers); | 49 registry->RegisterDictionaryPref(prefs::kEchoCheckedOffers); |
49 } | 50 } |
50 | 51 |
51 } // namespace echo_offer | 52 } // namespace echo_offer |
52 | 53 |
53 } // namespace chromeos | 54 } // namespace chromeos |
54 | 55 |
55 EchoPrivateGetRegistrationCodeFunction:: | 56 EchoPrivateGetRegistrationCodeFunction:: |
56 EchoPrivateGetRegistrationCodeFunction() {} | 57 EchoPrivateGetRegistrationCodeFunction() {} |
57 | 58 |
58 EchoPrivateGetRegistrationCodeFunction:: | 59 EchoPrivateGetRegistrationCodeFunction:: |
59 ~EchoPrivateGetRegistrationCodeFunction() {} | 60 ~EchoPrivateGetRegistrationCodeFunction() {} |
60 | 61 |
61 void EchoPrivateGetRegistrationCodeFunction::GetRegistrationCode( | 62 void EchoPrivateGetRegistrationCodeFunction::GetRegistrationCode( |
62 const std::string& type) { | 63 const std::string& type) { |
63 // Possible ECHO code type and corresponding key name in StatisticsProvider. | 64 // Possible ECHO code type and corresponding key name in StatisticsProvider. |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 const DialogShownTestCallback& dialog_shown_callback) { | 183 const DialogShownTestCallback& dialog_shown_callback) { |
183 scoped_refptr<EchoPrivateGetUserConsentFunction> function( | 184 scoped_refptr<EchoPrivateGetUserConsentFunction> function( |
184 new EchoPrivateGetUserConsentFunction()); | 185 new EchoPrivateGetUserConsentFunction()); |
185 function->dialog_shown_callback_ = dialog_shown_callback; | 186 function->dialog_shown_callback_ = dialog_shown_callback; |
186 return function; | 187 return function; |
187 } | 188 } |
188 | 189 |
189 EchoPrivateGetUserConsentFunction::~EchoPrivateGetUserConsentFunction() {} | 190 EchoPrivateGetUserConsentFunction::~EchoPrivateGetUserConsentFunction() {} |
190 | 191 |
191 bool EchoPrivateGetUserConsentFunction::RunAsync() { | 192 bool EchoPrivateGetUserConsentFunction::RunAsync() { |
192 CheckRedeemOffersAllowed(); | 193 CheckRedeemOffersAllowed(); |
193 return true; | 194 return true; |
194 } | 195 } |
195 | 196 |
196 void EchoPrivateGetUserConsentFunction::OnAccept() { | 197 void EchoPrivateGetUserConsentFunction::OnAccept() { |
197 Finalize(true); | 198 Finalize(true); |
198 } | 199 } |
199 | 200 |
200 void EchoPrivateGetUserConsentFunction::OnCancel() { | 201 void EchoPrivateGetUserConsentFunction::OnCancel() { |
201 Finalize(false); | 202 Finalize(false); |
202 } | 203 } |
203 | 204 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 void EchoPrivateGetUserConsentFunction::Finalize(bool consent) { | 271 void EchoPrivateGetUserConsentFunction::Finalize(bool consent) { |
271 // Consent should not be true if offers redeeming is disabled. | 272 // Consent should not be true if offers redeeming is disabled. |
272 CHECK(redeem_offers_allowed_ || !consent); | 273 CHECK(redeem_offers_allowed_ || !consent); |
273 results_ = echo_api::GetUserConsent::Results::Create(consent); | 274 results_ = echo_api::GetUserConsent::Results::Create(consent); |
274 SendResponse(true); | 275 SendResponse(true); |
275 | 276 |
276 // Release the reference added in |OnRedeemOffersAllowedChecked|, before | 277 // Release the reference added in |OnRedeemOffersAllowedChecked|, before |
277 // showing the dialog. | 278 // showing the dialog. |
278 Release(); | 279 Release(); |
279 } | 280 } |
OLD | NEW |