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

Side by Side Diff: chrome/browser/chromeos/locale_change_guard.h

Issue 382973002: ChromeOS: should not show "Language changed" notification for certain languages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests build. Created 6 years, 4 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/chromeos/locale_change_guard.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 #ifndef CHROME_BROWSER_CHROMEOS_LOCALE_CHANGE_GUARD_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOCALE_CHANGE_GUARD_H_
6 #define CHROME_BROWSER_CHROMEOS_LOCALE_CHANGE_GUARD_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOCALE_CHANGE_GUARD_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "ash/system/locale/locale_observer.h" 10 #include "ash/system/locale/locale_observer.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h"
12 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
16 #include "content/public/browser/notification_observer.h" 17 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
18 #include "content/public/browser/notification_types.h" 19 #include "content/public/browser/notification_types.h"
19 20
20 class Profile; 21 class Profile;
21 22
(...skipping 18 matching lines...) Expand all
40 virtual void RevertLocaleChange() OVERRIDE; 41 virtual void RevertLocaleChange() OVERRIDE;
41 42
42 // Called just before changing locale. 43 // Called just before changing locale.
43 void PrepareChangingLocale( 44 void PrepareChangingLocale(
44 const std::string& from_locale, const std::string& to_locale); 45 const std::string& from_locale, const std::string& to_locale);
45 46
46 // Called after login. 47 // Called after login.
47 void OnLogin(); 48 void OnLogin();
48 49
49 private: 50 private:
51 FRIEND_TEST_ALL_PREFIXES(LocaleChangeGuardTest,
52 ShowNotificationLocaleChanged);
53 FRIEND_TEST_ALL_PREFIXES(LocaleChangeGuardTest,
54 ShowNotificationLocaleChangedList);
55
50 void RevertLocaleChangeCallback(const base::ListValue* list); 56 void RevertLocaleChangeCallback(const base::ListValue* list);
51 void Check(); 57 void Check();
52 58
53 // content::NotificationObserver implementation. 59 // content::NotificationObserver implementation.
54 virtual void Observe(int type, 60 virtual void Observe(int type,
55 const content::NotificationSource& source, 61 const content::NotificationSource& source,
56 const content::NotificationDetails& details) OVERRIDE; 62 const content::NotificationDetails& details) OVERRIDE;
57 63
64 // Returns true if we should notify user about automatic locale change.
65 static bool ShouldShowLocaleChangeNotification(const std::string& from_locale,
66 const std::string& to_locale);
67
68 static const char* const* GetSkipShowNotificationLanguagesForTesting();
69 static size_t GetSkipShowNotificationLanguagesSizeForTesting();
70
58 std::string from_locale_; 71 std::string from_locale_;
59 std::string to_locale_; 72 std::string to_locale_;
60 Profile* profile_; 73 Profile* profile_;
61 bool reverted_; 74 bool reverted_;
62 bool session_started_; 75 bool session_started_;
63 bool main_frame_loaded_; 76 bool main_frame_loaded_;
64 content::NotificationRegistrar registrar_; 77 content::NotificationRegistrar registrar_;
65 78
66 // We want to show locale change notification in previous language however 79 // We want to show locale change notification in previous language however
67 // we cannot directly load strings for non-current locale. So we cache 80 // we cannot directly load strings for non-current locale. So we cache
68 // messages before locale change. 81 // messages before locale change.
69 base::string16 title_text_; 82 base::string16 title_text_;
70 base::string16 message_text_; 83 base::string16 message_text_;
71 base::string16 revert_link_text_; 84 base::string16 revert_link_text_;
72 }; 85 };
73 86
74 } // namespace chromeos 87 } // namespace chromeos
75 88
76 #endif // CHROME_BROWSER_CHROMEOS_LOCALE_CHANGE_GUARD_H_ 89 #endif // CHROME_BROWSER_CHROMEOS_LOCALE_CHANGE_GUARD_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/locale_change_guard.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698