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

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: Address review comments 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') | no next file » | 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 144c75e19d831574775b37690dba5d58ac3c971f..7bdc5a3ca23456382471fd36e4d8bedbf79fdd37 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,29 @@ 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() == 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;
+ CHECK(args->GetDouble(0, &x));
James Hawkins 2011/10/05 16:37:32 Why are these CHECKs?
sail 2011/10/05 16:40:54 I just copy pasted these from else where. Should I
James Hawkins 2011/10/05 16:43:53 Yes. CHECK should only be used to debug problems i
sail 2011/10/05 16:58:31 Fixed by using DCHECK(success) instead.
+ CHECK(args->GetDouble(1, &y));
+ CHECK(args->GetDouble(2, &width));
+ CHECK(args->GetDouble(3, &height));
+ gfx::Rect rect(x, y, width, height);
+ browser->window()->ShowAvatarBubble(web_ui_->tab_contents(), rect);
}
}
@@ -100,3 +117,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;
+}
« no previous file with comments | « 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