OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/dom_ui/tips_handler.h" | 10 #include "chrome/browser/dom_ui/tips_handler.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 // These values hold the data for each web resource item. | 37 // These values hold the data for each web resource item. |
38 int current_tip_index; | 38 int current_tip_index; |
39 std::string current_tip; | 39 std::string current_tip; |
40 | 40 |
41 // If tips are not correct for our language, do not send. Wait for update. | 41 // If tips are not correct for our language, do not send. Wait for update. |
42 // We need to check here because the new tab page calls for tips before | 42 // We need to check here because the new tab page calls for tips before |
43 // the tip service starts up. | 43 // the tip service starts up. |
44 PrefService* current_prefs = dom_ui_->GetProfile()->GetPrefs(); | 44 PrefService* current_prefs = dom_ui_->GetProfile()->GetPrefs(); |
45 if (current_prefs->HasPrefPath(prefs::kNTPTipsServer)) { | 45 if (current_prefs->HasPrefPath(prefs::kNTPTipsServer)) { |
46 std::wstring server = current_prefs->GetString(prefs::kNTPTipsServer); | 46 std::wstring server = current_prefs->GetString(prefs::kNTPTipsServer); |
47 std::wstring tips_language = WebResourceService::GetWebResourceLanguage( | 47 std::wstring locale = |
48 current_prefs); | 48 ASCIIToWide(g_browser_process->GetApplicationLocale()); |
49 if (!EndsWith(server, tips_language, false)) { | 49 if (!EndsWith(server, locale, false)) { |
50 dom_ui_->CallJavascriptFunction(L"tips", list_value); | 50 dom_ui_->CallJavascriptFunction(L"tips", list_value); |
51 return; | 51 return; |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 if (tips_cache_ != NULL && tips_cache_->GetSize() != 0) { | 55 if (tips_cache_ != NULL && tips_cache_->GetSize() != 0) { |
56 if (tips_cache_->GetInteger( | 56 if (tips_cache_->GetInteger( |
57 WebResourceService::kCurrentTipPrefName, ¤t_tip_index) && | 57 WebResourceService::kCurrentTipPrefName, ¤t_tip_index) && |
58 tips_cache_->GetList( | 58 tips_cache_->GetList( |
59 WebResourceService::kTipCachePrefName, &wr_list) && | 59 WebResourceService::kTipCachePrefName, &wr_list) && |
(...skipping 19 matching lines...) Expand all Loading... |
79 prefs->RegisterDictionaryPref(prefs::kNTPTipsCache); | 79 prefs->RegisterDictionaryPref(prefs::kNTPTipsCache); |
80 prefs->RegisterStringPref(prefs::kNTPTipsServer, | 80 prefs->RegisterStringPref(prefs::kNTPTipsServer, |
81 WebResourceService::kDefaultResourceServer); | 81 WebResourceService::kDefaultResourceServer); |
82 } | 82 } |
83 | 83 |
84 bool TipsHandler::IsValidURL(const std::wstring& url_string) { | 84 bool TipsHandler::IsValidURL(const std::wstring& url_string) { |
85 GURL url(WideToUTF8(url_string)); | 85 GURL url(WideToUTF8(url_string)); |
86 return !url.is_empty() && (url.SchemeIs(chrome::kHttpScheme) || | 86 return !url.is_empty() && (url.SchemeIs(chrome::kHttpScheme) || |
87 url.SchemeIs(chrome::kHttpsScheme)); | 87 url.SchemeIs(chrome::kHttpsScheme)); |
88 } | 88 } |
OLD | NEW |