OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ash/chrome_shell_content_state.h" | 5 #include "chrome/browser/ui/ash/chrome_shell_content_state.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "chrome/browser/profiles/profile_manager.h" | 8 #include "chrome/browser/profiles/profile_manager.h" |
9 #include "components/user_manager/user_manager.h" | 9 #include "components/user_manager/user_manager.h" |
10 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
11 | 11 |
12 ChromeShellContentState::ChromeShellContentState() {} | 12 // static |
13 ChromeShellContentState::~ChromeShellContentState() {} | 13 ChromeShellContentState* ChromeShellContentState::instance_ = nullptr; |
14 | |
15 // static | |
16 void ChromeShellContentState::SetInstance(ChromeShellContentState* instance) { | |
17 DCHECK(!instance_); | |
18 instance_ = instance; | |
19 } | |
20 | |
21 // static | |
22 ChromeShellContentState* ChromeShellContentState::GetInstance() { | |
23 DCHECK(instance_); | |
24 return instance_; | |
25 } | |
26 | |
27 // static | |
28 void ChromeShellContentState::DestroyInstance() { | |
29 DCHECK(instance_); | |
30 delete instance_; | |
31 instance_ = nullptr; | |
32 } | |
33 | |
34 ChromeShellContentState::ChromeShellContentState() { | |
35 SetInstance(this); | |
36 } | |
37 | |
38 ChromeShellContentState::~ChromeShellContentState() { | |
39 DestroyInstance(); | |
James Cook
2017/01/09 21:07:19
optional: I like to do this:
DCHECK_EQ(this, g_in
riajiang
2017/01/09 23:46:51
Done.
| |
40 } | |
14 | 41 |
15 content::BrowserContext* ChromeShellContentState::GetActiveBrowserContext() { | 42 content::BrowserContext* ChromeShellContentState::GetActiveBrowserContext() { |
16 DCHECK(user_manager::UserManager::Get()->GetLoggedInUsers().size()); | 43 DCHECK(user_manager::UserManager::Get()->GetLoggedInUsers().size()); |
17 return ProfileManager::GetActiveUserProfile(); | 44 return ProfileManager::GetActiveUserProfile(); |
18 } | 45 } |
OLD | NEW |