summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/sync
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-30 01:02:53 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-30 01:02:53 +0000
commitda0ade73522ccbb0284cedf2764a68465f691dc5 (patch)
tree2b5cdcc427c0dfd014fc87612e8ab4f40ea2736a /chrome/browser/ui/sync
parent6ed2de0c2b29723bec008ee1c20ee88a492154f2 (diff)
downloadchromium_src-da0ade73522ccbb0284cedf2764a68465f691dc5.zip
chromium_src-da0ade73522ccbb0284cedf2764a68465f691dc5.tar.gz
chromium_src-da0ade73522ccbb0284cedf2764a68465f691dc5.tar.bz2
Reorder pieces of code. No other changes.
* Make overriding functions as private as possible * Make declaration order match definition order * Fix a few other problems with section order not following the style guide * For consistency, list functions in order: virtuals, non-virtuals, macro-based declarations * In a few .cc files, try to keep class declarations and definitions together * In a few .cc files, move enums into the classes the use them BUG=none TEST=none R=sky@chromium.org Review URL: https://codereview.chromium.org/14383022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197198 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/sync')
-rw-r--r--chrome/browser/ui/sync/one_click_signin_helper.cc103
-rw-r--r--chrome/browser/ui/sync/one_click_signin_helper.h3
2 files changed, 54 insertions, 52 deletions
diff --git a/chrome/browser/ui/sync/one_click_signin_helper.cc b/chrome/browser/ui/sync/one_click_signin_helper.cc
index be275a4..ed2c521 100644
--- a/chrome/browser/ui/sync/one_click_signin_helper.cc
+++ b/chrome/browser/ui/sync/one_click_signin_helper.cc
@@ -74,7 +74,6 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
-DEFINE_WEB_CONTENTS_USER_DATA_KEY(OneClickSigninHelper);
namespace {
@@ -83,6 +82,34 @@ namespace {
// SAML-based accounts, but causes bug crbug.com/181163.
const int kMaxNavigationsSince = 10;
+// Arguments used with StartSync function. base::Bind() cannot support too
+// many args for performance reasons, so they are packaged up into a struct.
+struct StartSyncArgs {
+ StartSyncArgs(Profile* profile,
+ Browser* browser,
+ OneClickSigninHelper::AutoAccept auto_accept,
+ const std::string& session_index,
+ const std::string& email,
+ const std::string& password,
+ bool force_same_tab_navigation)
+ : profile(profile),
+ browser(browser),
+ auto_accept(auto_accept),
+ session_index(session_index),
+ email(email),
+ password(password),
+ force_same_tab_navigation(force_same_tab_navigation) {
+ }
+
+ Profile* profile;
+ Browser* browser;
+ OneClickSigninHelper::AutoAccept auto_accept;
+ std::string session_index;
+ std::string email;
+ std::string password;
+ bool force_same_tab_navigation;
+};
+
// Add a specific email to the list of emails rejected for one-click
// sign-in, for this profile.
void AddEmailToOneClickRejectedList(Profile* profile,
@@ -138,34 +165,6 @@ void LogOneClickHistogramValue(int action) {
one_click_signin::HISTOGRAM_MAX);
}
-// Arguments used with StartSync function. base::Bind() cannot support too
-// many args for performance reasons, so they are packaged up into a struct.
-struct StartSyncArgs {
- StartSyncArgs(Profile* profile,
- Browser* browser,
- OneClickSigninHelper::AutoAccept auto_accept,
- const std::string& session_index,
- const std::string& email,
- const std::string& password,
- bool force_same_tab_navigation)
- : profile(profile),
- browser(browser),
- auto_accept(auto_accept),
- session_index(session_index),
- email(email),
- password(password),
- force_same_tab_navigation(force_same_tab_navigation) {
- }
-
- Profile* profile;
- Browser* browser;
- OneClickSigninHelper::AutoAccept auto_accept;
- std::string session_index;
- std::string email;
- std::string password;
- bool force_same_tab_navigation;
-};
-
// Start syncing with the given user information.
void StartSync(const StartSyncArgs& args,
OneClickSigninSyncStarter::StartSyncMode start_mode) {
@@ -286,6 +285,28 @@ bool IsValidGaiaSigninRedirectOrResponseURL(const GURL& url) {
return false;
}
+// Tells when we are in the process of showing either the signin to chrome page
+// or the one click sign in to chrome page.
+// NOTE: This should only be used for logging purposes since it relies on hard
+// coded URLs that could change.
+bool AreWeShowingSignin(GURL url, SyncPromoUI::Source source,
+ std::string email) {
+ GURL::Replacements replacements;
+ replacements.ClearQuery();
+ GURL clean_login_url =
+ GURL(GaiaUrls::GetInstance()->service_login_url()).ReplaceComponents(
+ replacements);
+
+ GURL clean_one_click_url =
+ GURL(GaiaUrls::GetInstance()->gaia_login_form_realm() +
+ "ChromeLoginPrompt").ReplaceComponents(replacements);
+
+ return (url.ReplaceComponents(replacements) == clean_login_url &&
+ source != SyncPromoUI::SOURCE_UNKNOWN) ||
+ (url.ReplaceComponents(replacements) == clean_one_click_url &&
+ !email.empty());
+}
+
// Constants for the modal dialog / bubble sign in to chrome confirmation
// experiment
const char kSignInToChromeDialogFieldTrialName[] = "SignInToChromeConfirmation";
@@ -371,28 +392,6 @@ ConfirmEmailDialogDelegate::ConfirmEmailDialogDelegate(
callback_(callback) {
}
-// Tells when we are in the process of showing either the signin to chrome page
-// or the one click sign in to chrome page.
-// NOTE: This should only be used for logging purposes since it relies on hard
-// coded URLs that could change.
-bool AreWeShowingSignin(GURL url, SyncPromoUI::Source source,
- std::string email) {
- GURL::Replacements replacements;
- replacements.ClearQuery();
- GURL clean_login_url =
- GURL(GaiaUrls::GetInstance()->service_login_url()).ReplaceComponents(
- replacements);
-
- GURL clean_one_click_url =
- GURL(GaiaUrls::GetInstance()->gaia_login_form_realm() +
- "ChromeLoginPrompt").ReplaceComponents(replacements);
-
- return (url.ReplaceComponents(replacements) == clean_login_url &&
- source != SyncPromoUI::SOURCE_UNKNOWN) ||
- (url.ReplaceComponents(replacements) == clean_one_click_url &&
- !email.empty());
-}
-
// Watch a webcontents and remove URL from the history once loading is complete.
// We have to delay the cleaning until the new URL has finished loading because
@@ -437,6 +436,8 @@ void CurrentHistoryCleaner::WebContentsDestroyed(
} // namespace
+DEFINE_WEB_CONTENTS_USER_DATA_KEY(OneClickSigninHelper);
+
OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents)
: content::WebContentsObserver(web_contents),
showing_signin_(false),
diff --git a/chrome/browser/ui/sync/one_click_signin_helper.h b/chrome/browser/ui/sync/one_click_signin_helper.h
index a5219ed..e13272a 100644
--- a/chrome/browser/ui/sync/one_click_signin_helper.h
+++ b/chrome/browser/ui/sync/one_click_signin_helper.h
@@ -118,7 +118,6 @@ class OneClickSigninHelper
static void LogConfirmHistogramValue(int action);
private:
- explicit OneClickSigninHelper(content::WebContents* web_contents);
friend class content::WebContentsUserData<OneClickSigninHelper>;
friend class OneClickSigninHelperTest;
FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperTest,
@@ -155,6 +154,8 @@ class OneClickSigninHelper
FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest,
CanOfferOnIOThreadDisabledByPolicy);
+ explicit OneClickSigninHelper(content::WebContents* web_contents);
+
// Returns true if the one-click signin feature can be offered at this time.
// It can be offered if the io_data is not in an incognito window and if the
// origin of |url| is a valid Gaia sign in origin. This function is meant