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

Side by Side Diff: chrome/browser/ui/webui/ntp/ntp_login_handler.cc

Issue 9003014: Replace WebUI::tab_contents() with web_contents() and switch all users to use web_contents.h inst... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 13 matching lines...) Expand all
24 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_list.h" 25 #include "chrome/browser/ui/browser_list.h"
26 #include "chrome/browser/ui/browser_window.h" 26 #include "chrome/browser/ui/browser_window.h"
27 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 27 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
28 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" 28 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
29 #include "chrome/browser/ui/webui/web_ui_util.h" 29 #include "chrome/browser/ui/webui/web_ui_util.h"
30 #include "chrome/browser/web_resource/promo_resource_service.h" 30 #include "chrome/browser/web_resource/promo_resource_service.h"
31 #include "chrome/common/chrome_notification_types.h" 31 #include "chrome/common/chrome_notification_types.h"
32 #include "chrome/common/pref_names.h" 32 #include "chrome/common/pref_names.h"
33 #include "chrome/common/url_constants.h" 33 #include "chrome/common/url_constants.h"
34 #include "content/browser/tab_contents/tab_contents.h"
35 #include "content/public/browser/notification_details.h" 34 #include "content/public/browser/notification_details.h"
36 #include "content/public/browser/notification_service.h" 35 #include "content/public/browser/notification_service.h"
36 #include "content/public/browser/web_contents.h"
37 #include "grit/chromium_strings.h" 37 #include "grit/chromium_strings.h"
38 #include "grit/generated_resources.h" 38 #include "grit/generated_resources.h"
39 #include "net/base/escape.h" 39 #include "net/base/escape.h"
40 #include "skia/ext/image_operations.h" 40 #include "skia/ext/image_operations.h"
41 #include "ui/base/l10n/l10n_util.h" 41 #include "ui/base/l10n/l10n_util.h"
42 #include "ui/gfx/canvas_skia.h" 42 #include "ui/gfx/canvas_skia.h"
43 #include "ui/gfx/image/image.h" 43 #include "ui/gfx/image/image.h"
44 44
45 using content::OpenURLParams; 45 using content::OpenURLParams;
46 using content::Referrer; 46 using content::Referrer;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 Profile* profile = Profile::FromWebUI(web_ui()); 122 Profile* profile = Profile::FromWebUI(web_ui());
123 std::string username = profile->GetPrefs()->GetString( 123 std::string username = profile->GetPrefs()->GetString(
124 prefs::kGoogleServicesUsername); 124 prefs::kGoogleServicesUsername);
125 125
126 if (username.empty()) { 126 if (username.empty()) {
127 // The user isn't signed in, show the sync promo. 127 // The user isn't signed in, show the sync promo.
128 if (SyncPromoUI::ShouldShowSyncPromo(profile)) { 128 if (SyncPromoUI::ShouldShowSyncPromo(profile)) {
129 OpenURLParams params( 129 OpenURLParams params(
130 GURL(chrome::kChromeUISyncPromoURL), Referrer(), CURRENT_TAB, 130 GURL(chrome::kChromeUISyncPromoURL), Referrer(), CURRENT_TAB,
131 content::PAGE_TRANSITION_LINK, false); 131 content::PAGE_TRANSITION_LINK, false);
132 web_ui()->tab_contents()->OpenURL(params); 132 web_ui()->web_contents()->OpenURL(params);
133 RecordInHistogram(NTP_SIGN_IN_PROMO_CLICKED); 133 RecordInHistogram(NTP_SIGN_IN_PROMO_CLICKED);
134 } 134 }
135 } else if (args->GetSize() == 4) { 135 } else if (args->GetSize() == 4) {
136 // The user is signed in, show the profiles menu. 136 // The user is signed in, show the profiles menu.
137 Browser* browser = 137 Browser* browser =
138 BrowserList::FindBrowserWithTabContents(web_ui()->tab_contents()); 138 BrowserList::FindBrowserWithWebContents(web_ui()->web_contents());
139 if (!browser) 139 if (!browser)
140 return; 140 return;
141 double x = 0; 141 double x = 0;
142 double y = 0; 142 double y = 0;
143 double width = 0; 143 double width = 0;
144 double height = 0; 144 double height = 0;
145 bool success = args->GetDouble(0, &x); 145 bool success = args->GetDouble(0, &x);
146 DCHECK(success); 146 DCHECK(success);
147 success = args->GetDouble(1, &y); 147 success = args->GetDouble(1, &y);
148 DCHECK(success); 148 DCHECK(success);
149 success = args->GetDouble(2, &width); 149 success = args->GetDouble(2, &width);
150 DCHECK(success); 150 DCHECK(success);
151 success = args->GetDouble(3, &height); 151 success = args->GetDouble(3, &height);
152 DCHECK(success); 152 DCHECK(success);
153 gfx::Rect rect(x, y, width, height); 153 gfx::Rect rect(x, y, width, height);
154 browser->window()->ShowAvatarBubble(web_ui()->tab_contents(), rect); 154 browser->window()->ShowAvatarBubble(web_ui()->web_contents(), rect);
155 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::NTP_AVATAR_BUBBLE); 155 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::NTP_AVATAR_BUBBLE);
156 } 156 }
157 } 157 }
158 158
159 void NTPLoginHandler::RecordInHistogram(int type) { 159 void NTPLoginHandler::RecordInHistogram(int type) {
160 // Invalid type to record. 160 // Invalid type to record.
161 if (type < NTP_SIGN_IN_PROMO_VIEWED || 161 if (type < NTP_SIGN_IN_PROMO_VIEWED ||
162 type > NTP_SIGN_IN_PROMO_CLICKED) { 162 type > NTP_SIGN_IN_PROMO_CLICKED) {
163 NOTREACHED(); 163 NOTREACHED();
164 } else { 164 } else {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); 252 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)));
253 values->SetString("login_status_url", 253 values->SetString("login_status_url",
254 google_util::StringAppendGoogleLocaleParam(chrome::kSyncLearnMoreURL)); 254 google_util::StringAppendGoogleLocaleParam(chrome::kSyncLearnMoreURL));
255 values->SetString("login_status_learn_more", 255 values->SetString("login_status_learn_more",
256 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); 256 l10n_util::GetStringUTF16(IDS_LEARN_MORE));
257 values->SetString("login_status_advanced", 257 values->SetString("login_status_advanced",
258 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); 258 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED));
259 values->SetString("login_status_dismiss", 259 values->SetString("login_status_dismiss",
260 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); 260 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK));
261 } 261 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_ui.cc ('k') | chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698