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

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

Issue 866443003: Push API: Don't require notification if tab is visible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ycm_outdir
Patch Set: Created 5 years, 11 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/ui/toolbar/toolbar_model_impl.h" 12 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h"
13 #include "content/public/browser/notification_service.h" 13 #include "content/public/browser/notification_service.h"
14 14
15 using content::NotificationService; 15 using content::NotificationService;
16 16
17 static int INVALID_TAB_INDEX = -1;
Michael van Ouwerkerk 2015/01/21 19:13:22 Similar comment as in TabList.java?
johnme 2015/01/21 19:32:19 Done.
18
17 TabModel::TabModel(Profile* profile) 19 TabModel::TabModel(Profile* profile)
18 : profile_(profile), 20 : profile_(profile),
19 synced_window_delegate_( 21 synced_window_delegate_(
20 new browser_sync::SyncedWindowDelegateAndroid(this)) { 22 new browser_sync::SyncedWindowDelegateAndroid(this)) {
21 23
22 if (profile) { 24 if (profile) {
23 // A normal Profile creates an OTR profile if it does not exist when 25 // A normal Profile creates an OTR profile if it does not exist when
24 // GetOffTheRecordProfile() is called, so we guard it with 26 // GetOffTheRecordProfile() is called, so we guard it with
25 // HasOffTheRecordProfile(). An OTR profile returns itself when you call 27 // HasOffTheRecordProfile(). An OTR profile returns itself when you call
26 // GetOffTheRecordProfile(). 28 // GetOffTheRecordProfile().
(...skipping 24 matching lines...) Expand all
51 } 53 }
52 54
53 browser_sync::SyncedWindowDelegate* TabModel::GetSyncedWindowDelegate() const { 55 browser_sync::SyncedWindowDelegate* TabModel::GetSyncedWindowDelegate() const {
54 return synced_window_delegate_.get(); 56 return synced_window_delegate_.get();
55 } 57 }
56 58
57 SessionID::id_type TabModel::GetSessionId() const { 59 SessionID::id_type TabModel::GetSessionId() const {
58 return session_id_.id(); 60 return session_id_.id();
59 } 61 }
60 62
63 content::WebContents* TabModel::GetActiveWebContents() const {
64 int active_index = GetActiveIndex();
65 if (active_index == INVALID_TAB_INDEX)
66 return nullptr;
67 return GetWebContentsAt(active_index);
68 }
69
61 void TabModel::BroadcastSessionRestoreComplete() { 70 void TabModel::BroadcastSessionRestoreComplete() {
62 if (profile_) { 71 if (profile_) {
63 NotificationService::current()->Notify( 72 NotificationService::current()->Notify(
64 chrome::NOTIFICATION_SESSION_RESTORE_COMPLETE, 73 chrome::NOTIFICATION_SESSION_RESTORE_COMPLETE,
65 content::Source<Profile>(profile_), 74 content::Source<Profile>(profile_),
66 NotificationService::NoDetails()); 75 NotificationService::NoDetails());
67 } else { 76 } else {
68 // TODO(nyquist): Uncomment this once downstream Android uses new 77 // TODO(nyquist): Uncomment this once downstream Android uses new
69 // constructor that takes a Profile* argument. See crbug.com/159704. 78 // constructor that takes a Profile* argument. See crbug.com/159704.
70 // NOTREACHED(); 79 // NOTREACHED();
(...skipping 17 matching lines...) Expand all
88 if (is_off_the_record_) { 97 if (is_off_the_record_) {
89 Profile* profile = content::Source<Profile>(source).ptr(); 98 Profile* profile = content::Source<Profile>(source).ptr();
90 if (profile && profile->IsOffTheRecord()) 99 if (profile && profile->IsOffTheRecord())
91 profile_ = profile; 100 profile_ = profile;
92 } 101 }
93 break; 102 break;
94 default: 103 default:
95 NOTREACHED(); 104 NOTREACHED();
96 } 105 }
97 } 106 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698