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/profiles/profile_window.h" | 5 #include "chrome/browser/profiles/profile_window.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 #endif // defined(ENABLE_EXTENSIONS) | 141 #endif // defined(ENABLE_EXTENSIONS) |
142 | 142 |
143 // If |always_create| is false, and we have a |callback| to run, check | 143 // If |always_create| is false, and we have a |callback| to run, check |
144 // whether a browser already exists so that we can run the callback. We don't | 144 // whether a browser already exists so that we can run the callback. We don't |
145 // want to rely on the observer listening to OnBrowserSetLastActive in this | 145 // want to rely on the observer listening to OnBrowserSetLastActive in this |
146 // case, as you could manually activate an incorrect browser and trigger | 146 // case, as you could manually activate an incorrect browser and trigger |
147 // a false positive. | 147 // a false positive. |
148 if (!always_create) { | 148 if (!always_create) { |
149 Browser* browser = chrome::FindTabbedBrowser(profile, false, desktop_type); | 149 Browser* browser = chrome::FindTabbedBrowser(profile, false, desktop_type); |
150 if (browser) { | 150 if (browser) { |
151 browser->window()->Activate(); | 151 browser->window()->Activate(true /* user_gesture */); |
152 if (!callback.is_null()) | 152 if (!callback.is_null()) |
153 callback.Run(profile, Profile::CREATE_STATUS_INITIALIZED); | 153 callback.Run(profile, Profile::CREATE_STATUS_INITIALIZED); |
154 return; | 154 return; |
155 } | 155 } |
156 } | 156 } |
157 | 157 |
158 // If there is a callback, create an observer to make sure it is only | 158 // If there is a callback, create an observer to make sure it is only |
159 // run when the browser has been completely created. This observer will | 159 // run when the browser has been completely created. This observer will |
160 // delete itself once that happens. This should not leak, because we are | 160 // delete itself once that happens. This should not leak, because we are |
161 // passing |always_create| = true to FindOrCreateNewWindow below, which ends | 161 // passing |always_create| = true to FindOrCreateNewWindow below, which ends |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 chrome::HostDesktopType desktop_type, | 251 chrome::HostDesktopType desktop_type, |
252 bool always_create) { | 252 bool always_create) { |
253 #if defined(OS_IOS) | 253 #if defined(OS_IOS) |
254 NOTREACHED(); | 254 NOTREACHED(); |
255 #else | 255 #else |
256 DCHECK(profile); | 256 DCHECK(profile); |
257 | 257 |
258 if (!always_create) { | 258 if (!always_create) { |
259 Browser* browser = chrome::FindTabbedBrowser(profile, false, desktop_type); | 259 Browser* browser = chrome::FindTabbedBrowser(profile, false, desktop_type); |
260 if (browser) { | 260 if (browser) { |
261 browser->window()->Activate(); | 261 browser->window()->Activate(true /* user_gesture */); |
262 return; | 262 return; |
263 } | 263 } |
264 } | 264 } |
265 | 265 |
266 content::RecordAction(UserMetricsAction("NewWindow")); | 266 content::RecordAction(UserMetricsAction("NewWindow")); |
267 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 267 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
268 StartupBrowserCreator browser_creator; | 268 StartupBrowserCreator browser_creator; |
269 browser_creator.LaunchBrowser( | 269 browser_creator.LaunchBrowser( |
270 command_line, profile, base::FilePath(), process_startup, is_first_run); | 270 command_line, profile, base::FilePath(), process_startup, is_first_run); |
271 #endif // defined(OS_IOS) | 271 #endif // defined(OS_IOS) |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 PrefService* local_state = g_browser_process->local_state(); | 542 PrefService* local_state = g_browser_process->local_state(); |
543 const bool dismissed = local_state->GetBoolean( | 543 const bool dismissed = local_state->GetBoolean( |
544 prefs::kProfileAvatarRightClickTutorialDismissed); | 544 prefs::kProfileAvatarRightClickTutorialDismissed); |
545 | 545 |
546 // Don't show the tutorial if it's already been dismissed or if right-clicking | 546 // Don't show the tutorial if it's already been dismissed or if right-clicking |
547 // wouldn't show any targets. | 547 // wouldn't show any targets. |
548 return !dismissed && HasProfileSwitchTargets(profile); | 548 return !dismissed && HasProfileSwitchTargets(profile); |
549 } | 549 } |
550 | 550 |
551 } // namespace profiles | 551 } // namespace profiles |
OLD | NEW |