summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/generated_resources.grd22
-rw-r--r--chrome/browser/custom_handlers/protocol_handler_registry.cc15
-rw-r--r--chrome/browser/custom_handlers/protocol_handler_registry.h8
-rw-r--r--chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc17
-rw-r--r--chrome/browser/platform_util_chromeos.cc9
-rw-r--r--chrome/browser/profiles/profile_impl.cc20
-rw-r--r--chrome/browser/profiles/profile_impl.h3
7 files changed, 93 insertions, 1 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index f81ad62..39f87e5 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -11642,6 +11642,28 @@ Some features may be unavailable. Please check that the profile exists and you
</message>
</if>
+ <if expr="pp_ifdef('chromeos')">
+ <!-- The URL for the Google mailto service. -->
+ <message name="IDS_GOOGLE_MAILTO_HANDLER_URL">
+ https:////mail.google.com//mail//?extsrc=mailto&amp;url=%s
+ </message>
+
+ <!-- The name for the Google mailto service. -->
+ <message name="IDS_GOOGLE_MAILTO_HANDLER_NAME">
+ Google.com Mail
+ </message>
+
+ <!-- The URL for the Google webcal service. -->
+ <message name="IDS_GOOGLE_WEBCAL_HANDLER_URL">
+ https:////www.google.com//calendar//render?cid=%s
+ </message>
+
+ <!-- The name for the Google webcal service. -->
+ <message name="IDS_GOOGLE_WEBCAL_HANDLER_NAME">
+ Google Calendar
+ </message>
+ </if>
+
<!-- Sync promo page chrome://signin -->
<message name="IDS_SYNC_PROMO_TAB_TITLE" desc="The title of the sync promo tab.">
Sign in
diff --git a/chrome/browser/custom_handlers/protocol_handler_registry.cc b/chrome/browser/custom_handlers/protocol_handler_registry.cc
index ab8753a..aee6ea0b 100644
--- a/chrome/browser/custom_handlers/protocol_handler_registry.cc
+++ b/chrome/browser/custom_handlers/protocol_handler_registry.cc
@@ -151,7 +151,8 @@ ProtocolHandlerRegistry::ProtocolHandlerRegistry(Profile* profile,
delegate_(delegate),
enabled_(true),
enabled_io_(enabled_),
- is_loading_(false) {
+ is_loading_(false),
+ is_loaded_(false) {
}
bool ProtocolHandlerRegistry::SilentlyHandleRegisterHandlerRequest(
@@ -247,6 +248,8 @@ bool ProtocolHandlerRegistry::IsDefault(
}
void ProtocolHandlerRegistry::Load() {
+ // Any further default additions to the table will get rejected from now on.
+ is_loaded_ = true;
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
is_loading_ = true;
PrefService* prefs = profile_->GetPrefs();
@@ -708,3 +711,13 @@ void ProtocolHandlerRegistry::IgnoreProtocolHandler(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
ignored_protocol_handlers_.push_back(handler);
}
+
+void ProtocolHandlerRegistry::AddDefaultHandler(
+ const ProtocolHandler& handler) {
+ // If called after the load command was issued this function will fail.
+ DCHECK(!is_loaded_);
+ RegisterProtocolHandler(handler);
+ SetDefault(handler);
+}
+
+
diff --git a/chrome/browser/custom_handlers/protocol_handler_registry.h b/chrome/browser/custom_handlers/protocol_handler_registry.h
index 508a44c..de90791 100644
--- a/chrome/browser/custom_handlers/protocol_handler_registry.h
+++ b/chrome/browser/custom_handlers/protocol_handler_registry.h
@@ -191,6 +191,10 @@ class ProtocolHandlerRegistry
bool enabled() const { return enabled_; }
+ // Add a predefined protocol handler. This has to be called before the first
+ // load command was issued, otherwise the command will be ignored.
+ void AddDefaultHandler(const ProtocolHandler& handler);
+
private:
friend class base::DeleteHelper<ProtocolHandlerRegistry>;
friend struct content::BrowserThread::DeleteOnThread<
@@ -280,6 +284,10 @@ class ProtocolHandlerRegistry
// Whether or not we are loading.
bool is_loading_;
+ // When the table gets loaded this flag will be set and any further calls to
+ // AddDefaultHandler will be rejected.
+ bool is_loaded_;
+
DefaultClientObserverList default_client_observers_;
// Copy of default_handlers_ that is only accessed on the IO thread.
diff --git a/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc b/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc
index f5afb11..65699f7 100644
--- a/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc
+++ b/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc
@@ -229,6 +229,16 @@ class ProtocolHandlerRegistryTest : public testing::Test {
registry_->Load();
}
+ void ReloadProtocolHandlerRegistryAndInstallDefaultHandler() {
+ delegate_ = new FakeDelegate();
+ registry_->Finalize();
+ registry_ = NULL;
+ registry_ = new ProtocolHandlerRegistry(profile(), delegate());
+ registry_->AddDefaultHandler(CreateProtocolHandler(
+ "test", GURL("http://test.com/%s"), "Test"));
+ registry_->Load();
+ }
+
virtual void SetUp() {
ui_message_loop_.reset(new MessageLoopForUI());
ui_thread_.reset(new content::TestBrowserThread(BrowserThread::UI,
@@ -796,3 +806,10 @@ TEST_F(ProtocolHandlerRegistryTest, TestIsSameOrigin) {
ASSERT_EQ(ph3.url().GetOrigin() == ph2.url().GetOrigin(),
ph3.IsSameOrigin(ph2));
}
+
+TEST_F(ProtocolHandlerRegistryTest, TestInstallDefaultHandler) {
+ ReloadProtocolHandlerRegistryAndInstallDefaultHandler();
+ std::vector<std::string> protocols;
+ registry()->GetRegisteredProtocols(&protocols);
+ ASSERT_EQ(static_cast<size_t>(1), protocols.size());
+}
diff --git a/chrome/browser/platform_util_chromeos.cc b/chrome/browser/platform_util_chromeos.cc
index eaebafd..12d0c78 100644
--- a/chrome/browser/platform_util_chromeos.cc
+++ b/chrome/browser/platform_util_chromeos.cc
@@ -55,6 +55,15 @@ void OpenItem(const FilePath& full_path) {
}
void OpenExternal(const GURL& url) {
+ // This code should be obsolete since we have default handlers in ChromeOS
+ // which should handle this. However - there are two things which make it
+ // necessary to keep it in:
+ // a.) The user might have deleted the default handler in this session.
+ // In this case we would need to have this in place.
+ // b.) There are several code paths which are not clear if they would call
+ // this function directly and which would therefore break (e.g.
+ // "Browser::EmailPageLocation" (to name only one).
+ // As such we should keep this code here.
if (url.SchemeIs("mailto")) {
std::string string_url = kGmailComposeUrl;
string_url.append(url.spec());
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 7e89356..c6f422b 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -83,6 +83,7 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/user_metrics.h"
#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#if defined(OS_WIN)
@@ -442,9 +443,28 @@ void ProfileImpl::InitRegisteredProtocolHandlers() {
return;
protocol_handler_registry_ = new ProtocolHandlerRegistry(this,
new ProtocolHandlerRegistry::Delegate());
+
+ // Install predefined protocol handlers.
+ InstallDefaultProtocolHandlers();
+
protocol_handler_registry_->Load();
}
+void ProfileImpl::InstallDefaultProtocolHandlers() {
+#if defined(OS_CHROMEOS)
+ protocol_handler_registry_->AddDefaultHandler(
+ ProtocolHandler::CreateProtocolHandler(
+ "mailto",
+ GURL(l10n_util::GetStringUTF8(IDS_GOOGLE_MAILTO_HANDLER_URL)),
+ l10n_util::GetStringUTF16(IDS_GOOGLE_MAILTO_HANDLER_NAME)));
+ protocol_handler_registry_->AddDefaultHandler(
+ ProtocolHandler::CreateProtocolHandler(
+ "webcal",
+ GURL(l10n_util::GetStringUTF8(IDS_GOOGLE_WEBCAL_HANDLER_URL)),
+ l10n_util::GetStringUTF16(IDS_GOOGLE_WEBCAL_HANDLER_NAME)));
+#endif
+}
+
FilePath ProfileImpl::last_selected_directory() {
return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory);
}
diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h
index 7551050..93fd178 100644
--- a/chrome/browser/profiles/profile_impl.h
+++ b/chrome/browser/profiles/profile_impl.h
@@ -148,6 +148,9 @@ class ProfileImpl : public Profile,
void InitHostZoomMap();
+ // The installation of any pre-defined protocol handlers.
+ void InstallDefaultProtocolHandlers();
+
// Does final prefs initialization and calls Init().
void OnPrefsLoaded(bool success);