Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1420)

Unified Diff: chrome/browser/external_protocol/external_protocol_handler.cc

Issue 7790021: Open external application dialog should not show for Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/external_protocol/external_protocol_handler.cc
diff --git a/chrome/browser/external_protocol/external_protocol_handler.cc b/chrome/browser/external_protocol/external_protocol_handler.cc
index 7388dd94b1337446098063e7f742f9f0a6c88aeb..415c1c4f902f93a98828e85a37a661408120cc6a 100644
--- a/chrome/browser/external_protocol/external_protocol_handler.cc
+++ b/chrome/browser/external_protocol/external_protocol_handler.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/platform_util.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
+#include "chrome/browser/shell_integration.h"
#include "chrome/common/pref_names.h"
#include "googleurl/src/gurl.h"
#include "net/base/escape.h"
@@ -125,6 +126,58 @@ void ExternalProtocolHandler::SetBlockState(const std::string& scheme,
}
}
+namespace {
tony 2011/08/30 17:51:26 Nit: I would move this to the top of the file (abo
+
+// When we are about to launch a URL with the default OS level application,
+// we check if that external application will be us. If it is we just ignore
+// the request.
+class ExternalDefaultProtocolObserver
+ : public ShellIntegration::DefaultWebClientObserver {
+ public:
+ ExternalDefaultProtocolObserver(const GURL& escaped_url,
+ int render_process_host_id,
+ int tab_contents_id,
+ bool prompt_user)
+ : escaped_url_(escaped_url),
+ render_process_host_id_(render_process_host_id),
+ tab_contents_id_(tab_contents_id),
+ prompt_user_(prompt_user) {}
+
+ virtual void SetDefaultWebClientUIState(
+ ShellIntegration::DefaultWebClientUIState state) OVERRIDE {
+
tony 2011/08/30 17:51:26 Can we DCHECK that we're on the right thread here?
+ // If we are still working out if we're the default, or we've found
+ // out we definately are the default, we end here.
+ if (state == ShellIntegration::STATE_PROCESSING ||
+ state == ShellIntegration::STATE_IS_DEFAULT) {
+ return;
+ }
+
+ // If we get here, either we are not the default or we cannot work out
+ // what the default is, so we proceed.
+ if (prompt_user_) {
+ // Ask the user if they want to allow the protocol. This will call
+ // LaunchUrlWithoutSecurityCheck if the user decides to accept the
+ // protocol.
+ ExternalProtocolHandler::RunExternalProtocolDialog(
+ escaped_url_, render_process_host_id_, tab_contents_id_);
+ return;
+ }
+
+ ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(escaped_url_);
+ }
+
+ virtual bool IsOwnedByWorker() OVERRIDE { return true; }
+
+ private:
+ GURL escaped_url_;
+ int render_process_host_id_;
+ int tab_contents_id_;
+ bool prompt_user_;
+};
+
+} // namespace
+
// static
void ExternalProtocolHandler::LaunchUrl(const GURL& url,
int render_process_host_id,
@@ -141,16 +194,19 @@ void ExternalProtocolHandler::LaunchUrl(const GURL& url,
g_accept_requests = false;
- if (block_state == UNKNOWN) {
- // Ask the user if they want to allow the protocol. This will call
- // LaunchUrlWithoutSecurityCheck if the user decides to accept the protocol.
- RunExternalProtocolDialog(escaped_url,
- render_process_host_id,
- tab_contents_id);
- return;
- }
-
- LaunchUrlWithoutSecurityCheck(escaped_url);
+ // The worker creates tasks with references to itself and puts them into
+ // message loops. When no tasks are left it will delete the observer and
+ // eventually be deleted itself.
+ ExternalDefaultProtocolObserver* observer;
+ observer = new ExternalDefaultProtocolObserver(url, render_process_host_id,
tony 2011/08/30 17:51:26 Nit: Maybe merge this with the previous line.
+ tab_contents_id, block_state == UNKNOWN);
+ scoped_refptr<ShellIntegration::DefaultProtocolClientWorker> worker;
+ worker = new ShellIntegration::DefaultProtocolClientWorker(observer,
tony 2011/08/30 17:51:26 Nit: Ditto
+ escaped_url.scheme());
+ // Start the check process running. This will send tasks to the FILE thread
+ // and when the answer is known will send the result back to the observer on
+ // the UI thread.
+ worker->StartCheckIsDefault();
}
// static
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698