| OLD | NEW |
| 1 // Copyright (c) 2011 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/ntp/ntp_login_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 if (username.empty()) { | 72 if (username.empty()) { |
| 73 // The user isn't signed in, show the sync promo. | 73 // The user isn't signed in, show the sync promo. |
| 74 if (SyncPromoUI::ShouldShowSyncPromo(profile)) { | 74 if (SyncPromoUI::ShouldShowSyncPromo(profile)) { |
| 75 web_ui_->tab_contents()->OpenURL(GURL(chrome::kChromeUISyncPromoURL), | 75 web_ui_->tab_contents()->OpenURL(GURL(chrome::kChromeUISyncPromoURL), |
| 76 GURL(), CURRENT_TAB, | 76 GURL(), CURRENT_TAB, |
| 77 PageTransition::LINK); | 77 PageTransition::LINK); |
| 78 } | 78 } |
| 79 } else if (args->GetSize() == 4) { | 79 } else if (args->GetSize() == 4) { |
| 80 // The user is signed in, show the profiles menu. | 80 // The user is signed in, show the profiles menu. |
| 81 Browser* browser = GetBrowser(); | 81 Browser* browser = |
| 82 BrowserList::FindBrowserWithTabContents(web_ui_->tab_contents()); |
| 82 if (!browser) | 83 if (!browser) |
| 83 return; | 84 return; |
| 84 double x = 0; | 85 double x = 0; |
| 85 double y = 0; | 86 double y = 0; |
| 86 double width = 0; | 87 double width = 0; |
| 87 double height = 0; | 88 double height = 0; |
| 88 bool success = args->GetDouble(0, &x); | 89 bool success = args->GetDouble(0, &x); |
| 89 DCHECK(success); | 90 DCHECK(success); |
| 90 success = args->GetDouble(1, &y); | 91 success = args->GetDouble(1, &y); |
| 91 DCHECK(success); | 92 DCHECK(success); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 // For now we don't care about showing sync status on Chrome OS. The promo | 129 // For now we don't care about showing sync status on Chrome OS. The promo |
| 129 // UI and the avatar menu don't exist on that platform. | 130 // UI and the avatar menu don't exist on that platform. |
| 130 return false; | 131 return false; |
| 131 #else | 132 #else |
| 132 if (profile->IsOffTheRecord()) | 133 if (profile->IsOffTheRecord()) |
| 133 return false; | 134 return false; |
| 134 | 135 |
| 135 return profile->GetOriginalProfile()->IsSyncAccessible(); | 136 return profile->GetOriginalProfile()->IsSyncAccessible(); |
| 136 #endif | 137 #endif |
| 137 } | 138 } |
| 138 | |
| 139 Browser* NTPLoginHandler::GetBrowser() { | |
| 140 for (TabContentsIterator it; !it.done(); ++it) { | |
| 141 TabContents* tab = it->tab_contents(); | |
| 142 if (tab == web_ui_->tab_contents()) | |
| 143 return it.browser(); | |
| 144 } | |
| 145 return NULL; | |
| 146 } | |
| OLD | NEW |