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

Side by Side Diff: chrome/browser/background_mode_manager_mac.mm

Issue 5368002: Move Mac LaunchOnStartup enable/disable to File thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changing Mac LaunchOnStartupResetAllowed to accommodate FILE thread issues Created 10 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "app/l10n_util.h"
6 #include "base/command_line.h"
7 #include "base/mac_util.h"
8 #include "chrome/app/chrome_command_ids.h"
Andrew T Wilson (Slow) 2010/12/04 18:49:48 can you remove chrome_command_ids.h?
The wrong rickcam account 2010/12/07 22:59:57 Done.
9 #include "chrome/browser/background_mode_manager.h"
10 #include "chrome/browser/browser_thread.h"
11 #include "chrome/common/app_mode_common_mac.h"
12 #include "chrome/common/chrome_switches.h"
13 #include "grit/generated_resources.h"
14
15 class DisableLaunchOnStartupTask : public Task {
16 public:
17 virtual void Run();
18 };
19
20 class EnableLaunchOnStartupTask : public Task {
21 public:
22 virtual void Run();
23 };
24
25 const CFStringRef kLaunchOnStartupResetAllowedPrefsKey =
26 CFSTR("LaunchOnStartupResetAllowed");
27
28 void DisableLaunchOnStartupTask::Run() {
29 Boolean keyExistsAndHasValidFormat; // ignored
Andrew T Wilson (Slow) 2010/12/04 18:49:48 should be hacker_style, not camelCase?
The wrong rickcam account 2010/12/07 22:59:57 Done.
30 if (CFPreferencesGetAppBooleanValue(kLaunchOnStartupResetAllowedPrefsKey,
Andrew T Wilson (Slow) 2010/12/04 18:49:48 I did some quick googling, and I didn't see anythi
The wrong rickcam account 2010/12/07 22:59:57 I've fixed the inverted test. Based on email from
31 app_mode::kAppPrefsID,
32 &keyExistsAndHasValidFormat))
33 return;
34
35 CFPreferencesSetAppValue(kLaunchOnStartupResetAllowedPrefsKey,
36 kCFBooleanFalse,
37 app_mode::kAppPrefsID);
38
39 // Check if Chrome is not a login Item, or is a Login Item but w/o 'hidden'
40 // flag - most likely user has modified the setting, don't override it.
41 bool is_hidden = false;
42 if (!mac_util::CheckLoginItemStatus(&is_hidden) || !is_hidden)
43 return;
44
45 mac_util::RemoveFromLoginItems();
46 }
47
48 void EnableLaunchOnStartupTask::Run() {
49 // Return if Chrome is already a Login Item (avoid overriding user choice).
50 if (mac_util::CheckLoginItemStatus(NULL))
51 return;
52
53 mac_util::AddToLoginItems(true); // Hide on startup.
54 CFPreferencesSetAppValue(kLaunchOnStartupResetAllowedPrefsKey,
55 kCFBooleanTrue,
56 app_mode::kAppPrefsID);
57 }
58
59 void BackgroundModeManager::EnableLaunchOnStartup(bool should_launch) {
60 // This functionality is only defined for default profile, currently.
61 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUserDataDir))
62 return;
63
64 if (should_launch) {
65 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
66 new EnableLaunchOnStartupTask());
67 } else {
68 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
69 new DisableLaunchOnStartupTask());
70 }
71 }
72
73 string16 BackgroundModeManager::GetPreferencesMenuLabel() {
74 return l10n_util::GetStringUTF16(IDS_OPTIONS);
75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698