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

Side by Side Diff: chrome/browser/extensions/api/notifications/notifications_api.cc

Issue 2335293002: ShouldDisplayOverFullscreen implementation (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | chrome/browser/extensions/api/notifications/notifications_apitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/extensions/api/notifications/notifications_api.h" 5 #include "chrome/browser/extensions/api/notifications/notifications_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 13 matching lines...) Expand all
24 #include "chrome/browser/notifications/notification_ui_manager.h" 24 #include "chrome/browser/notifications/notification_ui_manager.h"
25 #include "chrome/browser/notifications/notifier_state_tracker.h" 25 #include "chrome/browser/notifications/notifier_state_tracker.h"
26 #include "chrome/browser/notifications/notifier_state_tracker_factory.h" 26 #include "chrome/browser/notifications/notifier_state_tracker_factory.h"
27 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/common/extensions/api/notifications/notification_style.h" 28 #include "chrome/common/extensions/api/notifications/notification_style.h"
29 #include "components/keyed_service/content/browser_context_keyed_service_shutdow n_notifier_factory.h" 29 #include "components/keyed_service/content/browser_context_keyed_service_shutdow n_notifier_factory.h"
30 #include "components/keyed_service/core/keyed_service_shutdown_notifier.h" 30 #include "components/keyed_service/core/keyed_service_shutdown_notifier.h"
31 #include "content/public/browser/render_process_host.h" 31 #include "content/public/browser/render_process_host.h"
32 #include "content/public/browser/render_view_host.h" 32 #include "content/public/browser/render_view_host.h"
33 #include "content/public/browser/web_contents.h" 33 #include "content/public/browser/web_contents.h"
34 #include "extensions/browser/app_window/app_window.h"
35 #include "extensions/browser/app_window/app_window_registry.h"
34 #include "extensions/browser/event_router.h" 36 #include "extensions/browser/event_router.h"
35 #include "extensions/browser/extension_system_provider.h" 37 #include "extensions/browser/extension_system_provider.h"
36 #include "extensions/browser/extensions_browser_client.h" 38 #include "extensions/browser/extensions_browser_client.h"
37 #include "extensions/common/extension.h" 39 #include "extensions/common/extension.h"
38 #include "extensions/common/features/feature.h" 40 #include "extensions/common/features/feature.h"
39 #include "third_party/skia/include/core/SkBitmap.h" 41 #include "third_party/skia/include/core/SkBitmap.h"
40 #include "ui/base/layout.h" 42 #include "ui/base/layout.h"
41 #include "ui/gfx/image/image.h" 43 #include "ui/gfx/image/image.h"
42 #include "ui/gfx/image/image_skia.h" 44 #include "ui/gfx/image/image_skia.h"
43 #include "ui/gfx/image/image_skia_operations.h" 45 #include "ui/gfx/image/image_skia_operations.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 }; 138 };
137 139
138 class NotificationsApiDelegate : public NotificationDelegate { 140 class NotificationsApiDelegate : public NotificationDelegate {
139 public: 141 public:
140 NotificationsApiDelegate(ChromeAsyncExtensionFunction* api_function, 142 NotificationsApiDelegate(ChromeAsyncExtensionFunction* api_function,
141 Profile* profile, 143 Profile* profile,
142 const std::string& extension_id, 144 const std::string& extension_id,
143 const std::string& id) 145 const std::string& id)
144 : api_function_(api_function), 146 : api_function_(api_function),
145 event_router_(EventRouter::Get(profile)), 147 event_router_(EventRouter::Get(profile)),
148 profile_(profile),
146 extension_id_(extension_id), 149 extension_id_(extension_id),
147 id_(id), 150 id_(id),
148 scoped_id_(CreateScopedIdentifier(extension_id, id)) { 151 scoped_id_(CreateScopedIdentifier(extension_id, id)) {
149 DCHECK(api_function_); 152 DCHECK(api_function_);
150 shutdown_notifier_subscription_ = 153 shutdown_notifier_subscription_ =
151 ShutdownNotifierFactory::GetInstance()->Get(profile)->Subscribe( 154 ShutdownNotifierFactory::GetInstance()->Get(profile)->Subscribe(
152 base::Bind(&NotificationsApiDelegate::Shutdown, 155 base::Bind(&NotificationsApiDelegate::Shutdown,
153 base::Unretained(this))); 156 base::Unretained(this)));
154 } 157 }
155 158
(...skipping 25 matching lines...) Expand all
181 void ButtonClick(int index) override { 184 void ButtonClick(int index) override {
182 std::unique_ptr<base::ListValue> args(CreateBaseEventArgs()); 185 std::unique_ptr<base::ListValue> args(CreateBaseEventArgs());
183 args->AppendInteger(index); 186 args->AppendInteger(index);
184 SendEvent(events::NOTIFICATIONS_ON_BUTTON_CLICKED, 187 SendEvent(events::NOTIFICATIONS_ON_BUTTON_CLICKED,
185 notifications::OnButtonClicked::kEventName, 188 notifications::OnButtonClicked::kEventName,
186 EventRouter::USER_GESTURE_ENABLED, std::move(args)); 189 EventRouter::USER_GESTURE_ENABLED, std::move(args));
187 } 190 }
188 191
189 std::string id() const override { return scoped_id_; } 192 std::string id() const override { return scoped_id_; }
190 193
194 // Should only display when fullscreen if this app is the source of the
195 // fullscreen window.
196 bool ShouldDisplayOverFullscreen() const override {
dewittj 2016/09/13 22:56:51 is it possible for two apps to have a fullscreen w
197 AppWindowRegistry::AppWindowList windows =
198 AppWindowRegistry::Get(profile_)->GetAppWindowsForApp(extension_id_);
199 bool shouldDisplay = false;
200 for (AppWindowRegistry::AppWindowList::const_iterator i = windows.begin();
dewittj 2016/09/13 22:56:51 for (const auto& window : windows)
201 i != windows.end() && !shouldDisplay; ++i) {
202 shouldDisplay |= (*i)->IsFullscreen();
dewittj 2016/09/13 22:56:51 I'd prefer: if (i->IsFullscreen()) return true;
203 }
204 return shouldDisplay;
205 }
206
191 private: 207 private:
192 ~NotificationsApiDelegate() override {} 208 ~NotificationsApiDelegate() override {}
193 209
194 void SendEvent(events::HistogramValue histogram_value, 210 void SendEvent(events::HistogramValue histogram_value,
195 const std::string& name, 211 const std::string& name,
196 EventRouter::UserGestureState user_gesture, 212 EventRouter::UserGestureState user_gesture,
197 std::unique_ptr<base::ListValue> args) { 213 std::unique_ptr<base::ListValue> args) {
198 if (!event_router_) 214 if (!event_router_)
199 return; 215 return;
200 216
(...skipping 14 matching lines...) Expand all
215 return args; 231 return args;
216 } 232 }
217 233
218 scoped_refptr<ChromeAsyncExtensionFunction> api_function_; 234 scoped_refptr<ChromeAsyncExtensionFunction> api_function_;
219 235
220 // Since this class is refcounted it may outlive the profile. We listen for 236 // Since this class is refcounted it may outlive the profile. We listen for
221 // profile-keyed service shutdown events and reset to nullptr at that time, 237 // profile-keyed service shutdown events and reset to nullptr at that time,
222 // so make sure to check for a valid pointer before use. 238 // so make sure to check for a valid pointer before use.
223 EventRouter* event_router_; 239 EventRouter* event_router_;
224 240
241 Profile* profile_;
225 const std::string extension_id_; 242 const std::string extension_id_;
226 const std::string id_; 243 const std::string id_;
227 const std::string scoped_id_; 244 const std::string scoped_id_;
228 245
229 std::unique_ptr<KeyedServiceShutdownNotifier::Subscription> 246 std::unique_ptr<KeyedServiceShutdownNotifier::Subscription>
230 shutdown_notifier_subscription_; 247 shutdown_notifier_subscription_;
231 248
232 DISALLOW_COPY_AND_ASSIGN(NotificationsApiDelegate); 249 DISALLOW_COPY_AND_ASSIGN(NotificationsApiDelegate);
233 }; 250 };
234 251
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 : api::notifications::PERMISSION_LEVEL_DENIED; 739 : api::notifications::PERMISSION_LEVEL_DENIED;
723 740
724 SetResult(base::MakeUnique<base::StringValue>( 741 SetResult(base::MakeUnique<base::StringValue>(
725 api::notifications::ToString(result))); 742 api::notifications::ToString(result)));
726 SendResponse(true); 743 SendResponse(true);
727 744
728 return true; 745 return true;
729 } 746 }
730 747
731 } // namespace extensions 748 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/notifications/notifications_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698