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

Side by Side Diff: chrome/browser/ui/webui/options/browser_options_handler.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/options/browser_options_handler.h" 5 #include "chrome/browser/ui/webui/options/browser_options_handler.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 160 }
161 161
162 void BrowserOptionsHandler::UpdateDefaultBrowserState() { 162 void BrowserOptionsHandler::UpdateDefaultBrowserState() {
163 // Check for side-by-side first. 163 // Check for side-by-side first.
164 if (!platform_util::CanSetAsDefaultBrowser()) { 164 if (!platform_util::CanSetAsDefaultBrowser()) {
165 SetDefaultBrowserUIString(IDS_OPTIONS_DEFAULTBROWSER_SXS); 165 SetDefaultBrowserUIString(IDS_OPTIONS_DEFAULTBROWSER_SXS);
166 return; 166 return;
167 } 167 }
168 168
169 #if defined(OS_MACOSX) 169 #if defined(OS_MACOSX)
170 ShellIntegration::DefaultBrowserState state = 170 ShellIntegration::DefaultWebClientState state =
171 ShellIntegration::IsDefaultBrowser(); 171 ShellIntegration::IsDefaultBrowser();
172 int status_string_id; 172 int status_string_id;
173 if (state == ShellIntegration::IS_DEFAULT_BROWSER) 173 if (state == ShellIntegration::IS_DEFAULT_WEB_CLIENT)
174 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_DEFAULT; 174 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_DEFAULT;
175 else if (state == ShellIntegration::NOT_DEFAULT_BROWSER) 175 else if (state == ShellIntegration::NOT_DEFAULT_WEB_CLIENT)
176 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT; 176 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT;
177 else 177 else
178 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN; 178 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN;
179 179
180 SetDefaultBrowserUIString(status_string_id); 180 SetDefaultBrowserUIString(status_string_id);
181 #else 181 #else
182 default_browser_worker_->StartCheckDefaultBrowser(); 182 default_browser_worker_->StartCheckIsDefault();
183 #endif 183 #endif
184 } 184 }
185 185
186 void BrowserOptionsHandler::BecomeDefaultBrowser(const ListValue* args) { 186 void BrowserOptionsHandler::BecomeDefaultBrowser(const ListValue* args) {
187 // If the default browser setting is managed then we should not be able to 187 // If the default browser setting is managed then we should not be able to
188 // call this function. 188 // call this function.
189 if (default_browser_policy_.IsManaged()) 189 if (default_browser_policy_.IsManaged())
190 return; 190 return;
191 191
192 UserMetricsRecordAction(UserMetricsAction("Options_SetAsDefaultBrowser")); 192 UserMetricsRecordAction(UserMetricsAction("Options_SetAsDefaultBrowser"));
193 #if defined(OS_MACOSX) 193 #if defined(OS_MACOSX)
194 if (ShellIntegration::SetAsDefaultBrowser()) 194 if (ShellIntegration::SetAsDefaultBrowser())
195 UpdateDefaultBrowserState(); 195 UpdateDefaultBrowserState();
196 #else 196 #else
197 default_browser_worker_->StartSetAsDefaultBrowser(); 197 default_browser_worker_->StartSetAsDefault();
198 // Callback takes care of updating UI. 198 // Callback takes care of updating UI.
199 #endif 199 #endif
200 200
201 // If the user attempted to make Chrome the default browser, then he/she 201 // If the user attempted to make Chrome the default browser, then he/she
202 // arguably wants to be notified when that changes. 202 // arguably wants to be notified when that changes.
203 PrefService* prefs = web_ui_->GetProfile()->GetPrefs(); 203 PrefService* prefs = web_ui_->GetProfile()->GetPrefs();
204 prefs->SetBoolean(prefs::kCheckDefaultBrowser, true); 204 prefs->SetBoolean(prefs::kCheckDefaultBrowser, true);
205 } 205 }
206 206
207 int BrowserOptionsHandler::StatusStringIdForState( 207 int BrowserOptionsHandler::StatusStringIdForState(
208 ShellIntegration::DefaultBrowserState state) { 208 ShellIntegration::DefaultWebClientState state) {
209 if (state == ShellIntegration::IS_DEFAULT_BROWSER) 209 if (state == ShellIntegration::IS_DEFAULT_WEB_CLIENT)
210 return IDS_OPTIONS_DEFAULTBROWSER_DEFAULT; 210 return IDS_OPTIONS_DEFAULTBROWSER_DEFAULT;
211 if (state == ShellIntegration::NOT_DEFAULT_BROWSER) 211 if (state == ShellIntegration::NOT_DEFAULT_WEB_CLIENT)
212 return IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT; 212 return IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT;
213 return IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN; 213 return IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN;
214 } 214 }
215 215
216 void BrowserOptionsHandler::SetDefaultBrowserUIState( 216 void BrowserOptionsHandler::SetDefaultWebClientUIState(
217 ShellIntegration::DefaultBrowserUIState state) { 217 ShellIntegration::DefaultWebClientUIState state) {
218 int status_string_id; 218 int status_string_id;
219 if (state == ShellIntegration::STATE_IS_DEFAULT) 219 if (state == ShellIntegration::STATE_IS_DEFAULT)
220 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_DEFAULT; 220 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_DEFAULT;
221 else if (state == ShellIntegration::STATE_NOT_DEFAULT) 221 else if (state == ShellIntegration::STATE_NOT_DEFAULT)
222 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT; 222 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT;
223 else if (state == ShellIntegration::STATE_UNKNOWN) 223 else if (state == ShellIntegration::STATE_UNKNOWN)
224 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN; 224 status_string_id = IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN;
225 else 225 else
226 return; // Still processing. 226 return; // Still processing.
227 227
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 DictionaryValue* entry = new DictionaryValue(); 445 DictionaryValue* entry = new DictionaryValue();
446 entry->SetString("title", match.description); 446 entry->SetString("title", match.description);
447 entry->SetString("displayURL", match.contents); 447 entry->SetString("displayURL", match.contents);
448 entry->SetString("url", match.destination_url.spec()); 448 entry->SetString("url", match.destination_url.spec());
449 suggestions.Append(entry); 449 suggestions.Append(entry);
450 } 450 }
451 451
452 web_ui_->CallJavascriptFunction( 452 web_ui_->CallJavascriptFunction(
453 "BrowserOptions.updateAutocompleteSuggestions", suggestions); 453 "BrowserOptions.updateAutocompleteSuggestions", suggestions);
454 } 454 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698