Sync Promo: Add "Setup Chrome Sync" menu item to the wrench menu

To better promote Sync we want to add a new "Setup Chrome Sync" menu item to the wrench menu. Clicking on the menu item shows the "sync sign in" dialog.

If the user is already signed into sync then clicking on the menu item shows the "configure sync" dialog.

BUG=None
TEST=Ran and verified that the menu item works.


Review URL: http://codereview.chromium.org/7324038

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92245 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/app/chrome_command_ids.h b/chrome/app/chrome_command_ids.h
index 7dd424b..e85d964 100644
--- a/chrome/app/chrome_command_ids.h
+++ b/chrome/app/chrome_command_ids.h
@@ -170,6 +170,7 @@
 #define IDC_PROFILING_ENABLED           40030
 #define IDC_FILE_MANAGER                40031
 #define IDC_BOOKMARKS_MENU              40032
+#define IDC_SHOW_SYNC_SETUP             40033
 
 // Spell-check
 // Insert any additional suggestions before _LAST; these have to be consecutive.
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index aa49484..63115efc0 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -8372,7 +8372,16 @@
       <message name="IDS_SYNC_USE_DEFAULT_SETTINGS" desc="The text to display on the link to go back to the default sync preferences.">
         Use default settings
       </message>
-
+      <if expr="pp_ifdef('use_titlecase')">
+        <message name="IDS_SHOW_SYNC_SETUP" desc="In title case. The title of the menu item to open the sync setup page. Shown in the Wrench menu.">
+          Set Up <ph name="SHORT_PRODUCT_NAME">$1<ex>Chrome</ex></ph> Sync
+        </message>
+      </if>
+      <if expr="not pp_ifdef('use_titlecase')">
+        <message name="IDS_SHOW_SYNC_SETUP" desc="The title of the menu item to open the sync setup page. Shown in the Wrench menu.">
+          Set up <ph name="SHORT_PRODUCT_NAME">$1<ex>Chrome</ex></ph> sync
+        </message>
+      </if>
       <!-- SafeBrowsing -->
       <message name="IDS_SAFE_BROWSING_MALWARE_TITLE" desc="SafeBrowsing Malware HTML title">
         Malware Detected!
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index ecc9e9ba..cbf6b6a2 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -2463,6 +2463,7 @@
     case IDC_INTERNET_OPTIONS:      OpenInternetOptionsDialog();      break;
     case IDC_LANGUAGE_OPTIONS:      OpenLanguageOptionsDialog();      break;
 #endif
+    case IDC_SHOW_SYNC_SETUP:       ShowSyncSetup();                  break;
 
     default:
       LOG(WARNING) << "Received Unimplemented Command: " << id;
@@ -3862,6 +3863,7 @@
   command_updater_.UpdateCommandEnabled(IDC_SYSTEM_OPTIONS, true);
   command_updater_.UpdateCommandEnabled(IDC_INTERNET_OPTIONS, true);
 #endif
+  command_updater_.UpdateCommandEnabled(IDC_SHOW_SYNC_SETUP, true);
 
   ExtensionService* extension_service = profile()->GetExtensionService();
   bool enable_extensions =
@@ -4754,3 +4756,11 @@
       BookmarkBar::DONT_ANIMATE_STATE_CHANGE;
   window_->BookmarkBarStateChanged(animate_type);
 }
+
+void Browser::ShowSyncSetup() {
+  ProfileSyncService* service = profile()->GetProfileSyncService();
+  if (service->HasSyncSetupCompleted())
+    ShowOptionsTab(chrome::kSyncSetupSubPage);
+  else
+    profile()->GetProfileSyncService()->ShowLoginDialog();
+}
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index 5f3cc81c..4d07864 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -592,6 +592,7 @@
   void OpenMobilePlanTabAndActivate();
 #endif
   void OpenPluginsTabAndActivate();
+  void ShowSyncSetup();
 
   virtual void UpdateDownloadShelfVisibility(bool visible);
 
diff --git a/chrome/browser/ui/toolbar/wrench_menu_model.cc b/chrome/browser/ui/toolbar/wrench_menu_model.cc
index 270e1c4..ba9290b 100644
--- a/chrome/browser/ui/toolbar/wrench_menu_model.cc
+++ b/chrome/browser/ui/toolbar/wrench_menu_model.cc
@@ -459,6 +459,14 @@
   AddItemWithStringId(IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS);
   AddSeparator();
 
+#if !defined(OS_CHROMEOS)
+  const string16 short_product_name =
+        l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME);
+  AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16(
+      IDS_SHOW_SYNC_SETUP, short_product_name));
+  AddSeparator();
+#endif
+
 #if defined(OS_CHROMEOS)
   AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS);
 #elif defined(OS_MACOSX)