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

Unified Diff: chrome/browser/shell_integration.cc

Issue 6961013: Allow chrome to become the os default handler for arbitrary protocols on mac/win. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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
Index: chrome/browser/shell_integration.cc
diff --git a/chrome/browser/shell_integration.cc b/chrome/browser/shell_integration.cc
index 0b66d078dd23e449226561478e5579c10920489e..d28992e73af22b09f11a35c02fe6c2b2c66f8138 100644
--- a/chrome/browser/shell_integration.cc
+++ b/chrome/browser/shell_integration.cc
@@ -61,64 +61,105 @@ CommandLine ShellIntegration::CommandLineArgsForLauncher(
}
///////////////////////////////////////////////////////////////////////////////
-// ShellIntegration::DefaultBrowserWorker
+// ShellIntegration::DefaultClientAppWorker
//
-ShellIntegration::DefaultBrowserWorker::DefaultBrowserWorker(
- DefaultBrowserObserver* observer)
- : observer_(observer) {
+ShellIntegration::DefaultClientAppWorker::DefaultClientAppWorker(
+ DefaultClientAppObserver* observer)
+ : observer_(observer), protocol_() {
}
-void ShellIntegration::DefaultBrowserWorker::StartCheckDefaultBrowser() {
- observer_->SetDefaultBrowserUIState(STATE_PROCESSING);
+void ShellIntegration::DefaultClientAppWorker::StartCheckDefaultBrowser() {
+ if (observer_) {
+ observer_->SetDefaultClientAppUIState(STATE_PROCESSING);
+ }
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ NewRunnableMethod(
+ this, &DefaultClientAppWorker::ExecuteCheckDefaultBrowser));
+}
+
+void ShellIntegration::DefaultClientAppWorker::StartCheckDefaultProtocolClient(
+ const std::string& protocol) {
+ if (observer_) {
+ observer_->SetDefaultClientAppUIState(STATE_PROCESSING);
+ }
+ protocol_.assign(protocol);
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
NewRunnableMethod(
- this, &DefaultBrowserWorker::ExecuteCheckDefaultBrowser));
+ this, &DefaultClientAppWorker::ExecuteCheckDefaultProtocolClient));
}
-void ShellIntegration::DefaultBrowserWorker::StartSetAsDefaultBrowser() {
- observer_->SetDefaultBrowserUIState(STATE_PROCESSING);
+void ShellIntegration::DefaultClientAppWorker::StartSetAsDefaultBrowser() {
+ if (observer_) {
+ observer_->SetDefaultClientAppUIState(STATE_PROCESSING);
+ }
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ NewRunnableMethod(
+ this, &DefaultClientAppWorker::ExecuteSetAsDefaultBrowser));
+}
+
+void ShellIntegration::DefaultClientAppWorker::StartSetAsDefaultProtocolClient(
+ const std::string& protocol) {
+ if (observer_) {
+ observer_->SetDefaultClientAppUIState(STATE_PROCESSING);
+ }
+ protocol_.assign(protocol);
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
NewRunnableMethod(
- this, &DefaultBrowserWorker::ExecuteSetAsDefaultBrowser));
+ this, &DefaultClientAppWorker::ExecuteSetAsDefaultProtocolClient));
}
-void ShellIntegration::DefaultBrowserWorker::ObserverDestroyed() {
+void ShellIntegration::DefaultClientAppWorker::ObserverDestroyed() {
// Our associated view has gone away, so we shouldn't call back to it if
// our worker thread returns after the view is dead.
observer_ = NULL;
}
///////////////////////////////////////////////////////////////////////////////
-// DefaultBrowserWorker, private:
+// DefaultClientAppWorker, private:
-void ShellIntegration::DefaultBrowserWorker::ExecuteCheckDefaultBrowser() {
+void ShellIntegration::DefaultClientAppWorker::ExecuteCheckDefaultBrowser() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- DefaultBrowserState state = ShellIntegration::IsDefaultBrowser();
+ DefaultClientAppState state = ShellIntegration::IsDefaultBrowser();
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
NewRunnableMethod(
- this, &DefaultBrowserWorker::CompleteCheckDefaultBrowser, state));
+ this, &DefaultClientAppWorker::CompleteCheckDefaultApplication,
+ state));
}
-void ShellIntegration::DefaultBrowserWorker::CompleteCheckDefaultBrowser(
- DefaultBrowserState state) {
+void
+ShellIntegration::DefaultClientAppWorker::ExecuteCheckDefaultProtocolClient() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ DefaultClientAppState state =
+ ShellIntegration::IsDefaultProtocolClient(protocol_);
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ this, &DefaultClientAppWorker::CompleteCheckDefaultApplication,
+ state));
+}
+
+void ShellIntegration::DefaultClientAppWorker::CompleteCheckDefaultApplication(
+ DefaultClientAppState state) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
UpdateUI(state);
}
-void ShellIntegration::DefaultBrowserWorker::ExecuteSetAsDefaultBrowser() {
+void ShellIntegration::DefaultClientAppWorker::ExecuteSetAsDefaultBrowser() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
ShellIntegration::SetAsDefaultBrowser();
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
NewRunnableMethod(
- this, &DefaultBrowserWorker::CompleteSetAsDefaultBrowser));
+ this, &DefaultClientAppWorker::CompleteSetAsDefaultBrowser));
}
-void ShellIntegration::DefaultBrowserWorker::CompleteSetAsDefaultBrowser() {
+void ShellIntegration::DefaultClientAppWorker::CompleteSetAsDefaultBrowser() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (observer_) {
// Set as default completed, check again to make sure it stuck...
@@ -126,18 +167,37 @@ void ShellIntegration::DefaultBrowserWorker::CompleteSetAsDefaultBrowser() {
}
}
-void ShellIntegration::DefaultBrowserWorker::UpdateUI(
- DefaultBrowserState state) {
+void
+ShellIntegration::DefaultClientAppWorker::ExecuteSetAsDefaultProtocolClient() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ ShellIntegration::SetAsDefaultProtocolClient(protocol_);
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ this, &DefaultClientAppWorker::CompleteSetAsDefaultProtocolClient));
+}
+
+void
+ShellIntegration::DefaultClientAppWorker::CompleteSetAsDefaultProtocolClient() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (observer_) {
+ // Set as default completed, check again to make sure it stuck...
+ StartCheckDefaultProtocolClient(protocol_);
+ }
+}
+
+void ShellIntegration::DefaultClientAppWorker::UpdateUI(
+ DefaultClientAppState state) {
if (observer_) {
switch (state) {
- case NOT_DEFAULT_BROWSER:
- observer_->SetDefaultBrowserUIState(STATE_NOT_DEFAULT);
+ case NOT_DEFAULT_CLIENT_APP:
+ observer_->SetDefaultClientAppUIState(STATE_NOT_DEFAULT);
break;
- case IS_DEFAULT_BROWSER:
- observer_->SetDefaultBrowserUIState(STATE_IS_DEFAULT);
+ case IS_DEFAULT_CLIENT_APP:
+ observer_->SetDefaultClientAppUIState(STATE_IS_DEFAULT);
break;
- case UNKNOWN_DEFAULT_BROWSER:
- observer_->SetDefaultBrowserUIState(STATE_UNKNOWN);
+ case UNKNOWN_DEFAULT_CLIENT_APP:
+ observer_->SetDefaultClientAppUIState(STATE_UNKNOWN);
break;
default:
break;

Powered by Google App Engine
This is Rietveld 408576698