| OLD | NEW |
| 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/sessions_ui.h" | 5 #include "chrome/browser/ui/webui/sessions_ui.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/sync/glue/session_model_associator.h" | 13 #include "chrome/browser/sync/glue/session_model_associator.h" |
| 14 #include "chrome/browser/sync/glue/synced_session.h" | 14 #include "chrome/browser/sync/glue/synced_session.h" |
| 15 #include "chrome/browser/sync/profile_sync_service.h" | 15 #include "chrome/browser/sync/profile_sync_service.h" |
| 16 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 17 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 17 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 18 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
| 18 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 19 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| 19 #include "chrome/common/chrome_version_info.h" | 20 #include "chrome/common/chrome_version_info.h" |
| 20 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/browser/web_ui.h" | 23 #include "content/public/browser/web_ui.h" |
| 23 #include "content/public/browser/web_ui_message_handler.h" | 24 #include "content/public/browser/web_ui_message_handler.h" |
| 24 #include "grit/browser_resources.h" | 25 #include "grit/browser_resources.h" |
| 25 #include "grit/chromium_strings.h" | 26 #include "grit/chromium_strings.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 void SessionsDOMHandler::HandleRequestSessions(const ListValue* args) { | 121 void SessionsDOMHandler::HandleRequestSessions(const ListValue* args) { |
| 121 UpdateUI(); | 122 UpdateUI(); |
| 122 } | 123 } |
| 123 | 124 |
| 124 browser_sync::SessionModelAssociator* SessionsDOMHandler::GetModelAssociator() { | 125 browser_sync::SessionModelAssociator* SessionsDOMHandler::GetModelAssociator() { |
| 125 // We only want to get the model associator if there is one, and it is done | 126 // We only want to get the model associator if there is one, and it is done |
| 126 // syncing sessions. | 127 // syncing sessions. |
| 127 Profile* profile = Profile::FromWebUI(web_ui()); | 128 Profile* profile = Profile::FromWebUI(web_ui()); |
| 128 if (!profile->HasProfileSyncService()) | 129 if (!profile->HasProfileSyncService()) |
| 129 return NULL; | 130 return NULL; |
| 130 ProfileSyncService* service = profile->GetProfileSyncService(); | 131 ProfileSyncService* service(ProfileSyncServiceFactory:: |
| 132 GetInstance()->GetForProfile(profile)); |
| 131 if (!service->ShouldPushChanges()) | 133 if (!service->ShouldPushChanges()) |
| 132 return NULL; | 134 return NULL; |
| 133 return service->GetSessionModelAssociator(); | 135 return service->GetSessionModelAssociator(); |
| 134 } | 136 } |
| 135 | 137 |
| 136 void SessionsDOMHandler::GetTabList( | 138 void SessionsDOMHandler::GetTabList( |
| 137 const std::vector<SessionTab*>& tabs, ListValue* tab_list) { | 139 const std::vector<SessionTab*>& tabs, ListValue* tab_list) { |
| 138 for (std::vector<SessionTab*>::const_iterator it = tabs.begin(); | 140 for (std::vector<SessionTab*>::const_iterator it = tabs.begin(); |
| 139 it != tabs.end(); ++it) { | 141 it != tabs.end(); ++it) { |
| 140 const SessionTab* tab = *it; | 142 const SessionTab* tab = *it; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 Profile* profile = Profile::FromWebUI(web_ui); | 266 Profile* profile = Profile::FromWebUI(web_ui); |
| 265 profile->GetChromeURLDataManager()->AddDataSource( | 267 profile->GetChromeURLDataManager()->AddDataSource( |
| 266 CreateSessionsUIHTMLSource()); | 268 CreateSessionsUIHTMLSource()); |
| 267 } | 269 } |
| 268 | 270 |
| 269 // static | 271 // static |
| 270 RefCountedMemory* SessionsUI::GetFaviconResourceBytes() { | 272 RefCountedMemory* SessionsUI::GetFaviconResourceBytes() { |
| 271 return ResourceBundle::GetSharedInstance(). | 273 return ResourceBundle::GetSharedInstance(). |
| 272 LoadDataResourceBytes(IDR_HISTORY_FAVICON); | 274 LoadDataResourceBytes(IDR_HISTORY_FAVICON); |
| 273 } | 275 } |
| OLD | NEW |