OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/notifications/notifications_prefs_cache.h" | 5 #include "chrome/browser/notifications/notifications_prefs_cache.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/chrome_thread.h" | 9 #include "chrome/browser/chrome_thread.h" |
10 #include "chrome/browser/pref_service.h" | 10 #include "chrome/browser/pref_service.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 void NotificationsPrefsCache::SetCacheDefaultContentSetting( | 48 void NotificationsPrefsCache::SetCacheDefaultContentSetting( |
49 ContentSetting setting) { | 49 ContentSetting setting) { |
50 default_content_setting_ = setting; | 50 default_content_setting_ = setting; |
51 } | 51 } |
52 | 52 |
53 // static | 53 // static |
54 void NotificationsPrefsCache::ListValueToGurlVector( | 54 void NotificationsPrefsCache::ListValueToGurlVector( |
55 const ListValue& origin_list, | 55 const ListValue& origin_list, |
56 std::vector<GURL>* origin_vector) { | 56 std::vector<GURL>* origin_vector) { |
57 ListValue::const_iterator i; | 57 ListValue::const_iterator i; |
58 std::wstring origin; | 58 std::string origin; |
59 for (i = origin_list.begin(); i != origin_list.end(); ++i) { | 59 for (i = origin_list.begin(); i != origin_list.end(); ++i) { |
60 (*i)->GetAsString(&origin); | 60 (*i)->GetAsString(&origin); |
61 origin_vector->push_back(GURL(WideToUTF8(origin))); | 61 origin_vector->push_back(GURL(origin)); |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 int NotificationsPrefsCache::HasPermission(const GURL& origin) { | 65 int NotificationsPrefsCache::HasPermission(const GURL& origin) { |
66 if (IsOriginAllowed(origin)) | 66 if (IsOriginAllowed(origin)) |
67 return WebKit::WebNotificationPresenter::PermissionAllowed; | 67 return WebKit::WebNotificationPresenter::PermissionAllowed; |
68 if (IsOriginDenied(origin)) | 68 if (IsOriginDenied(origin)) |
69 return WebKit::WebNotificationPresenter::PermissionDenied; | 69 return WebKit::WebNotificationPresenter::PermissionDenied; |
70 switch (default_content_setting_) { | 70 switch (default_content_setting_) { |
71 case CONTENT_SETTING_ALLOW: | 71 case CONTENT_SETTING_ALLOW: |
(...skipping 19 matching lines...) Expand all Loading... |
91 return denied_origins_.find(origin) != denied_origins_.end(); | 91 return denied_origins_.find(origin) != denied_origins_.end(); |
92 } | 92 } |
93 | 93 |
94 void NotificationsPrefsCache::CheckThreadAccess() { | 94 void NotificationsPrefsCache::CheckThreadAccess() { |
95 if (is_initialized_) { | 95 if (is_initialized_) { |
96 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 96 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
97 } else { | 97 } else { |
98 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 98 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
99 } | 99 } |
100 } | 100 } |
OLD | NEW |