summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-02 02:28:12 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-02 02:28:12 +0000
commitf99c87d5c20b9ece5b77fe0230f9c10bd2f48dcf (patch)
treefe41e293ce8e9c804626637ea4d09506a290d299 /chrome/browser
parentaa8f1cc58dcac3fe2b5688dabdd45d52c240721a (diff)
downloadchromium_src-f99c87d5c20b9ece5b77fe0230f9c10bd2f48dcf.zip
chromium_src-f99c87d5c20b9ece5b77fe0230f9c10bd2f48dcf.tar.gz
chromium_src-f99c87d5c20b9ece5b77fe0230f9c10bd2f48dcf.tar.bz2
Add PluginInstaller to encapsulate information about a missing plug-in, and add a separate help URL for each plug-in.
TBR=arv@chromium.org BUG=62079,102987 TEST=none Review URL: http://codereview.chromium.org/8664027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112610 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/plugin_finder.cc31
-rw-r--r--chrome/browser/plugin_finder.h12
-rw-r--r--chrome/browser/plugin_installer.cc20
-rw-r--r--chrome/browser/plugin_installer.h48
-rw-r--r--chrome/browser/plugin_observer.cc23
-rw-r--r--chrome/browser/plugin_observer.h8
-rw-r--r--chrome/browser/resources/plugins_mac.json8
-rw-r--r--chrome/browser/resources/plugins_win.json8
8 files changed, 125 insertions, 33 deletions
diff --git a/chrome/browser/plugin_finder.cc b/chrome/browser/plugin_finder.cc
index eee7757..59777de 100644
--- a/chrome/browser/plugin_finder.cc
+++ b/chrome/browser/plugin_finder.cc
@@ -7,8 +7,10 @@
#include "base/bind.h"
#include "base/json/json_reader.h"
#include "base/message_loop.h"
+#include "base/stl_util.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/plugin_installer.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
@@ -47,6 +49,7 @@ PluginFinder::PluginFinder() {
}
PluginFinder::~PluginFinder() {
+ STLDeleteValues(&installers_);
}
void PluginFinder::FindPlugin(
@@ -81,17 +84,29 @@ void PluginFinder::FindPlugin(
success = (*mime_type_it)->GetAsString(&mime_type_str);
DCHECK(success);
if (mime_type_str == mime_type) {
- std::string url;
- success = plugin->GetString("url", &url);
+ std::string identifier;
+ success = plugin->GetString("identifier", &identifier);
DCHECK(success);
- string16 name;
- success = plugin->GetString("name", &name);
- DCHECK(success);
- bool display_url = false;
- plugin->GetBoolean("displayurl", &display_url);
+ PluginInstaller* installer = installers_[identifier];
+ if (!installer) {
+ std::string url;
+ success = plugin->GetString("url", &url);
+ DCHECK(success);
+ std::string help_url;
+ plugin->GetString("help_url", &help_url);
+ string16 name;
+ success = plugin->GetString("name", &name);
+ DCHECK(success);
+ bool display_url = false;
+ plugin->GetBoolean("displayurl", &display_url);
+ installer = new PluginInstaller(identifier,
+ GURL(url), GURL(help_url), name,
+ display_url);
+ installers_[identifier] = installer;
+ }
MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(found_callback, GURL(url), name, display_url));
+ base::Bind(found_callback, installer));
return;
}
}
diff --git a/chrome/browser/plugin_finder.h b/chrome/browser/plugin_finder.h
index e9b18d0..3359edb 100644
--- a/chrome/browser/plugin_finder.h
+++ b/chrome/browser/plugin_finder.h
@@ -6,8 +6,8 @@
#define CHROME_BROWSER_PLUGIN_FINDER_H_
#pragma once
+#include <map>
#include <string>
-#include <vector>
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
@@ -19,16 +19,11 @@ class ListValue;
}
class GURL;
+class PluginInstaller;
class PluginFinder {
public:
- // If |display_url| is false, |plugin_url| is the URL of the download page for
- // the plug-in, which should be opened in a new tab. If it is true,
- // |plugin_url| is the URL of the plug-in installer binary, which can be
- // directly downloaded.
- typedef base::Callback<void(GURL /* plugin_url */,
- string16 /* name */,
- bool /* display_url */)> FindPluginCallback;
+ typedef base::Callback<void(PluginInstaller*)> FindPluginCallback;
static PluginFinder* GetInstance();
@@ -47,6 +42,7 @@ class PluginFinder {
~PluginFinder();
scoped_ptr<base::ListValue> plugin_list_;
+ std::map<std::string, PluginInstaller*> installers_;
DISALLOW_COPY_AND_ASSIGN(PluginFinder);
};
diff --git a/chrome/browser/plugin_installer.cc b/chrome/browser/plugin_installer.cc
new file mode 100644
index 0000000..00d6c49
--- /dev/null
+++ b/chrome/browser/plugin_installer.cc
@@ -0,0 +1,20 @@
+// Copyright (c) 2011 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/plugin_installer.h"
+
+PluginInstaller::~PluginInstaller() {
+}
+
+PluginInstaller::PluginInstaller(const std::string& identifier,
+ const GURL& plugin_url,
+ const GURL& help_url,
+ const string16& name,
+ bool url_for_display)
+ : identifier_(identifier),
+ plugin_url_(plugin_url),
+ help_url_(help_url),
+ name_(name),
+ url_for_display_(url_for_display) {
+}
diff --git a/chrome/browser/plugin_installer.h b/chrome/browser/plugin_installer.h
new file mode 100644
index 0000000..69f4a58
--- /dev/null
+++ b/chrome/browser/plugin_installer.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2011 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_PLUGIN_INSTALLER_H_
+#define CHROME_BROWSER_PLUGIN_INSTALLER_H_
+#pragma once
+
+#include "base/string16.h"
+#include "googleurl/src/gurl.h"
+
+class PluginInstaller {
+ public:
+ PluginInstaller(const std::string& identifier,
+ const GURL& plugin_url,
+ const GURL& help_url,
+ const string16& name,
+ bool url_for_display);
+ ~PluginInstaller();
+
+ // Unique identifier for the plug-in. Should be kept in sync with the
+ // identifier in plugin_list.cc.
+ const std::string& identifier() const { return identifier_; }
+
+ // Human-readable name of the plug-in.
+ const string16& name() const { return name_; }
+
+ // If |url_for_display| is false, |plugin_url| is the URL of the download page
+ // for the plug-in, which should be opened in a new tab. If it is true,
+ // |plugin_url| is the URL of the plug-in installer binary, which can be
+ // directly downloaded.
+ bool url_for_display() const { return url_for_display_; }
+ const GURL& plugin_url() const { return plugin_url_; }
+
+ // URL to open when the user clicks on the "Problems installing?" link.
+ const GURL& help_url() const { return help_url_; }
+
+ private:
+ std::string identifier_;
+ GURL plugin_url_;
+ GURL help_url_;
+ string16 name_;
+ bool url_for_display_;
+
+ DISALLOW_COPY_AND_ASSIGN(PluginInstaller);
+};
+
+#endif // CHROME_BROWSER_PLUGIN_INSTALLER_H_
diff --git a/chrome/browser/plugin_observer.cc b/chrome/browser/plugin_observer.cc
index 73d9a75..62562a4 100644
--- a/chrome/browser/plugin_observer.cc
+++ b/chrome/browser/plugin_observer.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/infobars/infobar_tab_helper.h"
#include "chrome/browser/plugin_finder.h"
+#include "chrome/browser/plugin_installer.h"
#include "chrome/browser/plugin_installer_infobar_delegate.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
@@ -19,6 +20,7 @@
#include "chrome/common/url_constants.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/tab_contents.h"
+#include "content/browser/tab_contents/tab_contents_delegate.h"
#include "content/browser/user_metrics.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources_standard.h"
@@ -330,17 +332,15 @@ void PluginObserver::OnFindMissingPlugin(int placeholder_id,
void PluginObserver::FoundMissingPlugin(int placeholder_id,
const std::string& mime_type,
- const GURL& url,
- const string16& name,
- bool display_url) {
- Send(new ChromeViewMsg_FoundMissingPlugin(placeholder_id, name));
+ PluginInstaller* installer) {
+ Send(new ChromeViewMsg_FoundMissingPlugin(placeholder_id, installer->name()));
InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper();
infobar_helper->AddInfoBar(new PluginInstallerInfoBarDelegate(
infobar_helper,
- name,
- GURL(), // TODO(bauerb): Get URL from JSON file.
+ installer->name(),
+ installer->help_url(),
base::Bind(&PluginObserver::InstallMissingPlugin,
- weak_ptr_factory_.GetWeakPtr(), url, display_url)));
+ weak_ptr_factory_.GetWeakPtr(), installer)));
}
void PluginObserver::DidNotFindMissingPlugin(int placeholder_id,
@@ -348,11 +348,10 @@ void PluginObserver::DidNotFindMissingPlugin(int placeholder_id,
Send(new ChromeViewMsg_DidNotFindMissingPlugin(placeholder_id));
}
-void PluginObserver::InstallMissingPlugin(const GURL& url,
- bool display_url) {
- if (display_url) {
- tab_contents()->OpenURL(url, tab_contents()->GetURL(), NEW_FOREGROUND_TAB,
- content::PAGE_TRANSITION_TYPED);
+void PluginObserver::InstallMissingPlugin(PluginInstaller* installer) {
+ if (installer->url_for_display()) {
+ tab_contents()->OpenURL(installer->plugin_url(), tab_contents()->GetURL(),
+ NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_TYPED);
} else {
NOTIMPLEMENTED();
}
diff --git a/chrome/browser/plugin_observer.h b/chrome/browser/plugin_observer.h
index a8a2706..2612e52 100644
--- a/chrome/browser/plugin_observer.h
+++ b/chrome/browser/plugin_observer.h
@@ -11,6 +11,7 @@
class GURL;
class InfoBarDelegate;
+class PluginInstaller;
class TabContentsWrapper;
class PluginObserver : public TabContentsObserver {
@@ -27,17 +28,14 @@ class PluginObserver : public TabContentsObserver {
void FoundMissingPlugin(int placeholder_id,
const std::string& mime_type,
- const GURL& url,
- const string16& name,
- bool display_url);
+ PluginInstaller* installer);
void DidNotFindMissingPlugin(int placeholder_id,
const std::string& mime_type);
- void InstallMissingPlugin(const GURL& url, bool display_url);
+ void InstallMissingPlugin(PluginInstaller* installer);
base::WeakPtrFactory<PluginObserver> weak_ptr_factory_;
TabContentsWrapper* tab_contents_;
- scoped_ptr<InfoBarDelegate> plugin_installer_; // Lazily created.
DISALLOW_COPY_AND_ASSIGN(PluginObserver);
};
diff --git a/chrome/browser/resources/plugins_mac.json b/chrome/browser/resources/plugins_mac.json
index 1f0a456..09c1e92 100644
--- a/chrome/browser/resources/plugins_mac.json
+++ b/chrome/browser/resources/plugins_mac.json
@@ -36,6 +36,7 @@
],
"lang": "en-US",
"name": "Java(TM)",
+ "identifier": "java-runtime-environment",
"url": "http://java.com/en/download/apple_manual.jsp",
"displayurl": true
},
@@ -48,6 +49,7 @@
],
"lang": "en-US",
"name": "RealPlayer",
+ "identifier": "realplayer",
"url": "http://www.real.com/realplayer/download",
"displayurl": true
},
@@ -58,6 +60,7 @@
],
"lang": "en-US",
"name": "Adobe Flash Player",
+ "identifier": "adobe-flash-player",
"url": "http://get.adobe.com/flashplayer/",
"displayurl": true
},
@@ -67,6 +70,7 @@
],
"lang": "en-US",
"name": "Adobe Shockwave Player",
+ "identifier": "shockwave",
"url": "http://www.adobe.com/shockwave/download/",
"displayurl": true
},
@@ -81,6 +85,7 @@
],
"lang": "en-US",
"name": "Adobe Reader",
+ "identifier": "adobe-reader",
"url": "http://get.adobe.com/reader/",
"displayurl": true
},
@@ -138,6 +143,7 @@
],
"lang": "en-US",
"name": "QuickTime Player",
+ "identifier": "apple-quicktime",
"url": "http://www.apple.com/quicktime/download/",
"displayurl": true
},
@@ -156,6 +162,7 @@
],
"lang": "en-US",
"name": "Flip4Mac",
+ "identifier": "flip4mac",
"url": "http://www.telestream.net/flip4mac-wmv/overview.htm",
"displayurl": true
},
@@ -166,6 +173,7 @@
],
"lang": "en-US",
"name": "DivX Web Player",
+ "identifier": "divx-player",
"url": "http://www.divx.com/en/downloads/divx/mac",
"displayurl": true
}
diff --git a/chrome/browser/resources/plugins_win.json b/chrome/browser/resources/plugins_win.json
index 0549c6c..9af9b29 100644
--- a/chrome/browser/resources/plugins_win.json
+++ b/chrome/browser/resources/plugins_win.json
@@ -36,6 +36,7 @@
],
"lang": "en-US",
"name": "Java(TM)",
+ "identifier": "java-runtime-environment",
"url": "http://java.com/download",
"displayurl": true
},
@@ -48,6 +49,7 @@
],
"lang": "en-US",
"name": "RealPlayer",
+ "identifier": "realplayer",
"url": "http://forms.real.com/real/realone/download.html?type=rpsp_us"
},
{
@@ -57,6 +59,7 @@
],
"lang": "en-US",
"name": "Adobe Flash Player",
+ "identifier": "adobe-flash-player",
"url": "http://fpdownload.adobe.com/get/flashplayer/current/install_flash_player.exe"
},
{
@@ -65,6 +68,7 @@
],
"lang": "en-US",
"name": "Adobe Shockwave Player",
+ "identifier": "shockwave",
"url": "http://fpdownload.macromedia.com/get/shockwave/default/english/win95nt/latest/Shockwave_Installer_Slim.exe"
},
{
@@ -78,6 +82,7 @@
],
"lang": "en-US",
"name": "Adobe Reader",
+ "identifier": "adobe-reader",
"url": "http://ardownload.adobe.com/pub/adobe/reader/win/9.x/9.1/enu/AdbeRdr910_en_US.exe"
},
{
@@ -134,6 +139,7 @@
],
"lang": "en-US",
"name": "QuickTime Player",
+ "identifier": "apple-quicktime",
"url": "http://appldnld.apple.com.edgesuite.net/content.info.apple.com/QuickTime/061-6118.20090601.Pq3V9/QuickTimeInstaller.exe"
},
{
@@ -151,6 +157,7 @@
],
"lang": "en-US",
"name": "Windows Media Player",
+ "identifier": "windows-media-player",
"url": "http://port25.technet.com/videos/downloads/wmpfirefoxplugin.exe"
},
{
@@ -160,6 +167,7 @@
],
"lang": "en-US",
"name": "DivX Web Player",
+ "identifier": "divx-player",
"url": "http://download.divx.com/player/divxdotcom/DivXWebPlayerInstaller.exe"
}
]