Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / network_profile_bubble.h
blobfb43906899885150fe9e2bc9cecbb53e8ad4c3ef
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.
5 #ifndef CHROME_BROWSER_UI_NETWORK_PROFILE_BUBBLE_H_
6 #define CHROME_BROWSER_UI_NETWORK_PROFILE_BUBBLE_H_
8 #include "base/basictypes.h"
10 class Browser;
11 class Profile;
13 namespace base {
14 class FilePath;
17 namespace user_prefs {
18 class PrefRegistrySyncable;
21 // This class will try to detect if the profile is on a network share and if
22 // this is the case notify the user with an info bubble.
23 class NetworkProfileBubble {
24 public:
25 enum MetricNetworkedProfileCheck {
26 // Check was suppressed by command line flag.
27 METRIC_CHECK_SUPPRESSED,
28 // WTSQuerySessionInformation call failed.
29 METRIC_CHECK_FAILED,
30 // File access in profile dir failed.
31 METRIC_CHECK_IO_FAILED,
33 // Profile on a network share detected.
34 METRIC_PROFILE_ON_NETWORK,
35 // Profile not on a network share detected.
36 METRIC_PROFILE_NOT_ON_NETWORK,
38 // Check was suppressed because of remote session.
39 METRIC_REMOTE_SESSION,
41 // User has clicked learn more on the notification bubble.
42 METRIC_LEARN_MORE_CLICKED,
43 // User has clicked OK on the notification bubble.
44 METRIC_ACKNOWLEDGED,
46 METRIC_NETWORKED_PROFILE_CHECK_SIZE // Must be the last.
49 // Returns true if the check for network located profile should be done. This
50 // test is only performed up to |kMaxWarnings| times in a row and then
51 // repeated after a period of silence that lasts |kSilenceDurationDays| days.
52 static bool ShouldCheckNetworkProfile(Profile* profile);
54 // Verifies that the profile folder is not located on a network share, and if
55 // it is shows the warning bubble to the user.
56 static void CheckNetworkProfile(const base::FilePath& profile_folder);
58 // Shows the notification bubble using the provided |browser|.
59 static void ShowNotification(Browser* browser);
61 static void SetNotificationShown(bool shown);
63 // Register the pref that controls whether the bubble should be shown anymore.
64 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
66 // Helper function wrapping the UMA_HISTOGRAM_ENUMERATION macro.
67 static void RecordUmaEvent(MetricNetworkedProfileCheck event);
69 private:
70 // This function creates the notification bubble, attaches it to the
71 // |anchor| View and then shows it to the user.
72 static void NotifyNetworkProfileDetected();
74 // Set to true once the notification check has been performed to avoid showing
75 // the notification more than once per browser run.
76 // This flag is not thread-safe and should only be accessed on the UI thread!
77 static bool notification_shown_;
79 DISALLOW_IMPLICIT_CONSTRUCTORS(NetworkProfileBubble);
82 #endif // CHROME_BROWSER_UI_NETWORK_PROFILE_BUBBLE_H_