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

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

Issue 8520009: Only show G+ promo for users logged into G+ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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/new_tab_page_handler.h" 5 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/memory/scoped_ptr.h"
9 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
11 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/extensions/default_apps_trial.h" 13 #include "chrome/browser/extensions/default_apps_trial.h"
13 #include "chrome/browser/prefs/pref_service.h" 14 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/sync/profile_sync_service.h" 16 #include "chrome/browser/sync/profile_sync_service.h"
16 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 17 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
17 #include "chrome/browser/web_resource/notification_promo.h" 18 #include "chrome/browser/web_resource/notification_promo.h"
18 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 base::Unretained(this))); 60 base::Unretained(this)));
60 web_ui()->RegisterMessageCallback("introMessageDismissed", 61 web_ui()->RegisterMessageCallback("introMessageDismissed",
61 base::Bind(&NewTabPageHandler::HandleIntroMessageDismissed, 62 base::Bind(&NewTabPageHandler::HandleIntroMessageDismissed,
62 base::Unretained(this))); 63 base::Unretained(this)));
63 web_ui()->RegisterMessageCallback("introMessageSeen", 64 web_ui()->RegisterMessageCallback("introMessageSeen",
64 base::Bind(&NewTabPageHandler::HandleIntroMessageSeen, 65 base::Bind(&NewTabPageHandler::HandleIntroMessageSeen,
65 base::Unretained(this))); 66 base::Unretained(this)));
66 } 67 }
67 68
68 void NewTabPageHandler::HandleCloseNotificationPromo(const ListValue* args) { 69 void NewTabPageHandler::HandleCloseNotificationPromo(const ListValue* args) {
69 NotificationPromo notification_promo( 70 scoped_refptr<NotificationPromo> notification_promo =
70 Profile::FromWebUI(web_ui())->GetPrefs(), NULL); 71 NotificationPromo::Create(Profile::FromWebUI(web_ui()), NULL);
71 notification_promo.HandleClosed(); 72 notification_promo->HandleClosed();
72 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED); 73 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED);
73 } 74 }
74 75
75 void NewTabPageHandler::HandleNotificationPromoViewed(const ListValue* args) { 76 void NewTabPageHandler::HandleNotificationPromoViewed(const ListValue* args) {
76 NotificationPromo notification_promo( 77 scoped_refptr<NotificationPromo> notification_promo =
77 Profile::FromWebUI(web_ui_)->GetPrefs(), NULL); 78 NotificationPromo::Create(Profile::FromWebUI(web_ui_), NULL);
78 if (notification_promo.HandleViewed()) 79 if (notification_promo->HandleViewed())
79 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED); 80 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED);
80 } 81 }
81 82
82 void NewTabPageHandler::HandlePageSelected(const ListValue* args) { 83 void NewTabPageHandler::HandlePageSelected(const ListValue* args) {
83 double page_id_double; 84 double page_id_double;
84 CHECK(args->GetDouble(0, &page_id_double)); 85 CHECK(args->GetDouble(0, &page_id_double));
85 int page_id = static_cast<int>(page_id_double); 86 int page_id = static_cast<int>(page_id_double);
86 87
87 double index_double; 88 double index_double;
88 CHECK(args->GetDouble(1, &index_double)); 89 CHECK(args->GetDouble(1, &index_double));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // is only called during startup before the ntp resource cache is constructed. 174 // is only called during startup before the ntp resource cache is constructed.
174 } 175 }
175 176
176 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) { 177 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) {
177 content::NotificationService* service = 178 content::NotificationService* service =
178 content::NotificationService::current(); 179 content::NotificationService::current();
179 service->Notify(notification_type, 180 service->Notify(notification_type,
180 content::Source<NewTabPageHandler>(this), 181 content::Source<NewTabPageHandler>(this),
181 content::NotificationService::NoDetails()); 182 content::NotificationService::NoDetails());
182 } 183 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/web_resource/notification_promo.h » ('j') | chrome/browser/web_resource/notification_promo.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698