Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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("pageSelected", | 60 web_ui()->RegisterMessageCallback("pageSelected", |
| 61 base::Bind(&NewTabPageHandler::HandlePageSelected, | 61 base::Bind(&NewTabPageHandler::HandlePageSelected, |
| 62 base::Unretained(this))); | 62 base::Unretained(this))); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void NewTabPageHandler::HandleCloseNotificationPromo(const ListValue* args) { | 65 void NewTabPageHandler::HandleCloseNotificationPromo(const ListValue* args) { |
| 66 NotificationPromo notification_promo(Profile::FromWebUI(web_ui())); | 66 NotificationPromo::HandleClosed(Profile::FromWebUI(web_ui()), |
| 67 notification_promo.HandleClosed(); | 67 NotificationPromo::NTP_NOTIFICATION_PROMO); |
| 68 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED); | 68 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void NewTabPageHandler::HandleNotificationPromoViewed(const ListValue* args) { | 71 void NewTabPageHandler::HandleNotificationPromoViewed(const ListValue* args) { |
| 72 NotificationPromo notification_promo(Profile::FromWebUI(web_ui())); | 72 if (NotificationPromo::HandleViewed(Profile::FromWebUI(web_ui()), |
| 73 if (notification_promo.HandleViewed()) | 73 NotificationPromo::NTP_NOTIFICATION_PROMO)) { |
|
aruslan
2012/08/06 21:11:12
nit: indentation cf 6 lines above.
achuithb
2012/08/06 22:16:19
Done.
| |
| 74 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED); | 74 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED); |
| 75 } | |
| 75 } | 76 } |
| 76 | 77 |
| 77 void NewTabPageHandler::HandlePageSelected(const ListValue* args) { | 78 void NewTabPageHandler::HandlePageSelected(const ListValue* args) { |
| 78 page_switch_count_++; | 79 page_switch_count_++; |
| 79 | 80 |
| 80 double page_id_double; | 81 double page_id_double; |
| 81 CHECK(args->GetDouble(0, &page_id_double)); | 82 CHECK(args->GetDouble(0, &page_id_double)); |
| 82 int page_id = static_cast<int>(page_id_double); | 83 int page_id = static_cast<int>(page_id_double); |
| 83 | 84 |
| 84 double index_double; | 85 double index_double; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 values->SetInteger("shown_page_index", shown_page & INDEX_MASK); | 128 values->SetInteger("shown_page_index", shown_page & INDEX_MASK); |
| 128 } | 129 } |
| 129 | 130 |
| 130 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) { | 131 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) { |
| 131 content::NotificationService* service = | 132 content::NotificationService* service = |
| 132 content::NotificationService::current(); | 133 content::NotificationService::current(); |
| 133 service->Notify(notification_type, | 134 service->Notify(notification_type, |
| 134 content::Source<NewTabPageHandler>(this), | 135 content::Source<NewTabPageHandler>(this), |
| 135 content::NotificationService::NoDetails()); | 136 content::NotificationService::NoDetails()); |
| 136 } | 137 } |
| OLD | NEW |