| 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 | 8 |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/sync/engine/syncapi.h" | 10 #include "chrome/browser/sync/engine/syncapi.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 NewCallback(this, &SessionsDOMHandler::HandleRequestSessions)); | 112 NewCallback(this, &SessionsDOMHandler::HandleRequestSessions)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void SessionsDOMHandler::HandleRequestSessions(const ListValue* args) { | 115 void SessionsDOMHandler::HandleRequestSessions(const ListValue* args) { |
| 116 UpdateUI(); | 116 UpdateUI(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 browser_sync::SessionModelAssociator* SessionsDOMHandler::GetModelAssociator() { | 119 browser_sync::SessionModelAssociator* SessionsDOMHandler::GetModelAssociator() { |
| 120 // We only want to get the model associator if there is one, and it is done | 120 // We only want to get the model associator if there is one, and it is done |
| 121 // syncing sessions. | 121 // syncing sessions. |
| 122 Profile* profile = web_ui_->GetProfile(); | 122 Profile* profile = |
| 123 Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context()); |
| 123 if (!profile->HasProfileSyncService()) | 124 if (!profile->HasProfileSyncService()) |
| 124 return NULL; | 125 return NULL; |
| 125 ProfileSyncService* service = profile->GetProfileSyncService(); | 126 ProfileSyncService* service = profile->GetProfileSyncService(); |
| 126 if (!service->ShouldPushChanges()) | 127 if (!service->ShouldPushChanges()) |
| 127 return NULL; | 128 return NULL; |
| 128 return service->GetSessionModelAssociator(); | 129 return service->GetSessionModelAssociator(); |
| 129 } | 130 } |
| 130 | 131 |
| 131 void SessionsDOMHandler::GetTabList( | 132 void SessionsDOMHandler::GetTabList( |
| 132 const std::vector<SessionTab*>& tabs, ListValue* tab_list) { | 133 const std::vector<SessionTab*>& tabs, ListValue* tab_list) { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); | 255 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); |
| 255 profile->GetChromeURLDataManager()->AddDataSource( | 256 profile->GetChromeURLDataManager()->AddDataSource( |
| 256 CreateSessionsUIHTMLSource()); | 257 CreateSessionsUIHTMLSource()); |
| 257 } | 258 } |
| 258 | 259 |
| 259 // static | 260 // static |
| 260 RefCountedMemory* SessionsUI::GetFaviconResourceBytes() { | 261 RefCountedMemory* SessionsUI::GetFaviconResourceBytes() { |
| 261 return ResourceBundle::GetSharedInstance(). | 262 return ResourceBundle::GetSharedInstance(). |
| 262 LoadDataResourceBytes(IDR_HISTORY_FAVICON); | 263 LoadDataResourceBytes(IDR_HISTORY_FAVICON); |
| 263 } | 264 } |
| OLD | NEW |