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

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: fix mac build 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.h ('k') | chrome/test/base/test_browser_window.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c2bacaa13ee5e17a714a06bf9bfa19c9e0b4a45e..f868ce175cf5f399359295328366569d0febee59 100644
--- a/chrome/browser/ui/webui/ntp/ntp_login_handler.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_login_handler.cc
@@ -15,6 +15,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"
@@ -64,6 +68,7 @@ void NTPLoginHandler::HandleShowSyncLoginUI(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(profile)) {
@@ -71,9 +76,25 @@ void NTPLoginHandler::HandleShowSyncLoginUI(const ListValue* args) {
GURL(), CURRENT_TAB,
PageTransition::LINK);
}
- } else {
+ } else if (args->GetSize() == 4) {
// The user is signed in, show the profiles menu.
- // TODO(sail): Need to implement this.
+ Browser* browser = GetBrowser();
+ if (!browser)
+ return;
+ double x = 0;
+ double y = 0;
+ double width = 0;
+ double height = 0;
+ bool success = args->GetDouble(0, &x);
+ DCHECK(success);
+ success = args->GetDouble(1, &y);
+ DCHECK(success);
+ success = args->GetDouble(2, &width);
+ DCHECK(success);
+ success = args->GetDouble(3, &height);
+ DCHECK(success);
+ gfx::Rect rect(x, y, width, height);
+ browser->window()->ShowAvatarBubble(web_ui_->tab_contents(), rect);
}
}
@@ -114,3 +135,12 @@ bool NTPLoginHandler::ShouldShow(Profile* profile) {
return profile->GetOriginalProfile()->IsSyncAccessible();
#endif
}
+
+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;
+}
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_login_handler.h ('k') | chrome/test/base/test_browser_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698