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

Unified Diff: chrome/browser/ui/webui/sync_promo_handler.cc

Issue 8227038: Sync Promo: Close browser tab when closing promo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix merge issues Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_login_handler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/sync_promo_handler.cc
diff --git a/chrome/browser/ui/webui/sync_promo_handler.cc b/chrome/browser/ui/webui/sync_promo_handler.cc
index 37031e47e031cc0a60bbfaf531d87df7d4e033c2..7ae5fb1157ded1f7cfafd7e2e63a22188a8f97af 100644
--- a/chrome/browser/ui/webui/sync_promo_handler.cc
+++ b/chrome/browser/ui/webui/sync_promo_handler.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/sync/sync_setup_flow.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/webui/sync_promo_ui.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -23,7 +24,8 @@
#include "content/common/notification_service.h"
SyncPromoHandler::SyncPromoHandler(ProfileManager* profile_manager)
- : SyncSetupHandler(profile_manager), window_already_closed_(false) {
+ : SyncSetupHandler(profile_manager),
+ window_already_closed_(false) {
}
SyncPromoHandler::~SyncPromoHandler() {
@@ -123,9 +125,19 @@ void SyncPromoHandler::ShowSetupUI() {
void SyncPromoHandler::HandleCloseSyncPromo(const base::ListValue* args) {
CloseSyncSetup();
- web_ui_->tab_contents()->OpenURL(GURL(chrome::kChromeUINewTabURL),
- GURL(), CURRENT_TAB,
- PageTransition::LINK);
+
+ // If there's no previous page on this tab then it means that the promo was
+ // displayed at startup. In this case we want to close the browser tab that
+ // the promo is in.
+ if (!web_ui_->tab_contents()->controller().CanGoBack()) {
+ Browser* browser =
+ BrowserList::FindBrowserWithTabContents(web_ui_->tab_contents());
+ browser->CloseTabContents(web_ui_->tab_contents());
+ } else {
+ web_ui_->tab_contents()->OpenURL(GURL(chrome::kChromeUINewTabURL),
+ GURL(), CURRENT_TAB,
+ PageTransition::LINK);
+ }
}
void SyncPromoHandler::HandleInitializeSyncPromo(const base::ListValue* args) {
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_login_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698