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/web_resource/web_resource_service.h" | 5 #include "chrome/browser/web_resource/web_resource_service.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "base/time.h" | 11 #include "base/time.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/browser_thread.h" | 15 #include "chrome/browser/browser_thread.h" |
16 #include "chrome/browser/extensions/extensions_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/sync/sync_ui_util.h" | 18 #include "chrome/browser/sync/sync_ui_util.h" |
19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
21 #include "chrome/common/net/url_fetcher.h" | 21 #include "chrome/common/net/url_fetcher.h" |
22 #include "chrome/common/notification_service.h" | 22 #include "chrome/common/notification_service.h" |
23 #include "chrome/common/notification_type.h" | 23 #include "chrome/common/notification_type.h" |
24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
25 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
26 #include "net/base/load_flags.h" | 26 #include "net/base/load_flags.h" |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 | 498 |
499 namespace WebResourceServiceUtil { | 499 namespace WebResourceServiceUtil { |
500 | 500 |
501 bool CanShowPromo(Profile* profile) { | 501 bool CanShowPromo(Profile* profile) { |
502 bool promo_closed = false; | 502 bool promo_closed = false; |
503 PrefService* prefs = profile->GetPrefs(); | 503 PrefService* prefs = profile->GetPrefs(); |
504 if (prefs->HasPrefPath(prefs::kNTPPromoClosed)) | 504 if (prefs->HasPrefPath(prefs::kNTPPromoClosed)) |
505 promo_closed = prefs->GetBoolean(prefs::kNTPPromoClosed); | 505 promo_closed = prefs->GetBoolean(prefs::kNTPPromoClosed); |
506 | 506 |
507 bool has_extensions = false; | 507 bool has_extensions = false; |
508 ExtensionsService* extensions_service = profile->GetExtensionsService(); | 508 ExtensionService* extensions_service = profile->GetExtensionService(); |
509 if (extensions_service) { | 509 if (extensions_service) { |
510 const ExtensionList* extensions = extensions_service->extensions(); | 510 const ExtensionList* extensions = extensions_service->extensions(); |
511 for (ExtensionList::const_iterator iter = extensions->begin(); | 511 for (ExtensionList::const_iterator iter = extensions->begin(); |
512 iter != extensions->end(); | 512 iter != extensions->end(); |
513 ++iter) { | 513 ++iter) { |
514 if ((*iter)->location() == Extension::INTERNAL) { | 514 if ((*iter)->location() == Extension::INTERNAL) { |
515 has_extensions = true; | 515 has_extensions = true; |
516 break; | 516 break; |
517 } | 517 } |
518 } | 518 } |
519 } | 519 } |
520 | 520 |
521 // Note that HasProfileSyncService() will be false for ChromeOS, so | 521 // Note that HasProfileSyncService() will be false for ChromeOS, so |
522 // promo_options will only be true if the user has an extension installed. | 522 // promo_options will only be true if the user has an extension installed. |
523 // See http://crosbug/10209 | 523 // See http://crosbug/10209 |
524 bool promo_options = | 524 bool promo_options = |
525 (profile->HasProfileSyncService() && | 525 (profile->HasProfileSyncService() && |
526 sync_ui_util::GetStatus( | 526 sync_ui_util::GetStatus( |
527 profile->GetProfileSyncService()) == sync_ui_util::SYNCED) || | 527 profile->GetProfileSyncService()) == sync_ui_util::SYNCED) || |
528 has_extensions; | 528 has_extensions; |
529 | 529 |
530 return !promo_closed && | 530 return !promo_closed && |
531 promo_options && | 531 promo_options && |
532 g_browser_process->GetApplicationLocale() == "en-US"; | 532 g_browser_process->GetApplicationLocale() == "en-US"; |
533 } | 533 } |
534 | 534 |
535 } // namespace WebResourceService | 535 } // namespace WebResourceService |
536 | 536 |
OLD | NEW |