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

Side by Side Diff: chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc

Issue 12069004: google_apis: Move AppendQueryParameter() etc. from common/net/url_util.h to net/base/url_util.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
OLDNEW
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/ui/webui/sync_promo/sync_promo_ui.h" 5 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/first_run/first_run.h" 13 #include "chrome/browser/first_run/first_run.h"
14 #include "chrome/browser/google/google_util.h" 14 #include "chrome/browser/google/google_util.h"
15 #include "chrome/browser/prefs/pref_service.h" 15 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/profiles/profile_info_cache.h" 17 #include "chrome/browser/profiles/profile_info_cache.h"
18 #include "chrome/browser/profiles/profile_manager.h" 18 #include "chrome/browser/profiles/profile_manager.h"
19 #include "chrome/browser/sync/profile_sync_service.h" 19 #include "chrome/browser/sync/profile_sync_service.h"
20 #include "chrome/browser/sync/profile_sync_service_factory.h" 20 #include "chrome/browser/sync/profile_sync_service_factory.h"
21 #include "chrome/browser/ui/webui/options/core_options_handler.h" 21 #include "chrome/browser/ui/webui/options/core_options_handler.h"
22 #include "chrome/browser/ui/webui/sync_promo/sync_promo_handler.h" 22 #include "chrome/browser/ui/webui/sync_promo/sync_promo_handler.h"
23 #include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h" 23 #include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h"
24 #include "chrome/browser/ui/webui/theme_source.h" 24 #include "chrome/browser/ui/webui/theme_source.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
28 #include "chrome/common/net/url_util.h"
29 #include "content/public/browser/url_data_source.h" 28 #include "content/public/browser/url_data_source.h"
30 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
31 #include "content/public/browser/web_ui.h" 30 #include "content/public/browser/web_ui.h"
32 #include "content/public/browser/web_ui_data_source.h" 31 #include "content/public/browser/web_ui_data_source.h"
33 #include "google_apis/gaia/gaia_urls.h" 32 #include "google_apis/gaia/gaia_urls.h"
34 #include "grit/browser_resources.h" 33 #include "grit/browser_resources.h"
35 #include "grit/generated_resources.h" 34 #include "grit/generated_resources.h"
36 #include "grit/theme_resources.h" 35 #include "grit/theme_resources.h"
37 #include "net/base/escape.h" 36 #include "net/base/escape.h"
38 #include "net/base/network_change_notifier.h" 37 #include "net/base/network_change_notifier.h"
38 #include "net/base/url_util.h"
39 #include "ui/base/l10n/l10n_util.h" 39 #include "ui/base/l10n/l10n_util.h"
40 40
41 using content::WebContents; 41 using content::WebContents;
42 42
43 namespace { 43 namespace {
44 44
45 const char kStringsJsFile[] = "strings.js"; 45 const char kStringsJsFile[] = "strings.js";
46 const char kSyncPromoJsFile[] = "sync_promo.js"; 46 const char kSyncPromoJsFile[] = "sync_promo.js";
47 47
48 const char kSyncPromoQueryKeyAutoClose[] = "auto_close"; 48 const char kSyncPromoQueryKeyAutoClose[] = "auto_close";
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 260 }
261 261
262 return GURL(url_string); 262 return GURL(url_string);
263 } 263 }
264 264
265 // static 265 // static
266 GURL SyncPromoUI::GetNextPageURLForSyncPromoURL(const GURL& url) { 266 GURL SyncPromoUI::GetNextPageURLForSyncPromoURL(const GURL& url) {
267 const char* key_name = UseWebBasedSigninFlow() ? kSyncPromoQueryKeyContinue : 267 const char* key_name = UseWebBasedSigninFlow() ? kSyncPromoQueryKeyContinue :
268 kSyncPromoQueryKeyNextPage; 268 kSyncPromoQueryKeyNextPage;
269 std::string value; 269 std::string value;
270 if (chrome_common_net::GetValueForKeyInQuery(url, key_name, &value)) { 270 if (net::GetValueForKeyInQuery(url, key_name, &value)) {
271 return GURL(value); 271 return GURL(value);
272 } 272 }
273 return GURL(); 273 return GURL();
274 } 274 }
275 275
276 // static 276 // static
277 SyncPromoUI::Source SyncPromoUI::GetSourceForSyncPromoURL(const GURL& url) { 277 SyncPromoUI::Source SyncPromoUI::GetSourceForSyncPromoURL(const GURL& url) {
278 std::string value; 278 std::string value;
279 if (chrome_common_net::GetValueForKeyInQuery( 279 if (net::GetValueForKeyInQuery(url, kSyncPromoQueryKeySource, &value)) {
280 url, kSyncPromoQueryKeySource, &value)) {
281 int source = 0; 280 int source = 0;
282 if (base::StringToInt(value, &source) && source >= SOURCE_START_PAGE && 281 if (base::StringToInt(value, &source) && source >= SOURCE_START_PAGE &&
283 source < SOURCE_UNKNOWN) { 282 source < SOURCE_UNKNOWN) {
284 return static_cast<Source>(source); 283 return static_cast<Source>(source);
285 } 284 }
286 } 285 }
287 return SOURCE_UNKNOWN; 286 return SOURCE_UNKNOWN;
288 } 287 }
289 288
290 // static 289 // static
291 bool SyncPromoUI::GetAutoCloseForSyncPromoURL(const GURL& url) { 290 bool SyncPromoUI::GetAutoCloseForSyncPromoURL(const GURL& url) {
292 std::string value; 291 std::string value;
293 if (chrome_common_net::GetValueForKeyInQuery( 292 if (net::GetValueForKeyInQuery(url, kSyncPromoQueryKeyAutoClose, &value)) {
294 url, kSyncPromoQueryKeyAutoClose, &value)) {
295 int source = 0; 293 int source = 0;
296 base::StringToInt(value, &source); 294 base::StringToInt(value, &source);
297 return (source == 1); 295 return (source == 1);
298 } 296 }
299 return false; 297 return false;
300 } 298 }
301 299
302 // static 300 // static
303 bool SyncPromoUI::UseWebBasedSigninFlow() { 301 bool SyncPromoUI::UseWebBasedSigninFlow() {
304 #if defined(ENABLE_ONE_CLICK_SIGNIN) 302 #if defined(ENABLE_ONE_CLICK_SIGNIN)
305 return !CommandLine::ForCurrentProcess()->HasSwitch( 303 return !CommandLine::ForCurrentProcess()->HasSwitch(
306 switches::kUseClientLoginSigninFlow) || 304 switches::kUseClientLoginSigninFlow) ||
307 g_force_web_based_signin_flow; 305 g_force_web_based_signin_flow;
308 #else 306 #else
309 return false; 307 return false;
310 #endif 308 #endif
311 } 309 }
312 310
313 // static 311 // static
314 void SyncPromoUI::ForceWebBasedSigninFlowForTesting(bool force) { 312 void SyncPromoUI::ForceWebBasedSigninFlowForTesting(bool force) {
315 g_force_web_based_signin_flow = force; 313 g_force_web_based_signin_flow = force;
316 } 314 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.cc ('k') | chrome/browser/web_resource/notification_promo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698