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

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: More changes for comments; fix for a bug introduced with DefaultWebClientWorker refactoring 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..fd0e035a0b794ac17c35b5abe8cab64ac96c2f54 100644
--- a/chrome/browser/shell_integration.cc
+++ b/chrome/browser/shell_integration.cc
@@ -61,86 +61,131 @@ CommandLine ShellIntegration::CommandLineArgsForLauncher(
}
///////////////////////////////////////////////////////////////////////////////
-// ShellIntegration::DefaultBrowserWorker
+// ShellIntegration::DefaultWebClientWorker
//
-ShellIntegration::DefaultBrowserWorker::DefaultBrowserWorker(
- DefaultBrowserObserver* observer)
+ShellIntegration::DefaultWebClientWorker::DefaultWebClientWorker(
+ DefaultWebClientObserver* observer)
: observer_(observer) {
}
-void ShellIntegration::DefaultBrowserWorker::StartCheckDefaultBrowser() {
- observer_->SetDefaultBrowserUIState(STATE_PROCESSING);
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(
- this, &DefaultBrowserWorker::ExecuteCheckDefaultBrowser));
+void ShellIntegration::DefaultWebClientWorker::StartCheckIsDefault() {
+ if (observer_) {
+ observer_->SetDefaultWebClientUIState(STATE_PROCESSING);
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ NewRunnableMethod(
+ this, &DefaultWebClientWorker::ExecuteCheckIsDefault));
+ }
}
-void ShellIntegration::DefaultBrowserWorker::StartSetAsDefaultBrowser() {
- observer_->SetDefaultBrowserUIState(STATE_PROCESSING);
+void ShellIntegration::DefaultWebClientWorker::StartSetAsDefault() {
+ if (observer_) {
+ observer_->SetDefaultWebClientUIState(STATE_PROCESSING);
+ }
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
NewRunnableMethod(
- this, &DefaultBrowserWorker::ExecuteSetAsDefaultBrowser));
+ this, &DefaultWebClientWorker::ExecuteSetAsDefault));
}
-void ShellIntegration::DefaultBrowserWorker::ObserverDestroyed() {
+void ShellIntegration::DefaultWebClientWorker::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:
+// DefaultWebClientWorker, private:
-void ShellIntegration::DefaultBrowserWorker::ExecuteCheckDefaultBrowser() {
+void ShellIntegration::DefaultWebClientWorker::ExecuteCheckIsDefault() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- DefaultBrowserState state = ShellIntegration::IsDefaultBrowser();
+ DefaultWebClientState state = CheckIsDefault();
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
NewRunnableMethod(
- this, &DefaultBrowserWorker::CompleteCheckDefaultBrowser, state));
+ this, &DefaultWebClientWorker::CompleteCheckIsDefault, state));
}
-void ShellIntegration::DefaultBrowserWorker::CompleteCheckDefaultBrowser(
- DefaultBrowserState state) {
+void ShellIntegration::DefaultWebClientWorker::CompleteCheckIsDefault(
+ DefaultWebClientState state) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
UpdateUI(state);
}
-void ShellIntegration::DefaultBrowserWorker::ExecuteSetAsDefaultBrowser() {
+void ShellIntegration::DefaultWebClientWorker::ExecuteSetAsDefault() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- ShellIntegration::SetAsDefaultBrowser();
+ SetAsDefault();
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
NewRunnableMethod(
- this, &DefaultBrowserWorker::CompleteSetAsDefaultBrowser));
+ this, &DefaultWebClientWorker::CompleteSetAsDefault));
}
-void ShellIntegration::DefaultBrowserWorker::CompleteSetAsDefaultBrowser() {
+void ShellIntegration::DefaultWebClientWorker::CompleteSetAsDefault() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- if (observer_) {
- // Set as default completed, check again to make sure it stuck...
- StartCheckDefaultBrowser();
- }
+ // Set as default completed, check again to make sure it stuck...
+ StartCheckIsDefault();
}
-void ShellIntegration::DefaultBrowserWorker::UpdateUI(
- DefaultBrowserState state) {
+void ShellIntegration::DefaultWebClientWorker::UpdateUI(
+ DefaultWebClientState state) {
if (observer_) {
switch (state) {
- case NOT_DEFAULT_BROWSER:
- observer_->SetDefaultBrowserUIState(STATE_NOT_DEFAULT);
+ case NOT_DEFAULT_WEB_CLIENT:
+ observer_->SetDefaultWebClientUIState(STATE_NOT_DEFAULT);
break;
- case IS_DEFAULT_BROWSER:
- observer_->SetDefaultBrowserUIState(STATE_IS_DEFAULT);
+ case IS_DEFAULT_WEB_CLIENT:
+ observer_->SetDefaultWebClientUIState(STATE_IS_DEFAULT);
break;
- case UNKNOWN_DEFAULT_BROWSER:
- observer_->SetDefaultBrowserUIState(STATE_UNKNOWN);
+ case UNKNOWN_DEFAULT_WEB_CLIENT:
+ observer_->SetDefaultWebClientUIState(STATE_UNKNOWN);
break;
default:
break;
}
}
}
+
+///////////////////////////////////////////////////////////////////////////////
+// ShellIntegration::DefaultBrowserWorker
+//
+
+ShellIntegration::DefaultBrowserWorker::DefaultBrowserWorker(
+ DefaultWebClientObserver* observer)
+ : DefaultWebClientWorker(observer) {
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// DefaultBrowserWorker, private:
+
+ShellIntegration::DefaultWebClientState
+ShellIntegration::DefaultBrowserWorker::CheckIsDefault() {
+ return ShellIntegration::IsDefaultBrowser();
+}
+
+void ShellIntegration::DefaultBrowserWorker::SetAsDefault() {
+ ShellIntegration::SetAsDefaultBrowser();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// ShellIntegration::DefaultProtocolClientWorker
+//
+
+ShellIntegration::DefaultProtocolClientWorker::DefaultProtocolClientWorker(
+ DefaultWebClientObserver* observer, const std::string& protocol)
+ : DefaultWebClientWorker(observer),
+ protocol_(protocol) {
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// DefaultProtocolClientWorker, private:
+
+ShellIntegration::DefaultWebClientState
+ShellIntegration::DefaultProtocolClientWorker::CheckIsDefault() {
+ return ShellIntegration::IsDefaultProtocolClient(protocol_);
+}
+
+void ShellIntegration::DefaultProtocolClientWorker::SetAsDefault() {
+ ShellIntegration::SetAsDefaultProtocolClient(protocol_);
+}

Powered by Google App Engine
This is Rietveld 408576698