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

Unified Diff: chrome/browser/ui/webui/ntp/ntp_login_handler.cc

Issue 8110003: Show avatar menu from NTP4 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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
Index: chrome/browser/ui/webui/ntp/ntp_login_handler.cc
diff --git a/chrome/browser/ui/webui/ntp/ntp_login_handler.cc b/chrome/browser/ui/webui/ntp/ntp_login_handler.cc
index 144c75e19d831574775b37690dba5d58ac3c971f..ea4ba5038b396e9037eb8064ebc579e6d4b836d0 100644
--- a/chrome/browser/ui/webui/ntp/ntp_login_handler.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_login_handler.cc
@@ -13,6 +13,10 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/sync_setup_flow.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/webui/sync_promo_ui.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
@@ -60,16 +64,24 @@ void NTPLoginHandler::HandleLoginContainerClicked(const ListValue* args) {
Profile* profile = Profile::FromWebUI(web_ui_);
std::string username = profile->GetPrefs()->GetString(
prefs::kGoogleServicesUsername);
+
if (username.empty()) {
// The user isn't signed in, show the sync promo.
if (SyncPromoUI::ShouldShowSyncPromo()) {
- web_ui_->tab_contents()->OpenURL(GURL(chrome::kChromeUISyncPromoURL),
- GURL(), CURRENT_TAB,
- PageTransition::LINK);
+ web_ui_->tab_contents()->OpenURL(GURL(chrome::kChromeUISyncPromoURL),
+ GURL(), CURRENT_TAB,
+ PageTransition::LINK);
}
- } else {
+ } else if (args->GetSize() == 2) {
// The user is signed in, show the profiles menu.
- // TODO(sail): Need to implement this.
+ double x = 0;
+ double y = 0;
+ CHECK(args->GetDouble(0, &x));
+ CHECK(args->GetDouble(1, &y));
+ Browser* browser = GetBrowser();
+ if (!browser)
+ return;
+ browser->window()->ShowAvatarBubble(web_ui_->tab_contents(), x, y);
}
}
@@ -100,3 +112,12 @@ bool NTPLoginHandler::ShouldShow(Profile* profile) {
return profile->GetOriginalProfile()->IsSyncAccessible();
}
+
+Browser* NTPLoginHandler::GetBrowser() {
+ for (TabContentsIterator it; !it.done(); ++it) {
+ TabContents* tab = it->tab_contents();
+ if (tab == web_ui_->tab_contents())
+ return it.browser();
+ }
+ return NULL;
+}
« chrome/browser/ui/panels/panel.cc ('K') | « chrome/browser/ui/webui/ntp/ntp_login_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698