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

Side by Side Diff: chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h

Issue 12088040: Add a SigninAllowed policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address nits and rebase to ToT. Created 7 years, 9 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 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_SYNC_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_SYNC_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_SYNC_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_SYNC_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/prefs/public/pref_change_registrar.h"
10 #include "chrome/browser/sync/profile_sync_service.h" 11 #include "chrome/browser/sync/profile_sync_service.h"
11 #include "chrome/browser/sync/sync_ui_util.h" 12 #include "chrome/browser/sync/sync_ui_util.h"
12 #include "content/public/browser/web_ui_message_handler.h" 13 #include "content/public/browser/web_ui_message_handler.h"
13 14
14 namespace base { 15 namespace base {
15 class ListValue; 16 class ListValue;
16 } 17 }
17 18
18 // Sends sync-state changes to the New Tab Page for UI updating and forwards 19 // Sends sync-state changes to the New Tab Page for UI updating and forwards
19 // link clicks on the page to the sync service. 20 // link clicks on the page to the sync service.
20 class NewTabPageSyncHandler : public content::WebUIMessageHandler, 21 class NewTabPageSyncHandler : public content::WebUIMessageHandler,
21 public ProfileSyncServiceObserver { 22 public ProfileSyncServiceObserver {
22 public: 23 public:
23 NewTabPageSyncHandler(); 24 NewTabPageSyncHandler();
24 virtual ~NewTabPageSyncHandler(); 25 virtual ~NewTabPageSyncHandler();
25 26
26 // WebUIMessageHandler implementation. 27 // WebUIMessageHandler implementation.
27 virtual void RegisterMessages() OVERRIDE; 28 virtual void RegisterMessages() OVERRIDE;
28 29
29 // Callback for "GetSyncMessage". 30 // Callback for "GetSyncMessage".
30 void HandleGetSyncMessage(const base::ListValue* args); 31 void HandleGetSyncMessage(const base::ListValue* args);
31 // Callback for "SyncLinkClicked". 32 // Callback for "SyncLinkClicked".
32 void HandleSyncLinkClicked(const base::ListValue* args); 33 void HandleSyncLinkClicked(const base::ListValue* args);
33 34
34 // ProfileSyncServiceObserver 35 // ProfileSyncServiceObserver
35 virtual void OnStateChanged() OVERRIDE; 36 virtual void OnStateChanged() OVERRIDE;
36 37
38 void OnSigninAllowedPrefChange();
39
37 private: 40 private:
41 friend class MockNewTabPageSyncHandler;
42 FRIEND_TEST_ALL_PREFIXES(NewTabPageSyncHandlerBrowserTest,
43 ChangeSigninAllowedToFalse);
44
38 enum MessageType { 45 enum MessageType {
39 HIDE, 46 HIDE,
40 SYNC_ERROR, 47 SYNC_ERROR,
41 SYNC_PROMO 48 SYNC_PROMO
42 }; 49 };
43 // Helper to invoke the |syncMessageChanged| JS function on the new tab page. 50 // Helper to invoke the |syncMessageChanged| JS function on the new tab page.
44 void SendSyncMessageToPage(MessageType type, 51 virtual void SendSyncMessageToPage(MessageType type,
45 std::string msg, std::string linktext); 52 std::string msg, std::string linktext);
46 53
47 // Helper to query the sync service and figure out what to send to 54 // Helper to query the sync service and figure out what to send to
48 // the page, and send it via SendSyncMessageToPage. 55 // the page, and send it via SendSyncMessageToPage.
49 // NOTE: precondition: sync must be enabled. 56 // NOTE: precondition: sync must be enabled.
50 void BuildAndSendSyncStatus(); 57 void BuildAndSendSyncStatus();
51 58
52 // Helper to send a message to the NNTP which hides the sync section. 59 // Helper to send a message to the NNTP which hides the sync section.
53 void HideSyncStatusSection(); 60 void HideSyncStatusSection();
54 61
55 // Helper to convert from a sync status message type to an NTP specific one. 62 // Helper to convert from a sync status message type to an NTP specific one.
56 static MessageType FromSyncStatusMessageType( 63 static MessageType FromSyncStatusMessageType(
57 sync_ui_util::MessageType type); 64 sync_ui_util::MessageType type);
58 65
59 // Cached pointer to ProfileSyncService. 66 // Cached pointer to ProfileSyncService.
60 ProfileSyncService* sync_service_; 67 ProfileSyncService* sync_service_;
61 68
69 PrefChangeRegistrar profile_pref_registrar_;
70
62 // Used to make sure we don't register ourselves twice if the user refreshes 71 // Used to make sure we don't register ourselves twice if the user refreshes
63 // the new tab page. 72 // the new tab page.
64 bool waiting_for_initial_page_load_; 73 bool waiting_for_initial_page_load_;
65 74
66 DISALLOW_COPY_AND_ASSIGN(NewTabPageSyncHandler); 75 DISALLOW_COPY_AND_ASSIGN(NewTabPageSyncHandler);
67 }; 76 };
68 77
69 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_SYNC_HANDLER_H_ 78 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_SYNC_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/wrench_menu_model.cc ('k') | chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698