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

Side by Side Diff: chrome/browser/shell_integration_win.cc

Issue 6090006: Regkey functions return error code instead of bool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
« no previous file with comments | « chrome/browser/rlz/rlz_unittest.cc ('k') | chrome/browser/ui/views/external_protocol_dialog.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/shell_integration.h" 5 #include "chrome/browser/shell_integration.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shobjidl.h> 8 #include <shobjidl.h>
9 #include <propkey.h> 9 #include <propkey.h>
10 #include <propvarutil.h> 10 #include <propvarutil.h>
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 339
340 // open command for protocol associations 340 // open command for protocol associations
341 for (int i = 0; i < _countof(kChromeProtocols); i++) { 341 for (int i = 0; i < _countof(kChromeProtocols); i++) {
342 // Check in HKEY_CLASSES_ROOT that is the result of merge between 342 // Check in HKEY_CLASSES_ROOT that is the result of merge between
343 // HKLM and HKCU 343 // HKLM and HKCU
344 HKEY root_key = HKEY_CLASSES_ROOT; 344 HKEY root_key = HKEY_CLASSES_ROOT;
345 // Check <protocol>\shell\open\command 345 // Check <protocol>\shell\open\command
346 std::wstring key_path(kChromeProtocols[i] + ShellUtil::kRegShellOpen); 346 std::wstring key_path(kChromeProtocols[i] + ShellUtil::kRegShellOpen);
347 base::win::RegKey key(root_key, key_path.c_str(), KEY_READ); 347 base::win::RegKey key(root_key, key_path.c_str(), KEY_READ);
348 std::wstring value; 348 std::wstring value;
349 if (!key.Valid() || !key.ReadValue(L"", &value)) 349 if (!key.Valid() || (key.ReadValue(L"", &value) != ERROR_SUCCESS))
350 return NOT_DEFAULT_BROWSER; 350 return NOT_DEFAULT_BROWSER;
351 // Need to normalize path in case it's been munged. 351 // Need to normalize path in case it's been munged.
352 CommandLine command_line = CommandLine::FromString(value); 352 CommandLine command_line = CommandLine::FromString(value);
353 std::wstring short_path; 353 std::wstring short_path;
354 GetShortPathName(command_line.GetProgram().value().c_str(), 354 GetShortPathName(command_line.GetProgram().value().c_str(),
355 WriteInto(&short_path, MAX_PATH), MAX_PATH); 355 WriteInto(&short_path, MAX_PATH), MAX_PATH);
356 if (!FilePath::CompareEqualIgnoreCase(short_path, short_app_path)) 356 if (!FilePath::CompareEqualIgnoreCase(short_path, short_app_path))
357 return NOT_DEFAULT_BROWSER; 357 return NOT_DEFAULT_BROWSER;
358 } 358 }
359 } 359 }
(...skipping 10 matching lines...) Expand all
370 // This method checks if Firefox is defualt browser by checking these 370 // This method checks if Firefox is defualt browser by checking these
371 // locations and returns true if Firefox traces are found there. In case of 371 // locations and returns true if Firefox traces are found there. In case of
372 // error (or if Firefox is not found)it returns the default value which 372 // error (or if Firefox is not found)it returns the default value which
373 // is false. 373 // is false.
374 bool ShellIntegration::IsFirefoxDefaultBrowser() { 374 bool ShellIntegration::IsFirefoxDefaultBrowser() {
375 bool ff_default = false; 375 bool ff_default = false;
376 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { 376 if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
377 std::wstring app_cmd; 377 std::wstring app_cmd;
378 base::win::RegKey key(HKEY_CURRENT_USER, 378 base::win::RegKey key(HKEY_CURRENT_USER,
379 ShellUtil::kRegVistaUrlPrefs, KEY_READ); 379 ShellUtil::kRegVistaUrlPrefs, KEY_READ);
380 if (key.Valid() && key.ReadValue(L"Progid", &app_cmd) && 380 if (key.Valid() && (key.ReadValue(L"Progid", &app_cmd) == ERROR_SUCCESS) &&
381 app_cmd == L"FirefoxURL") 381 app_cmd == L"FirefoxURL")
382 ff_default = true; 382 ff_default = true;
383 } else { 383 } else {
384 std::wstring key_path(L"http"); 384 std::wstring key_path(L"http");
385 key_path.append(ShellUtil::kRegShellOpen); 385 key_path.append(ShellUtil::kRegShellOpen);
386 base::win::RegKey key(HKEY_CLASSES_ROOT, key_path.c_str(), KEY_READ); 386 base::win::RegKey key(HKEY_CLASSES_ROOT, key_path.c_str(), KEY_READ);
387 std::wstring app_cmd; 387 std::wstring app_cmd;
388 if (key.Valid() && key.ReadValue(L"", &app_cmd) && 388 if (key.Valid() && (key.ReadValue(L"", &app_cmd) == ERROR_SUCCESS) &&
389 std::wstring::npos != StringToLowerASCII(app_cmd).find(L"firefox")) 389 std::wstring::npos != StringToLowerASCII(app_cmd).find(L"firefox"))
390 ff_default = true; 390 ff_default = true;
391 } 391 }
392 return ff_default; 392 return ff_default;
393 } 393 }
394 394
395 std::wstring ShellIntegration::GetAppId(const std::wstring& app_name, 395 std::wstring ShellIntegration::GetAppId(const std::wstring& app_name,
396 const FilePath& profile_path) { 396 const FilePath& profile_path) {
397 std::wstring app_id(app_name); 397 std::wstring app_id(app_name);
398 398
(...skipping 13 matching lines...) Expand all
412 profile_path); 412 profile_path);
413 } 413 }
414 414
415 void ShellIntegration::MigrateChromiumShortcuts() { 415 void ShellIntegration::MigrateChromiumShortcuts() {
416 if (base::win::GetVersion() < base::win::VERSION_WIN7) 416 if (base::win::GetVersion() < base::win::VERSION_WIN7)
417 return; 417 return;
418 418
419 BrowserThread::PostTask( 419 BrowserThread::PostTask(
420 BrowserThread::FILE, FROM_HERE, new MigrateChromiumShortcutsTask()); 420 BrowserThread::FILE, FROM_HERE, new MigrateChromiumShortcutsTask());
421 } 421 }
OLDNEW
« no previous file with comments | « chrome/browser/rlz/rlz_unittest.cc ('k') | chrome/browser/ui/views/external_protocol_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698