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

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

Issue 10911196: Support for ntp promo bubble. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/memory/scoped_ptr.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 static bool default_apps_trial_exists = 45 static bool default_apps_trial_exists =
46 base::FieldTrialList::TrialExists(kDefaultAppsTrialName); 46 base::FieldTrialList::TrialExists(kDefaultAppsTrialName);
47 if (default_apps_trial_exists) { 47 if (default_apps_trial_exists) {
48 UMA_HISTOGRAM_ENUMERATION( 48 UMA_HISTOGRAM_ENUMERATION(
49 base::FieldTrial::MakeName(kDefaultPageTypeHistogram, 49 base::FieldTrial::MakeName(kDefaultPageTypeHistogram,
50 kDefaultAppsTrialName), 50 kDefaultAppsTrialName),
51 shown_page_type, kHistogramEnumerationMax); 51 shown_page_type, kHistogramEnumerationMax);
52 } 52 }
53 53
54 web_ui()->RegisterMessageCallback("closeNotificationPromo", 54 web_ui()->RegisterMessageCallback("notificationPromoClosed",
55 base::Bind(&NewTabPageHandler::HandleCloseNotificationPromo, 55 base::Bind(&NewTabPageHandler::HandleNotificationPromoClosed,
56 base::Unretained(this))); 56 base::Unretained(this)));
57 web_ui()->RegisterMessageCallback("notificationPromoViewed", 57 web_ui()->RegisterMessageCallback("notificationPromoViewed",
58 base::Bind(&NewTabPageHandler::HandleNotificationPromoViewed, 58 base::Bind(&NewTabPageHandler::HandleNotificationPromoViewed,
59 base::Unretained(this))); 59 base::Unretained(this)));
60 web_ui()->RegisterMessageCallback("bubblePromoClosed",
61 base::Bind(&NewTabPageHandler::HandleBubblePromoClosed,
62 base::Unretained(this)));
63 web_ui()->RegisterMessageCallback("bubblePromoViewed",
64 base::Bind(&NewTabPageHandler::HandleBubblePromoViewed,
65 base::Unretained(this)));
60 web_ui()->RegisterMessageCallback("pageSelected", 66 web_ui()->RegisterMessageCallback("pageSelected",
61 base::Bind(&NewTabPageHandler::HandlePageSelected, 67 base::Bind(&NewTabPageHandler::HandlePageSelected,
62 base::Unretained(this))); 68 base::Unretained(this)));
63 } 69 }
64 70
65 void NewTabPageHandler::HandleCloseNotificationPromo(const ListValue* args) { 71 void NewTabPageHandler::HandleNotificationPromoClosed(const ListValue* args) {
66 NotificationPromo::HandleClosed(Profile::FromWebUI(web_ui()), 72 NotificationPromo::HandleClosed(Profile::FromWebUI(web_ui()),
67 NotificationPromo::NTP_NOTIFICATION_PROMO); 73 NotificationPromo::NTP_NOTIFICATION_PROMO);
68 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED); 74 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED);
69 } 75 }
70 76
71 void NewTabPageHandler::HandleNotificationPromoViewed(const ListValue* args) { 77 void NewTabPageHandler::HandleNotificationPromoViewed(const ListValue* args) {
72 if (NotificationPromo::HandleViewed(Profile::FromWebUI(web_ui()), 78 if (NotificationPromo::HandleViewed(Profile::FromWebUI(web_ui()),
73 NotificationPromo::NTP_NOTIFICATION_PROMO)) { 79 NotificationPromo::NTP_NOTIFICATION_PROMO)) {
74 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED); 80 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED);
75 } 81 }
76 } 82 }
77 83
84 void NewTabPageHandler::HandleBubblePromoClosed(const ListValue* args) {
85 NotificationPromo::HandleClosed(Profile::FromWebUI(web_ui()),
86 NotificationPromo::NTP_BUBBLE_PROMO);
87 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED);
88 }
89
90 void NewTabPageHandler::HandleBubblePromoViewed(const ListValue* args) {
91 if (NotificationPromo::HandleViewed(Profile::FromWebUI(web_ui()),
92 NotificationPromo::NTP_BUBBLE_PROMO)) {
Dan Beam 2012/09/11 03:44:57 nit: needs moar spacez
achuithb 2012/09/11 20:27:05 Done.
93 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED);
94 }
95 }
96
78 void NewTabPageHandler::HandlePageSelected(const ListValue* args) { 97 void NewTabPageHandler::HandlePageSelected(const ListValue* args) {
79 page_switch_count_++; 98 page_switch_count_++;
80 99
81 double page_id_double; 100 double page_id_double;
82 CHECK(args->GetDouble(0, &page_id_double)); 101 CHECK(args->GetDouble(0, &page_id_double));
83 int page_id = static_cast<int>(page_id_double); 102 int page_id = static_cast<int>(page_id_double);
84 103
85 double index_double; 104 double index_double;
86 CHECK(args->GetDouble(1, &index_double)); 105 CHECK(args->GetDouble(1, &index_double));
87 int index = static_cast<int>(index_double); 106 int index = static_cast<int>(index_double);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 values->SetInteger("shown_page_index", shown_page & INDEX_MASK); 149 values->SetInteger("shown_page_index", shown_page & INDEX_MASK);
131 } 150 }
132 151
133 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) { 152 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) {
134 content::NotificationService* service = 153 content::NotificationService* service =
135 content::NotificationService::current(); 154 content::NotificationService::current();
136 service->Notify(notification_type, 155 service->Notify(notification_type,
137 content::Source<NewTabPageHandler>(this), 156 content::Source<NewTabPageHandler>(this),
138 content::NotificationService::NoDetails()); 157 content::NotificationService::NoDetails());
139 } 158 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698