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

Side by Side Diff: chrome/browser/sync/glue/session_model_associator.cc

Issue 6693054: Get rid of extensions dependency from content\browser. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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/sync/glue/session_model_associator.h" 5 #include "chrome/browser/sync/glue/session_model_associator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "chrome/browser/browser_list.h" 11 #include "chrome/browser/browser_list.h"
12 #include "chrome/browser/browser_window.h" 12 #include "chrome/browser/browser_window.h"
13 #include "chrome/browser/extensions/extension_tab_helper.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/sync/profile_sync_service.h" 15 #include "chrome/browser/sync/profile_sync_service.h"
15 #include "chrome/browser/sync/syncable/syncable.h" 16 #include "chrome/browser/sync/syncable/syncable.h"
16 #include "chrome/browser/tabs/tab_strip_model.h" 17 #include "chrome/browser/tabs/tab_strip_model.h"
17 #include "chrome/common/extensions/extension.h" 18 #include "chrome/common/extensions/extension.h"
18 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
19 #include "content/browser/tab_contents/navigation_controller.h" 20 #include "content/browser/tab_contents/navigation_controller.h"
20 #include "content/browser/tab_contents/navigation_entry.h" 21 #include "content/browser/tab_contents/navigation_entry.h"
22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
21 #include "content/common/notification_details.h" 23 #include "content/common/notification_details.h"
22 #include "content/common/notification_service.h" 24 #include "content/common/notification_service.h"
23 25
24 namespace browser_sync { 26 namespace browser_sync {
25 27
26 namespace { 28 namespace {
27 static const char kNoSessionsFolderError[] = 29 static const char kNoSessionsFolderError[] =
28 "Server did not create the top-level sessions node. We " 30 "Server did not create the top-level sessions node. We "
29 "might be running against an out-of-date server."; 31 "might be running against an out-of-date server.";
30 32
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 tab_s->set_window_id(tab.controller().window_id().id()); 263 tab_s->set_window_id(tab.controller().window_id().id());
262 const int current_index = tab.controller().GetCurrentEntryIndex(); 264 const int current_index = tab.controller().GetCurrentEntryIndex();
263 const int min_index = std::max(0, 265 const int min_index = std::max(0,
264 current_index - max_sync_navigation_count); 266 current_index - max_sync_navigation_count);
265 const int max_index = std::min(current_index + max_sync_navigation_count, 267 const int max_index = std::min(current_index + max_sync_navigation_count,
266 tab.controller().entry_count()); 268 tab.controller().entry_count());
267 const int pending_index = tab.controller().pending_entry_index(); 269 const int pending_index = tab.controller().pending_entry_index();
268 int index_in_window = browser.tabstrip_model()->GetWrapperIndex(&tab); 270 int index_in_window = browser.tabstrip_model()->GetWrapperIndex(&tab);
269 DCHECK(index_in_window != TabStripModel::kNoTab); 271 DCHECK(index_in_window != TabStripModel::kNoTab);
270 tab_s->set_pinned(browser.tabstrip_model()->IsTabPinned(index_in_window)); 272 tab_s->set_pinned(browser.tabstrip_model()->IsTabPinned(index_in_window));
271 if (tab.extension_app()) 273 TabContentsWrapper* wrapper =
272 tab_s->set_extension_app_id(tab.extension_app()->id()); 274 TabContentsWrapper::GetCurrentWrapperForContents(
275 const_cast<TabContents*>(&tab));
276 if (wrapper->extension_tab_helper()->extension_app()) {
277 tab_s->set_extension_app_id(
278 wrapper->extension_tab_helper()->extension_app()->id());
279 }
273 for (int i = min_index; i < max_index; ++i) { 280 for (int i = min_index; i < max_index; ++i) {
274 const NavigationEntry* entry = (i == pending_index) ? 281 const NavigationEntry* entry = (i == pending_index) ?
275 tab.controller().pending_entry() : tab.controller().GetEntryAtIndex(i); 282 tab.controller().pending_entry() : tab.controller().GetEntryAtIndex(i);
276 DCHECK(entry); 283 DCHECK(entry);
277 if (entry->virtual_url().is_valid()) { 284 if (entry->virtual_url().is_valid()) {
278 if (i == max_index - 1) { 285 if (i == max_index - 1) {
279 VLOG(1) << "Associating tab " << tab_id << " with sync id " << sync_id 286 VLOG(1) << "Associating tab " << tab_id << " with sync id " << sync_id
280 << " and url " << entry->virtual_url().possibly_invalid_spec(); 287 << " and url " << entry->virtual_url().possibly_invalid_spec();
281 } 288 }
282 TabNavigation tab_nav; 289 TabNavigation tab_nav;
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 bool SessionModelAssociator::CryptoReadyIfNecessary() { 995 bool SessionModelAssociator::CryptoReadyIfNecessary() {
989 // We only access the cryptographer while holding a transaction. 996 // We only access the cryptographer while holding a transaction.
990 sync_api::ReadTransaction trans(sync_service_->GetUserShare()); 997 sync_api::ReadTransaction trans(sync_service_->GetUserShare());
991 syncable::ModelTypeSet encrypted_types; 998 syncable::ModelTypeSet encrypted_types;
992 sync_service_->GetEncryptedDataTypes(&encrypted_types); 999 sync_service_->GetEncryptedDataTypes(&encrypted_types);
993 return encrypted_types.count(syncable::SESSIONS) == 0 || 1000 return encrypted_types.count(syncable::SESSIONS) == 0 ||
994 sync_service_->IsCryptographerReady(&trans); 1001 sync_service_->IsCryptographerReady(&trans);
995 } 1002 }
996 1003
997 } // namespace browser_sync 1004 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/session_change_processor.cc ('k') | chrome/browser/tab_contents/background_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698