| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_UI_NETWORK_PROFILE_BUBBLE_H_ | 5 #ifndef CHROME_BROWSER_UI_NETWORK_PROFILE_BUBBLE_H_ |
| 6 #define CHROME_BROWSER_UI_NETWORK_PROFILE_BUBBLE_H_ | 6 #define CHROME_BROWSER_UI_NETWORK_PROFILE_BUBBLE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 | 9 |
| 10 class Browser; | 10 class Browser; |
| 11 class FilePath; | |
| 12 class PrefServiceSyncable; | 11 class PrefServiceSyncable; |
| 13 class Profile; | 12 class Profile; |
| 14 | 13 |
| 14 namespace base { |
| 15 class FilePath; |
| 16 } |
| 17 |
| 15 // This class will try to detect if the profile is on a network share and if | 18 // This class will try to detect if the profile is on a network share and if |
| 16 // this is the case notify the user with an info bubble. | 19 // this is the case notify the user with an info bubble. |
| 17 class NetworkProfileBubble { | 20 class NetworkProfileBubble { |
| 18 public: | 21 public: |
| 19 enum MetricNetworkedProfileCheck { | 22 enum MetricNetworkedProfileCheck { |
| 20 // Check was suppressed by command line flag. | 23 // Check was suppressed by command line flag. |
| 21 METRIC_CHECK_SUPPRESSED, | 24 METRIC_CHECK_SUPPRESSED, |
| 22 // WTSQuerySessionInformation call failed. | 25 // WTSQuerySessionInformation call failed. |
| 23 METRIC_CHECK_FAILED, | 26 METRIC_CHECK_FAILED, |
| 24 // File access in profile dir failed. | 27 // File access in profile dir failed. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 40 METRIC_NETWORKED_PROFILE_CHECK_SIZE // Must be the last. | 43 METRIC_NETWORKED_PROFILE_CHECK_SIZE // Must be the last. |
| 41 }; | 44 }; |
| 42 | 45 |
| 43 // Returns true if the check for network located profile should be done. This | 46 // Returns true if the check for network located profile should be done. This |
| 44 // test is only performed up to |kMaxWarnings| times in a row and then | 47 // test is only performed up to |kMaxWarnings| times in a row and then |
| 45 // repeated after a period of silence that lasts |kSilenceDurationDays| days. | 48 // repeated after a period of silence that lasts |kSilenceDurationDays| days. |
| 46 static bool ShouldCheckNetworkProfile(Profile* profile); | 49 static bool ShouldCheckNetworkProfile(Profile* profile); |
| 47 | 50 |
| 48 // Verifies that the profile folder is not located on a network share, and if | 51 // Verifies that the profile folder is not located on a network share, and if |
| 49 // it is shows the warning bubble to the user. | 52 // it is shows the warning bubble to the user. |
| 50 static void CheckNetworkProfile(const FilePath& profile_folder); | 53 static void CheckNetworkProfile(const base::FilePath& profile_folder); |
| 51 | 54 |
| 52 // Shows the notification bubble using the provided |browser|. | 55 // Shows the notification bubble using the provided |browser|. |
| 53 static void ShowNotification(Browser* browser); | 56 static void ShowNotification(Browser* browser); |
| 54 | 57 |
| 55 static void SetNotificationShown(bool shown); | 58 static void SetNotificationShown(bool shown); |
| 56 | 59 |
| 57 // Register the pref that controls whether the bubble should be shown anymore. | 60 // Register the pref that controls whether the bubble should be shown anymore. |
| 58 static void RegisterUserPrefs(PrefServiceSyncable* prefs); | 61 static void RegisterUserPrefs(PrefServiceSyncable* prefs); |
| 59 | 62 |
| 60 // Helper function wrapping the UMA_HISTOGRAM_ENUMERATION macro. | 63 // Helper function wrapping the UMA_HISTOGRAM_ENUMERATION macro. |
| 61 static void RecordUmaEvent(MetricNetworkedProfileCheck event); | 64 static void RecordUmaEvent(MetricNetworkedProfileCheck event); |
| 62 | 65 |
| 63 private: | 66 private: |
| 64 // This function creates the notification bubble, attaches it to the | 67 // This function creates the notification bubble, attaches it to the |
| 65 // |anchor| View and then shows it to the user. | 68 // |anchor| View and then shows it to the user. |
| 66 static void NotifyNetworkProfileDetected(); | 69 static void NotifyNetworkProfileDetected(); |
| 67 | 70 |
| 68 // Set to true once the notification check has been performed to avoid showing | 71 // Set to true once the notification check has been performed to avoid showing |
| 69 // the notification more than once per browser run. | 72 // the notification more than once per browser run. |
| 70 // This flag is not thread-safe and should only be accessed on the UI thread! | 73 // This flag is not thread-safe and should only be accessed on the UI thread! |
| 71 static bool notification_shown_; | 74 static bool notification_shown_; |
| 72 | 75 |
| 73 DISALLOW_IMPLICIT_CONSTRUCTORS(NetworkProfileBubble); | 76 DISALLOW_IMPLICIT_CONSTRUCTORS(NetworkProfileBubble); |
| 74 }; | 77 }; |
| 75 | 78 |
| 76 #endif // CHROME_BROWSER_UI_NETWORK_PROFILE_BUBBLE_H_ | 79 #endif // CHROME_BROWSER_UI_NETWORK_PROFILE_BUBBLE_H_ |
| OLD | NEW |