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

Side by Side Diff: ash/system/chromeos/screen_layout_observer.h

Issue 2732813002: chromeos: Move files in //ash/common to //ash, part 1 (Closed)
Patch Set: rebase Created 3 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef ASH_SYSTEM_CHROMEOS_SCREEN_LAYOUT_OBSERVER_H_
6 #define ASH_SYSTEM_CHROMEOS_SCREEN_LAYOUT_OBSERVER_H_
7
8 #include <stdint.h>
9
10 #include <map>
11
12 #include "ash/ash_export.h"
13 #include "ash/common/wm_display_observer.h"
14 #include "base/macros.h"
15 #include "base/strings/string16.h"
16 #include "ui/display/manager/managed_display_info.h"
17
18 namespace ash {
19
20 // ScreenLayoutObserver is responsible to send notification to users when screen
21 // resolution changes or screen rotation changes.
22 class ASH_EXPORT ScreenLayoutObserver : public WmDisplayObserver {
23 public:
24 ScreenLayoutObserver();
25 ~ScreenLayoutObserver() override;
26
27 // Overridden from WmDisplayObserver:
28 void OnDisplayConfigurationChanged() override;
29
30 // Notifications are shown in production and are not shown in unit tests.
31 // Allow individual unit tests to show notifications.
32 void set_show_notifications_for_testing(bool show) {
33 show_notifications_for_testing = show;
34 }
35
36 private:
37 friend class ScreenLayoutObserverTest;
38
39 using DisplayInfoMap = std::map<int64_t, display::ManagedDisplayInfo>;
40
41 static const char kNotificationId[];
42
43 // Scans the current display info and updates |display_info_|. Sets the
44 // previous data to |old_info| if it's not NULL.
45 void UpdateDisplayInfo(DisplayInfoMap* old_info);
46
47 // Compares the current display settings with |old_info| and determine what
48 // message should be shown for notification. Returns true if there's a
49 // meaningful change. Note that it's possible to return true and set
50 // |message_out| to empty, which means the notification should be removed. It
51 // also sets |additional_message_out| which appears in the notification with
52 // the |message_out|.
53 bool GetDisplayMessageForNotification(const DisplayInfoMap& old_info,
54 base::string16* out_message,
55 base::string16* out_additional_message);
56
57 // Creates or updates the display notification.
58 void CreateOrUpdateNotification(const base::string16& message,
59 const base::string16& additional_message);
60
61 // Returns the notification message that should be shown when mirror display
62 // mode is exited.
63 bool GetExitMirrorModeMessage(base::string16* out_message,
64 base::string16* out_additional_message);
65
66 DisplayInfoMap display_info_;
67
68 enum class DisplayMode {
69 SINGLE,
70 EXTENDED_2, // 2 displays in extended mode.
71 EXTENDED_3_PLUS, // 3+ displays in extended mode.
72 MIRRORING,
73 UNIFIED,
74 DOCKED
75 };
76
77 DisplayMode old_display_mode_ = DisplayMode::SINGLE;
78 DisplayMode current_display_mode_ = DisplayMode::SINGLE;
79
80 bool show_notifications_for_testing = true;
81
82 DISALLOW_COPY_AND_ASSIGN(ScreenLayoutObserver);
83 };
84
85 } // namespace ash
86
87 #endif // ASH_SYSTEM_CHROMEOS_SCREEN_LAYOUT_OBSERVER_H_
OLDNEW
« no previous file with comments | « ash/system/chromeos/rotation/tray_rotation_lock_unittest.cc ('k') | ash/system/chromeos/screen_layout_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698