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

Side by Side Diff: chrome/browser/ui/android/tab_model/tab_model.cc

Issue 2088443003: Shortcut ctrl+shift+T added on android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit fixes based on review. Created 4 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "chrome/browser/ui/android/tab_model/tab_model.h" 5 #include "chrome/browser/ui/android/tab_model/tab_model.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/sync/glue/synced_window_delegate_android.h" 11 #include "chrome/browser/sync/glue/synced_window_delegate_android.h"
12 #include "chrome/browser/sync/profile_sync_service_factory.h" 12 #include "chrome/browser/sync/profile_sync_service_factory.h"
13 #include "components/browser_sync/browser/profile_sync_service.h" 13 #include "components/browser_sync/browser/profile_sync_service.h"
14 #include "components/toolbar/toolbar_model_impl.h" 14 #include "components/toolbar/toolbar_model_impl.h"
15 #include "content/public/browser/notification_service.h" 15 #include "content/public/browser/notification_service.h"
16 16
17 using content::NotificationService; 17 using content::NotificationService;
18 18
19 // Keep this in sync with 19 // Keep this in sync with
20 // chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabList.java 20 // chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabList.java
21 static int INVALID_TAB_INDEX = -1; 21 static int INVALID_TAB_INDEX = -1;
22 22
23 TabModel::TabModel(Profile* profile) 23 TabModel::TabModel(Profile* profile)
24 : profile_(profile), 24 : profile_(profile),
25 live_tab_context_(new AndroidLiveTabContext(this)),
25 synced_window_delegate_( 26 synced_window_delegate_(
26 new browser_sync::SyncedWindowDelegateAndroid(this)) { 27 new browser_sync::SyncedWindowDelegateAndroid(this)) {
27 28
28 if (profile) { 29 if (profile) {
29 // A normal Profile creates an OTR profile if it does not exist when 30 // A normal Profile creates an OTR profile if it does not exist when
30 // GetOffTheRecordProfile() is called, so we guard it with 31 // GetOffTheRecordProfile() is called, so we guard it with
31 // HasOffTheRecordProfile(). An OTR profile returns itself when you call 32 // HasOffTheRecordProfile(). An OTR profile returns itself when you call
32 // GetOffTheRecordProfile(). 33 // GetOffTheRecordProfile().
33 is_off_the_record_ = (profile->HasOffTheRecordProfile() && 34 is_off_the_record_ = (profile->HasOffTheRecordProfile() &&
34 profile == profile->GetOffTheRecordProfile()); 35 profile == profile->GetOffTheRecordProfile());
(...skipping 22 matching lines...) Expand all
57 } 58 }
58 59
59 browser_sync::SyncedWindowDelegate* TabModel::GetSyncedWindowDelegate() const { 60 browser_sync::SyncedWindowDelegate* TabModel::GetSyncedWindowDelegate() const {
60 return synced_window_delegate_.get(); 61 return synced_window_delegate_.get();
61 } 62 }
62 63
63 SessionID::id_type TabModel::GetSessionId() const { 64 SessionID::id_type TabModel::GetSessionId() const {
64 return session_id_.id(); 65 return session_id_.id();
65 } 66 }
66 67
68 const SessionID& TabModel::SessionId() const {
69 return session_id_;
70 }
71
72 sessions::LiveTabContext* TabModel::GetLiveTabContext() const{
73 return live_tab_context_.get();
74 }
75
67 content::WebContents* TabModel::GetActiveWebContents() const { 76 content::WebContents* TabModel::GetActiveWebContents() const {
68 int active_index = GetActiveIndex(); 77 int active_index = GetActiveIndex();
69 if (active_index == INVALID_TAB_INDEX) 78 if (active_index == INVALID_TAB_INDEX)
70 return nullptr; 79 return nullptr;
71 return GetWebContentsAt(active_index); 80 return GetWebContentsAt(active_index);
72 } 81 }
73 82
74 void TabModel::BroadcastSessionRestoreComplete() { 83 void TabModel::BroadcastSessionRestoreComplete() {
75 if (profile_) { 84 if (profile_) {
76 ProfileSyncService* sync_service = 85 ProfileSyncService* sync_service =
(...skipping 24 matching lines...) Expand all
101 if (is_off_the_record_) { 110 if (is_off_the_record_) {
102 Profile* profile = content::Source<Profile>(source).ptr(); 111 Profile* profile = content::Source<Profile>(source).ptr();
103 if (profile && profile->IsOffTheRecord()) 112 if (profile && profile->IsOffTheRecord())
104 profile_ = profile; 113 profile_ = profile;
105 } 114 }
106 break; 115 break;
107 default: 116 default:
108 NOTREACHED(); 117 NOTREACHED();
109 } 118 }
110 } 119 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/tab_model/tab_model.h ('k') | chrome/browser/ui/android/tab_model/tab_model_jni_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698