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

Side by Side Diff: chrome/browser/notifications/web_notification_delegate.cc

Issue 2377553003: Add ShouldDisplayOverFullscreen support to web notifications. (Closed)
Patch Set: Final formatting fixes Created 4 years, 2 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
« no previous file with comments | « chrome/browser/notifications/web_notification_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/notifications/web_notification_delegate.h"
6
7 #include "chrome/browser/notifications/notification_common.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_list.h"
11 #include "chrome/browser/ui/browser_window.h"
12 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "content/public/browser/web_contents.h"
15
16 WebNotificationDelegate::WebNotificationDelegate(
17 content::BrowserContext* browser_context,
18 const std::string& notification_id,
19 const GURL& origin)
20 : browser_context_(browser_context),
21 notification_id_(notification_id),
22 origin_(origin) {}
23
24 WebNotificationDelegate::~WebNotificationDelegate() {}
25
26 std::string WebNotificationDelegate::id() const {
27 return notification_id_;
28 }
29
30 void WebNotificationDelegate::SettingsClick() {
31 NotificationCommon::OpenNotificationSettings(browser_context_);
32 }
33
34 bool WebNotificationDelegate::ShouldDisplaySettingsButton() {
35 return true;
36 }
37
38 bool WebNotificationDelegate::ShouldDisplayOverFullscreen() const {
39 #if !defined(OS_ANDROID)
40 Profile* profile = Profile::FromBrowserContext(browser_context_);
41 DCHECK(profile);
42 // Check to see if this notification comes from a webpage that is displaying
43 // fullscreen content.
44 for (auto* browser : *BrowserList::GetInstance()) {
45 // Only consider the browsers for the profile that created the notification
46 if (browser->profile() != profile)
47 continue;
48
49 const content::WebContents* active_contents =
50 browser->tab_strip_model()->GetActiveWebContents();
51 if (!active_contents)
52 continue;
53
54 // Check to see if
55 // (a) the active tab in the browser shares its origin with the
56 // notification.
57 // (b) the browser is fullscreen
58 // (c) the browser has focus.
59 if (active_contents->GetURL().GetOrigin() == origin_ &&
60 browser->exclusive_access_manager()->context()->IsFullscreen() &&
61 browser->window()->IsActive()) {
62 return true;
63 }
64 }
65 #endif
66
67 return false;
68 }
OLDNEW
« no previous file with comments | « chrome/browser/notifications/web_notification_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698