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

Side by Side Diff: chrome/browser/ui/webui/foreign_session_handler.h

Issue 2376123003: [Sync] Move //components/sync to the syncer namespace. (Closed)
Patch Set: Rebase. Created 4 years, 2 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #ifndef CHROME_BROWSER_UI_WEBUI_FOREIGN_SESSION_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_FOREIGN_SESSION_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_FOREIGN_SESSION_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_FOREIGN_SESSION_HANDLER_H_
7 7
8 #include <string>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/scoped_observer.h" 12 #include "base/scoped_observer.h"
12 #include "base/time/time.h" 13 #include "base/time/time.h"
13 #include "chrome/browser/sessions/session_service.h" 14 #include "chrome/browser/sessions/session_service.h"
14 #include "components/sync/driver/sync_service_observer.h" 15 #include "components/sync/driver/sync_service_observer.h"
15 #include "components/sync_sessions/open_tabs_ui_delegate.h" 16 #include "components/sync_sessions/open_tabs_ui_delegate.h"
16 #include "content/public/browser/web_ui.h" 17 #include "content/public/browser/web_ui.h"
17 #include "content/public/browser/web_ui_message_handler.h" 18 #include "content/public/browser/web_ui_message_handler.h"
18 19
19 namespace sessions { 20 namespace sessions {
20 struct SessionTab; 21 struct SessionTab;
21 struct SessionWindow; 22 struct SessionWindow;
22 } 23 }
23 24
24 namespace sync_driver { 25 namespace syncer {
25 class SyncService; 26 class SyncService;
26 } 27 }
27 28
28 namespace user_prefs { 29 namespace user_prefs {
29 class PrefRegistrySyncable; 30 class PrefRegistrySyncable;
30 } 31 }
31 32
32 namespace browser_sync { 33 namespace browser_sync {
33 34
34 class ForeignSessionHandler : public content::WebUIMessageHandler, 35 class ForeignSessionHandler : public content::WebUIMessageHandler,
35 public sync_driver::SyncServiceObserver { 36 public syncer::SyncServiceObserver {
36 public: 37 public:
37 // Invalid value, used to note that we don't have a tab or window number. 38 // Invalid value, used to note that we don't have a tab or window number.
38 static const int kInvalidId = -1; 39 static const int kInvalidId = -1;
39 40
40 // WebUIMessageHandler implementation. 41 // WebUIMessageHandler implementation.
41 void RegisterMessages() override; 42 void RegisterMessages() override;
42 43
43 ForeignSessionHandler(); 44 ForeignSessionHandler();
44 ~ForeignSessionHandler() override; 45 ~ForeignSessionHandler() override;
45 46
46 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 47 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
47 48
48 static void OpenForeignSessionTab(content::WebUI* web_ui, 49 static void OpenForeignSessionTab(content::WebUI* web_ui,
49 const std::string& session_string_value, 50 const std::string& session_string_value,
50 SessionID::id_type window_num, 51 SessionID::id_type window_num,
51 SessionID::id_type tab_id, 52 SessionID::id_type tab_id,
52 const WindowOpenDisposition& disposition); 53 const WindowOpenDisposition& disposition);
53 54
54 static void OpenForeignSessionWindows(content::WebUI* web_ui, 55 static void OpenForeignSessionWindows(content::WebUI* web_ui,
55 const std::string& session_string_value, 56 const std::string& session_string_value,
56 SessionID::id_type window_num); 57 SessionID::id_type window_num);
57 58
58 // Returns a pointer to the current session model associator or NULL. 59 // Returns a pointer to the current session model associator or NULL.
59 static sync_sessions::OpenTabsUIDelegate* GetOpenTabsUIDelegate( 60 static sync_sessions::OpenTabsUIDelegate* GetOpenTabsUIDelegate(
60 content::WebUI* web_ui); 61 content::WebUI* web_ui);
61 62
62 private: 63 private:
63 // sync_driver::SyncServiceObserver: 64 // syncer::SyncServiceObserver:
64 void OnStateChanged() override {} 65 void OnStateChanged() override {}
65 void OnSyncConfigurationCompleted() override; 66 void OnSyncConfigurationCompleted() override;
66 void OnForeignSessionUpdated() override; 67 void OnForeignSessionUpdated() override;
67 68
68 // Returns true if tab sync is enabled for this profile, otherwise false. 69 // Returns true if tab sync is enabled for this profile, otherwise false.
69 bool IsTabSyncEnabled(); 70 bool IsTabSyncEnabled();
70 71
71 // Returns a string used to show the user when a session was last modified. 72 // Returns a string used to show the user when a session was last modified.
72 base::string16 FormatSessionTime(const base::Time& time); 73 base::string16 FormatSessionTime(const base::Time& time);
73 74
74 // Determines which session is to be opened, and then calls 75 // Determines which session is to be opened, and then calls
75 // OpenForeignSession, to begin the process of opening a new browser window. 76 // OpenForeignSession, to begin the process of opening a new browser window.
76 // This is a javascript callback handler. 77 // This is a javascript callback handler.
77 void HandleOpenForeignSession(const base::ListValue* args); 78 void HandleOpenForeignSession(const base::ListValue* args);
78 79
79 // Determines whether foreign sessions should be obtained from the sync model. 80 // Determines whether foreign sessions should be obtained from the sync model.
80 // This is a javascript callback handler, and it is also called when the sync 81 // This is a javascript callback handler, and it is also called when the sync
81 // model has changed and the new tab page needs to reflect the changes. 82 // model has changed and the new tab page needs to reflect the changes.
82 void HandleGetForeignSessions(const base::ListValue* args); 83 void HandleGetForeignSessions(const base::ListValue* args);
83 84
84 // Delete a foreign session. This will remove it from the list of foreign 85 // Delete a foreign session. This will remove it from the list of foreign
85 // sessions on all devices. It will reappear if the session is re-activated 86 // sessions on all devices. It will reappear if the session is re-activated
86 // on the original device. 87 // on the original device.
87 // This is a javascript callback handler. 88 // This is a javascript callback handler.
88 void HandleDeleteForeignSession(const base::ListValue* args); 89 void HandleDeleteForeignSession(const base::ListValue* args);
89 90
90 void HandleSetForeignSessionCollapsed(const base::ListValue* args); 91 void HandleSetForeignSessionCollapsed(const base::ListValue* args);
91 92
92 // ScopedObserver used to observe the ProfileSyncService. 93 // ScopedObserver used to observe the ProfileSyncService.
93 ScopedObserver<sync_driver::SyncService, sync_driver::SyncServiceObserver> 94 ScopedObserver<syncer::SyncService, syncer::SyncServiceObserver>
94 scoped_observer_; 95 scoped_observer_;
95 96
96 // The time at which this WebUI was created. Used to calculate how long 97 // The time at which this WebUI was created. Used to calculate how long
97 // the WebUI was present before the sessions data was visible. 98 // the WebUI was present before the sessions data was visible.
98 base::TimeTicks load_attempt_time_; 99 base::TimeTicks load_attempt_time_;
99 100
100 DISALLOW_COPY_AND_ASSIGN(ForeignSessionHandler); 101 DISALLOW_COPY_AND_ASSIGN(ForeignSessionHandler);
101 }; 102 };
102 103
103 } // namespace browser_sync 104 } // namespace browser_sync
104 105
105 #endif // CHROME_BROWSER_UI_WEBUI_FOREIGN_SESSION_HANDLER_H_ 106 #endif // CHROME_BROWSER_UI_WEBUI_FOREIGN_SESSION_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/browsing_history_handler.cc ('k') | chrome/browser/ui/webui/options/browser_options_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698