Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/chrome_extensions_browser_client.h" | 5 #include "chrome/browser/extensions/chrome_extensions_browser_client.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | |
| 7 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | |
| 11 #include "chrome/browser/ui/browser_finder.h" | |
| 12 #include "chrome/common/chrome_switches.h" | |
| 9 | 13 |
| 10 namespace extensions { | 14 namespace extensions { |
| 11 | 15 |
| 12 namespace { | 16 namespace { |
| 13 | 17 |
| 14 static base::LazyInstance<ChromeExtensionsBrowserClient> g_client = | 18 static base::LazyInstance<ChromeExtensionsBrowserClient> g_client = |
| 15 LAZY_INSTANCE_INITIALIZER; | 19 LAZY_INSTANCE_INITIALIZER; |
| 16 | 20 |
| 17 } // namespace | 21 } // namespace |
| 18 | 22 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 34 bool ChromeExtensionsBrowserClient::HasOffTheRecordContext( | 38 bool ChromeExtensionsBrowserClient::HasOffTheRecordContext( |
| 35 content::BrowserContext* context) { | 39 content::BrowserContext* context) { |
| 36 return static_cast<Profile*>(context)->HasOffTheRecordProfile(); | 40 return static_cast<Profile*>(context)->HasOffTheRecordProfile(); |
| 37 } | 41 } |
| 38 | 42 |
| 39 content::BrowserContext* ChromeExtensionsBrowserClient::GetOffTheRecordContext( | 43 content::BrowserContext* ChromeExtensionsBrowserClient::GetOffTheRecordContext( |
| 40 content::BrowserContext* context) { | 44 content::BrowserContext* context) { |
| 41 return static_cast<Profile*>(context)->GetOffTheRecordProfile(); | 45 return static_cast<Profile*>(context)->GetOffTheRecordProfile(); |
| 42 } | 46 } |
| 43 | 47 |
| 48 content::BrowserContext* ChromeExtensionsBrowserClient::GetOriginalContext( | |
| 49 content::BrowserContext* context) { | |
| 50 return static_cast<Profile*>(context)->GetOriginalProfile(); | |
|
miket_OOO
2013/10/31 23:04:53
This is probably already covered by your "all the
James Cook
2013/11/01 00:08:32
These casts have to stay, as do all the others in
| |
| 51 } | |
| 52 | |
| 53 bool ChromeExtensionsBrowserClient::DeferLoadingBackgroundHosts( | |
| 54 content::BrowserContext* context) const { | |
| 55 Profile* profile = static_cast<Profile*>(context); | |
| 56 | |
| 57 // The profile may not be valid yet if it is still being initialized. | |
| 58 // In that case, defer loading, since it depends on an initialized profile. | |
| 59 // http://crbug.com/222473 | |
| 60 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) | |
| 61 return true; | |
| 62 | |
| 63 #if defined(OS_ANDROID) | |
| 64 return false; | |
| 65 #else | |
| 66 // There are no browser windows open and the browser process was | |
| 67 // started to show the app launcher. | |
| 68 return chrome::GetTotalBrowserCountForProfile(profile) == 0 && | |
| 69 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowAppList); | |
| 70 #endif | |
| 71 } | |
| 72 | |
| 44 // static | 73 // static |
| 45 ChromeExtensionsBrowserClient* ChromeExtensionsBrowserClient::GetInstance() { | 74 ChromeExtensionsBrowserClient* ChromeExtensionsBrowserClient::GetInstance() { |
| 46 return g_client.Pointer(); | 75 return g_client.Pointer(); |
| 47 } | 76 } |
| 48 | 77 |
| 49 } // namespace extensions | 78 } // namespace extensions |
| OLD | NEW |