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

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

Issue 7481023: Adding notifications for new sync types. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Now acknowledges sync types when notification is clocked. Created 9 years, 4 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/new_tab_page_handler.h" 5 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/common/pref_names.h" 8 #include "chrome/common/pref_names.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/sync/profile_sync_service.h"
11 #include "chrome/common/chrome_notification_types.h" 12 #include "chrome/common/chrome_notification_types.h"
12 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
13 #include "content/common/notification_service.h" 14 #include "content/common/notification_service.h"
14 15
15 void NewTabPageHandler::RegisterMessages() { 16 void NewTabPageHandler::RegisterMessages() {
16 web_ui_->RegisterMessageCallback("closePromo", NewCallback( 17 web_ui_->RegisterMessageCallback("closePromo", NewCallback(
17 this, &NewTabPageHandler::HandleClosePromo)); 18 this, &NewTabPageHandler::HandleClosePromo));
19 web_ui_->RegisterMessageCallback("closeSyncNotification", NewCallback(
20 this, &NewTabPageHandler::HandleCloseSyncNotification));
18 web_ui_->RegisterMessageCallback("pageSelected", NewCallback( 21 web_ui_->RegisterMessageCallback("pageSelected", NewCallback(
19 this, &NewTabPageHandler::HandlePageSelected)); 22 this, &NewTabPageHandler::HandlePageSelected));
20 } 23 }
21 24
22 void NewTabPageHandler::HandleClosePromo(const ListValue* args) { 25 void NewTabPageHandler::HandleClosePromo(const ListValue* args) {
23 web_ui_->GetProfile()->GetPrefs()->SetBoolean(prefs::kNTPPromoClosed, true); 26 web_ui_->GetProfile()->GetPrefs()->SetBoolean(prefs::kNTPPromoClosed, true);
24 NotificationService* service = NotificationService::current(); 27 NotificationService* service = NotificationService::current();
25 service->Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, 28 service->Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED,
26 Source<NewTabPageHandler>(this), 29 Source<NewTabPageHandler>(this),
27 NotificationService::NoDetails()); 30 NotificationService::NoDetails());
28 } 31 }
29 32
33 void NewTabPageHandler::HandleCloseSyncNotification(const ListValue* args) {
34 ProfileSyncService* service = web_ui_->GetProfile()->GetProfileSyncService();
35 if (service)
36 service->AcknowledgeSyncedTypes();
37 }
38
30 void NewTabPageHandler::HandlePageSelected(const ListValue* args) { 39 void NewTabPageHandler::HandlePageSelected(const ListValue* args) {
31 double page_id_double; 40 double page_id_double;
32 CHECK(args->GetDouble(0, &page_id_double)); 41 CHECK(args->GetDouble(0, &page_id_double));
33 int page_id = static_cast<int>(page_id_double); 42 int page_id = static_cast<int>(page_id_double);
34 43
35 double index_double; 44 double index_double;
36 CHECK(args->GetDouble(1, &index_double)); 45 CHECK(args->GetDouble(1, &index_double));
37 int index = static_cast<int>(index_double); 46 int index = static_cast<int>(index_double);
38 47
39 PrefService* prefs = web_ui_->GetProfile()->GetPrefs(); 48 PrefService* prefs = web_ui_->GetProfile()->GetPrefs();
(...skipping 17 matching lines...) Expand all
57 values->SetInteger("apps_page_id", APPS_PAGE_ID); 66 values->SetInteger("apps_page_id", APPS_PAGE_ID);
58 values->SetInteger("bookmarks_page_id", BOOKMARKS_PAGE_ID); 67 values->SetInteger("bookmarks_page_id", BOOKMARKS_PAGE_ID);
59 68
60 // TODO(estade) Should respect shown sections pref (i.e. migrate if it 69 // TODO(estade) Should respect shown sections pref (i.e. migrate if it
61 // exists). 70 // exists).
62 PrefService* prefs = profile->GetPrefs(); 71 PrefService* prefs = profile->GetPrefs();
63 int shown_page = prefs->GetInteger(prefs::kNTPShownPage); 72 int shown_page = prefs->GetInteger(prefs::kNTPShownPage);
64 values->SetInteger("shown_page_type", shown_page & ~INDEX_MASK); 73 values->SetInteger("shown_page_type", shown_page & ~INDEX_MASK);
65 values->SetInteger("shown_page_index", shown_page & INDEX_MASK); 74 values->SetInteger("shown_page_index", shown_page & INDEX_MASK);
66 } 75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698