diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-16 23:59:55 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-16 23:59:55 +0000 |
commit | 0ca1ccdea35a265e21b30ec6e5c5b002d5f5afc3 (patch) | |
tree | 5e8e3a70c6580f4045683987659d36f8b2144892 | |
parent | 6d4c082ebfe5d2f243098a6be88866122ba540d9 (diff) | |
download | chromium_src-0ca1ccdea35a265e21b30ec6e5c5b002d5f5afc3.zip chromium_src-0ca1ccdea35a265e21b30ec6e5c5b002d5f5afc3.tar.gz chromium_src-0ca1ccdea35a265e21b30ec6e5c5b002d5f5afc3.tar.bz2 |
Revert "Windows: Warn about outdated plugins."
This reverts commit r26409.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26420 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/generated_resources.grd | 4 | ||||
-rw-r--r-- | chrome/browser/outdated_plugins.cc | 214 | ||||
-rw-r--r-- | chrome/browser/outdated_plugins.h | 27 | ||||
-rw-r--r-- | chrome/browser/outdated_plugins_unittest.cc | 44 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_message_filter.cc | 5 | ||||
-rw-r--r-- | chrome/chrome.gyp | 3 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 4 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 2 |
8 files changed, 1 insertions, 302 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 6df2aef..6aad21b 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -5034,10 +5034,6 @@ Keep your key file in a safe place. You will need it to create new versions of y </message> </if> - <message name="IDS_OUTDATED_PLUGIN" desc="This message is shown to the user when we detect that one of their plugins is out of date and should be upgraded (i.e. because of known security issues etc)"> - Your <ph name="PLUGIN_NAME">$1<ex>Shockwave Flash</ex></ph> plugin is out of date. You should update it immediately! - </message> - <!-- Chrome OS Strings --> <if expr="pp_ifdef('chromeos')"> <message name="IDS_OPTIONS_SETTINGS_SECTION_TITLE_NETWORK"> diff --git a/chrome/browser/outdated_plugins.cc b/chrome/browser/outdated_plugins.cc deleted file mode 100644 index abe44cf..0000000 --- a/chrome/browser/outdated_plugins.cc +++ /dev/null @@ -1,214 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/outdated_plugins.h" - -#include "app/l10n_util.h" -#include "base/logging.h" -#include "base/message_loop.h" -#include "base/string_util.h" -#include "chrome/browser/browser.h" -#include "chrome/browser/browser_list.h" -#include "chrome/browser/profile.h" -#include "chrome/browser/tab_contents/infobar_delegate.h" -#include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/common/pref_names.h" -#include "chrome/common/pref_service.h" -#include "grit/generated_resources.h" -#include "webkit/glue/webplugininfo.h" - -// A VersionPredicate function returns true iff the given version is considered -// to be out of date. -typedef bool (*VersionPredicate) (const std::wstring& version); - -// static -bool OutdatedPlugins::CheckFlashVersion(const std::wstring& version) { - // Returns true iff the given Flash version should be considered a security - // risk. - - // Latest security advisory: - // http://www.adobe.com/support/security/bulletins/apsb09-10.html - // suggests that versions < v9.0.246.0 and v10.0.32.18 are insecure. - - // The number of parts in the version number - static const unsigned kExpectedNumParts = 4; - - std::vector<std::wstring> version_parts; - SplitString(version, L'.', &version_parts); - if (version_parts.size() != kExpectedNumParts) - return false; // can't parse version - - for (unsigned i = 0; i < kExpectedNumParts; ++i) { - for (size_t j = 0; j < version_parts[i].size(); ++j) { - if (!IsAsciiDigit(version_parts[i][j])) - return false; // parse failure - } - } - - unsigned version_numbers[kExpectedNumParts]; - for (unsigned i = 0; i < kExpectedNumParts; ++i) - version_numbers[i] = StringToInt(WideToASCII(version_parts[i])); - - if (version_numbers[0] < 9) { - return true; // versions before 9 should be updated - } else if (version_numbers[0] == 9) { - if (version_numbers[1] == 0 && - version_numbers[2] < 246) { - return true; // versions before 9.0.246.0 are bad - } - - return false; - } else if (version_numbers[0] == 10) { - if (version_numbers[1] == 0) { - if (version_numbers[2] < 32) { - return true; // versions prior to 10.0.32.18 are bad - } else if (version_numbers[2] == 32) { - if (version_numbers[3] < 18) - return true; // versions prior to 10.0.32.18 are bad - } else { - return false; // assume good - } - } - - return false; // assume good - } else { - // version > 10 - we assume that it's good - return false; - } -} - -struct OutdatedPluginInfo { - const wchar_t name[16]; - const char update_url[34]; - VersionPredicate version_check_function; -} kOutdatedPlugins[] = { - { L"Shockwave Flash", "http://get.adobe.com/flashplayer/", - OutdatedPlugins::CheckFlashVersion }, - { L"", "", NULL }, -}; - -// static -void OutdatedPlugins::Check(const std::vector<WebPluginInfo>& plugins, - MessageLoop* ui_loop) { - static base::Time last_time_nagged; - static bool last_time_nagged_valid = false; - const base::Time current_time = base::Time::Now(); - - if (last_time_nagged_valid) { - static const base::TimeDelta one_day = base::TimeDelta::FromDays(1); - // Bug the user, at most, once a day. Obviously, this resets every time the - // user restarts Chrome. Because of that we also have a preferences entry - // but we have to be on the UI thread in order to check that. - if (last_time_nagged + one_day > current_time) - return; - } - - // This is a vector of indexes into |kOutdatedPlugins| for which we have - // found that the given plugin is out of date. - std::vector<unsigned>* outdated_plugins = NULL; - - for (std::vector<WebPluginInfo>::const_iterator - i = plugins.begin(); i != plugins.end(); ++i) { - for (size_t j = 0; kOutdatedPlugins[j].version_check_function; ++j) { - if (i->name == kOutdatedPlugins[j].name) { - if (kOutdatedPlugins[j].version_check_function(i->version)) { - if (!outdated_plugins) - outdated_plugins = new std::vector<unsigned>; - outdated_plugins->push_back(j); - } - } - } - } - - if (!outdated_plugins) - return; - - ui_loop->PostTask(FROM_HERE, - NewRunnableFunction(&OutdatedPlugins::PluginAlert, outdated_plugins)); - - last_time_nagged = current_time; - last_time_nagged_valid = true; -} - -class OutdatedPluginInfobarDelegate : public ConfirmInfoBarDelegate { - public: - OutdatedPluginInfobarDelegate(TabContents* tab_contents, - const std::wstring& plugin_name, - const char* update_url) - : ConfirmInfoBarDelegate(tab_contents), - plugin_name_(plugin_name), - update_url_(update_url) { - } - - virtual bool ShouldExpire( - const NavigationController::LoadCommittedDetails& details) const { - return false; - } - - virtual std::wstring GetMessageText() const { - return l10n_util::GetStringF(IDS_OUTDATED_PLUGIN, plugin_name_); - } - - virtual int GetButtons() const { - return BUTTON_OK; - } - - virtual std::wstring GetButtonLabel(InfoBarButton button) const { - DCHECK(button == BUTTON_OK); - return l10n_util::GetString(IDS_ABOUT_CHROME_UPDATE_CHECK); - } - - virtual bool Accept() { - Browser* browser = BrowserList::GetLastActive(); - if (!browser) - return true; - - browser->AddTabWithURL(GURL(update_url_), GURL(), PageTransition::LINK, - true, -1, false, NULL); - return true; - } - - private: - const std::wstring plugin_name_; - const char* update_url_; -}; - -// static -void OutdatedPlugins::PluginAlert(std::vector<unsigned>* in_outdated_plugins) { - scoped_ptr<std::vector<unsigned> > outdated_plugins(in_outdated_plugins); - - // Runs on the UI thread. - Browser* browser = BrowserList::GetLastActive(); - if (!browser) - return; - - TabContents *contents = browser->GetSelectedTabContents(); - if (!contents) - return; - - Profile* profile = browser->profile(); - if (profile) { - // Now that we are on the UI thread, we can check the preferences value for - // the last time that we nagged the user about plugins. - PrefService* prefs = profile->GetPrefs(); - if (!prefs->IsPrefRegistered(prefs::kLastTimeNaggedAboutPlugins)) - prefs->RegisterRealPref(prefs::kLastTimeNaggedAboutPlugins, 0.); - base::Time last_time_nagged = base::Time::FromDoubleT( - prefs->GetReal(prefs::kLastTimeNaggedAboutPlugins)); - base::Time current_time = base::Time::Now(); - static const base::TimeDelta one_day = base::TimeDelta::FromDays(1); - if (last_time_nagged + one_day > current_time) - return; - - prefs->SetReal(prefs::kLastTimeNaggedAboutPlugins, - current_time.ToDoubleT()); - } - - for (std::vector<unsigned>::const_iterator - i = outdated_plugins->begin(); i != outdated_plugins->end(); ++i) { - contents->AddInfoBar(new OutdatedPluginInfobarDelegate( - contents, kOutdatedPlugins[*i].name, - kOutdatedPlugins[*i].update_url)); - } -} diff --git a/chrome/browser/outdated_plugins.h b/chrome/browser/outdated_plugins.h deleted file mode 100644 index 68207c9..0000000 --- a/chrome/browser/outdated_plugins.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_OUTDATED_PLUGINS_H -#define CHROME_BROWSER_OUTDATED_PLUGINS_H - -#include <vector> - -struct WebPluginInfo; -class MessageLoop; - -class OutdatedPlugins { - public: - // Check a list of plugins and (asynchronously) throw up info bars for those - // which we consider to be outdated. - static void Check(const std::vector<WebPluginInfo>& plugins, - MessageLoop* ui_loop); - - // Version check functions: exported for testing - static bool CheckFlashVersion(const std::wstring& version); - - private: - static void PluginAlert(std::vector<unsigned>* outdated_plugins); -}; - -#endif // CHROME_BROWSER_OUTDATED_PLUGINS_H diff --git a/chrome/browser/outdated_plugins_unittest.cc b/chrome/browser/outdated_plugins_unittest.cc deleted file mode 100644 index 138a6f9..0000000 --- a/chrome/browser/outdated_plugins_unittest.cc +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/outdated_plugins.h" -#include "testing/gtest/include/gtest/gtest.h" - -class OutdatedPluginsTest : public testing::Test { -}; - -TEST_F(OutdatedPluginsTest, CheckFlashVersion) { - // In the case that we can't parse the version, assume that it's ok. - EXPECT_FALSE(OutdatedPlugins::CheckFlashVersion(L"bogus value")); - EXPECT_FALSE(OutdatedPlugins::CheckFlashVersion(L"1.2.3")); - EXPECT_FALSE(OutdatedPlugins::CheckFlashVersion(L"1x.2.3.4")); - EXPECT_FALSE(OutdatedPlugins::CheckFlashVersion(L"1.2x.3.4")); - EXPECT_FALSE(OutdatedPlugins::CheckFlashVersion(L"1.2.3x.4")); - EXPECT_FALSE(OutdatedPlugins::CheckFlashVersion(L"1.2.3.4x")); - EXPECT_FALSE(OutdatedPlugins::CheckFlashVersion(L"1.2.3.4.5")); - - // Very out of date versions should trigger - EXPECT_TRUE(OutdatedPlugins::CheckFlashVersion(L"1.2.3.4")); - EXPECT_TRUE(OutdatedPlugins::CheckFlashVersion(L"2.0.0.0")); - EXPECT_TRUE(OutdatedPlugins::CheckFlashVersion(L"8.0.0.0")); - - // Known bad versions - EXPECT_TRUE(OutdatedPlugins::CheckFlashVersion(L"9.0.159.0")); - EXPECT_TRUE(OutdatedPlugins::CheckFlashVersion(L"9.0.158.0")); - - EXPECT_TRUE(OutdatedPlugins::CheckFlashVersion(L"10.0.22.87")); - EXPECT_TRUE(OutdatedPlugins::CheckFlashVersion(L"10.0.21.87")); - EXPECT_TRUE(OutdatedPlugins::CheckFlashVersion(L"10.0.22.88")); - - // Known good versions - EXPECT_FALSE(OutdatedPlugins::CheckFlashVersion(L"10.0.32.18")); - EXPECT_FALSE(OutdatedPlugins::CheckFlashVersion(L"9.0.246.0")); - - // Version numbers from the future - EXPECT_FALSE(OutdatedPlugins::CheckFlashVersion(L"10.0.32.19")); - EXPECT_FALSE(OutdatedPlugins::CheckFlashVersion(L"10.0.33.0")); - EXPECT_FALSE(OutdatedPlugins::CheckFlashVersion(L"10.0.33.20")); - EXPECT_FALSE(OutdatedPlugins::CheckFlashVersion(L"10.1.31.0")); - EXPECT_FALSE(OutdatedPlugins::CheckFlashVersion(L"11.0.0.0")); -} diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index 08c86c9..4a5de3a 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -17,11 +17,10 @@ #include "chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/net/dns_global.h" -#include "chrome/browser/outdated_plugins.h" #include "chrome/browser/plugin_service.h" +#include "chrome/browser/profile.h" #include "chrome/browser/privacy_blacklist/blacklist.h" #include "chrome/browser/privacy_blacklist/blacklist_observer.h" -#include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/audio_renderer_host.h" #include "chrome/browser/renderer_host/browser_render_process_host.h" #include "chrome/browser/renderer_host/database_dispatcher_host.h" @@ -542,8 +541,6 @@ void ResourceMessageFilter::OnGetPluginsOnFileThread( std::vector<WebPluginInfo> plugins; NPAPI::PluginList::Singleton()->GetPlugins(refresh, &plugins); - OutdatedPlugins::Check(plugins, filter->ui_loop()); - ViewHostMsg_GetPlugins::WriteReplyParams(reply_msg, plugins); // Note, we want to get to the IO thread now, but the file thread outlives it // so we can't post a task to it directly as it might be in the middle of diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index d3a2c25..fb4f905 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -1608,8 +1608,6 @@ 'browser/options_util.cc', 'browser/options_util.h', 'browser/options_window.h', - 'browser/outdated_plugins.cc', - 'browser/outdated_plugins.h', 'browser/page_info_model.cc', 'browser/page_info_model.h', 'browser/page_state.cc', @@ -4191,7 +4189,6 @@ 'browser/net/test_url_fetcher_factory.h', 'browser/net/url_fetcher_unittest.cc', 'browser/net/url_fixer_upper_unittest.cc', - 'browser/outdated_plugins_unittest.cc', 'browser/password_manager/encryptor_unittest.cc', 'browser/password_manager/login_database_unittest.cc', 'browser/password_manager/password_form_manager_unittest.cc', diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 3d55aba..4ee3cb7 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -596,8 +596,4 @@ const wchar_t kSyncLastSyncedTime[] = L"sync.last_synced_time"; // Boolean specifying whether the user finished setting up sync. const wchar_t kSyncHasSetupCompleted[] = L"sync.has_setup_completed"; -// A double value giving the epoch time when we last nagged the user about -// outdated plugins. -const wchar_t kLastTimeNaggedAboutPlugins[] = L"plugins_last_nagged"; - } // namespace prefs diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 91b8572..18c7d45 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -226,8 +226,6 @@ extern const wchar_t kDevToolsSplitLocation[]; extern const wchar_t kSyncLastSyncedTime[]; extern const wchar_t kSyncHasSetupCompleted[]; - -extern const wchar_t kLastTimeNaggedAboutPlugins[]; } #endif // CHROME_COMMON_PREF_NAMES_H_ |