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 "base/command_line.h" |
8 #include "base/version.h" | 8 #include "base/version.h" |
9 #include "chrome/browser/app_mode/app_mode_utils.h" | 9 #include "chrome/browser/app_mode/app_mode_utils.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/extensions/chrome_app_sorting.h" | 11 #include "chrome/browser/extensions/chrome_app_sorting.h" |
12 #include "chrome/browser/extensions/extension_prefs.h" | 12 #include "chrome/browser/extensions/extension_prefs.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
15 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h" | 15 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h" |
16 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/chrome_version_info.h" | 18 #include "chrome/common/chrome_version_info.h" |
19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
20 | 20 |
| 21 #if defined(OS_CHROMEOS) |
| 22 #include "chromeos/chromeos_switches.h" |
| 23 #endif |
| 24 |
21 namespace extensions { | 25 namespace extensions { |
22 | 26 |
23 ChromeExtensionsBrowserClient::ChromeExtensionsBrowserClient() {} | 27 ChromeExtensionsBrowserClient::ChromeExtensionsBrowserClient() {} |
24 | 28 |
25 ChromeExtensionsBrowserClient::~ChromeExtensionsBrowserClient() {} | 29 ChromeExtensionsBrowserClient::~ChromeExtensionsBrowserClient() {} |
26 | 30 |
27 bool ChromeExtensionsBrowserClient::IsShuttingDown() { | 31 bool ChromeExtensionsBrowserClient::IsShuttingDown() { |
28 return g_browser_process->IsShuttingDown(); | 32 return g_browser_process->IsShuttingDown(); |
29 } | 33 } |
30 | 34 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 #if defined(OS_ANDROID) | 86 #if defined(OS_ANDROID) |
83 return false; | 87 return false; |
84 #else | 88 #else |
85 // There are no browser windows open and the browser process was | 89 // There are no browser windows open and the browser process was |
86 // started to show the app launcher. | 90 // started to show the app launcher. |
87 return chrome::GetTotalBrowserCountForProfile(profile) == 0 && | 91 return chrome::GetTotalBrowserCountForProfile(profile) == 0 && |
88 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowAppList); | 92 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowAppList); |
89 #endif | 93 #endif |
90 } | 94 } |
91 | 95 |
| 96 bool ChromeExtensionsBrowserClient::IsBackgroundPageAllowed( |
| 97 content::BrowserContext* context) const { |
| 98 #if defined(OS_CHROMEOS) |
| 99 // Returns true if current session is Chrome OS Guest mode session and current |
| 100 // browser context is *not* off-the-record. Such context is artificial and |
| 101 // background page shouldn't be created in it. |
| 102 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 103 if (command_line->HasSwitch(chromeos::switches::kGuestSession) && |
| 104 !context->IsOffTheRecord()) { |
| 105 return false; |
| 106 } |
| 107 #endif |
| 108 return true; |
| 109 } |
| 110 |
92 bool ChromeExtensionsBrowserClient::DidVersionUpdate( | 111 bool ChromeExtensionsBrowserClient::DidVersionUpdate( |
93 content::BrowserContext* context) { | 112 content::BrowserContext* context) { |
94 Profile* profile = static_cast<Profile*>(context); | 113 Profile* profile = static_cast<Profile*>(context); |
95 | 114 |
96 // Unit tests may not provide prefs; assume everything is up-to-date. | 115 // Unit tests may not provide prefs; assume everything is up-to-date. |
97 ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(profile); | 116 ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(profile); |
98 if (!extension_prefs) | 117 if (!extension_prefs) |
99 return false; | 118 return false; |
100 | 119 |
101 // If we're inside a browser test, then assume prefs are all up-to-date. | 120 // If we're inside a browser test, then assume prefs are all up-to-date. |
(...skipping 27 matching lines...) Expand all Loading... |
129 bool ChromeExtensionsBrowserClient::IsRunningInForcedAppMode() { | 148 bool ChromeExtensionsBrowserClient::IsRunningInForcedAppMode() { |
130 return chrome::IsRunningInForcedAppMode(); | 149 return chrome::IsRunningInForcedAppMode(); |
131 } | 150 } |
132 | 151 |
133 content::JavaScriptDialogManager* | 152 content::JavaScriptDialogManager* |
134 ChromeExtensionsBrowserClient::GetJavaScriptDialogManager() { | 153 ChromeExtensionsBrowserClient::GetJavaScriptDialogManager() { |
135 return GetJavaScriptDialogManagerInstance(); | 154 return GetJavaScriptDialogManagerInstance(); |
136 } | 155 } |
137 | 156 |
138 } // namespace extensions | 157 } // namespace extensions |
OLD | NEW |