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

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

Issue 9117048: Revert r118627 and r118640 "Update Gaia URL." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 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) 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/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/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/first_run/first_run.h" 10 #include "chrome/browser/first_run/first_run.h"
11 #include "chrome/browser/google/google_util.h" 11 #include "chrome/browser/google/google_util.h"
12 #include "chrome/browser/net/browser_url_util.h"
13 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/sync/profile_sync_service.h" 14 #include "chrome/browser/sync/profile_sync_service.h"
16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 15 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
17 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" 16 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
18 #include "chrome/browser/ui/webui/options/core_options_handler.h" 17 #include "chrome/browser/ui/webui/options/core_options_handler.h"
19 #include "chrome/browser/ui/webui/sync_promo/sync_promo_handler.h" 18 #include "chrome/browser/ui/webui/sync_promo/sync_promo_handler.h"
20 #include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h" 19 #include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h"
21 #include "chrome/browser/ui/webui/theme_source.h" 20 #include "chrome/browser/ui/webui/theme_source.h"
22 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 }; 74 };
76 75
77 SyncPromoUIHTMLSource::SyncPromoUIHTMLSource(content::WebUI* web_ui) 76 SyncPromoUIHTMLSource::SyncPromoUIHTMLSource(content::WebUI* web_ui)
78 : ChromeWebUIDataSource(chrome::kChromeUISyncPromoHost) { 77 : ChromeWebUIDataSource(chrome::kChromeUISyncPromoHost) {
79 DictionaryValue localized_strings; 78 DictionaryValue localized_strings;
80 CoreOptionsHandler::GetStaticLocalizedValues(&localized_strings); 79 CoreOptionsHandler::GetStaticLocalizedValues(&localized_strings);
81 SyncSetupHandler::GetStaticLocalizedValues(&localized_strings, web_ui); 80 SyncSetupHandler::GetStaticLocalizedValues(&localized_strings, web_ui);
82 AddLocalizedStrings(localized_strings); 81 AddLocalizedStrings(localized_strings);
83 } 82 }
84 83
84 // Looks for |search_key| in the query portion of |url|. Returns true if the
85 // key is found and sets |out_value| to the value for the key. Returns false if
86 // the key is not found.
87 bool GetValueForKeyInQuery(const GURL& url, const std::string& search_key,
88 std::string* out_value) {
89 url_parse::Component query = url.parsed_for_possibly_invalid_spec().query;
90 url_parse::Component key, value;
91 while (url_parse::ExtractQueryKeyValue(
92 url.spec().c_str(), &query, &key, &value)) {
93 if (key.is_nonempty()) {
94 std::string key_string = url.spec().substr(key.begin, key.len);
95 if (key_string == search_key) {
96 if (value.is_nonempty())
97 *out_value = url.spec().substr(value.begin, value.len);
98 else
99 *out_value = "";
100 return true;
101 }
102 }
103 }
104 return false;
105 }
106
85 } // namespace 107 } // namespace
86 108
87 SyncPromoUI::SyncPromoUI(content::WebUI* web_ui) : WebUIController(web_ui) { 109 SyncPromoUI::SyncPromoUI(content::WebUI* web_ui) : WebUIController(web_ui) {
88 web_ui->HideURL(); 110 web_ui->HideURL();
89 111
90 SyncPromoHandler* handler = new SyncPromoHandler( 112 SyncPromoHandler* handler = new SyncPromoHandler(
91 g_browser_process->profile_manager()); 113 g_browser_process->profile_manager());
92 web_ui->AddMessageHandler(handler); 114 web_ui->AddMessageHandler(handler);
93 115
94 // Set up the chrome://theme/ source. 116 // Set up the chrome://theme/ source.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } 248 }
227 249
228 return GURL(stream.str()); 250 return GURL(stream.str());
229 } 251 }
230 252
231 // static 253 // static
232 bool SyncPromoUI::GetIsLaunchPageForSyncPromoURL(const GURL& url) { 254 bool SyncPromoUI::GetIsLaunchPageForSyncPromoURL(const GURL& url) {
233 std::string value; 255 std::string value;
234 // Show the title if the promo is currently the Chrome launch page (and not 256 // Show the title if the promo is currently the Chrome launch page (and not
235 // the page accessed through the NTP). 257 // the page accessed through the NTP).
236 if (chrome_browser_net::GetValueForKeyInQuery(url, 258 if (GetValueForKeyInQuery(url, kSyncPromoQueryKeyIsLaunchPage, &value))
237 kSyncPromoQueryKeyIsLaunchPage, &value)) {
238 return value == "true"; 259 return value == "true";
239 }
240 return false; 260 return false;
241 } 261 }
242 262
243 // static 263 // static
244 GURL SyncPromoUI::GetNextPageURLForSyncPromoURL(const GURL& url) { 264 GURL SyncPromoUI::GetNextPageURLForSyncPromoURL(const GURL& url) {
245 std::string value; 265 std::string value;
246 if (chrome_browser_net::GetValueForKeyInQuery(url, 266 if (GetValueForKeyInQuery(url, kSyncPromoQueryKeyNextPage, &value)) {
247 kSyncPromoQueryKeyNextPage, &value)) { 267 url_canon::RawCanonOutputT<char16> output;
248 return GURL(value); 268 url_util::DecodeURLEscapeSequences(value.c_str(), value.length(), &output);
269 std::string url;
270 UTF16ToUTF8(output.data(), output.length(), &url);
271 return GURL(url);
249 } 272 }
250 return GURL(); 273 return GURL();
251 } 274 }
252 275
253 // static 276 // static
254 bool SyncPromoUI::UserHasSeenSyncPromoAtStartup(Profile* profile) { 277 bool SyncPromoUI::UserHasSeenSyncPromoAtStartup(Profile* profile) {
255 return profile->GetPrefs()->GetInteger(prefs::kSyncPromoStartupCount) > 0; 278 return profile->GetPrefs()->GetInteger(prefs::kSyncPromoStartupCount) > 0;
256 } 279 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/sync_test.cc ('k') | chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698