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

Side by Side Diff: chrome/browser/ui/browser_commands.cc

Issue 11146023: Work on separate browser contexts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: another busted command line flag Created 8 years, 2 months 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
« no previous file with comments | « chrome/browser/ui/browser_commands.h ('k') | chrome/browser/ui/browser_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser_commands.h" 5 #include "chrome/browser/ui/browser_commands.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/bookmarks/bookmark_model.h" 10 #include "chrome/browser/bookmarks/bookmark_model.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 if (!download_util::IsSavableURL( 233 if (!download_util::IsSavableURL(
234 active_entry ? active_entry->GetURL() : GURL()) || 234 active_entry ? active_entry->GetURL() : GURL()) ||
235 current_tab->ShowingInterstitialPage()) 235 current_tab->ShowingInterstitialPage())
236 content_restrictions |= content::CONTENT_RESTRICTION_SAVE; 236 content_restrictions |= content::CONTENT_RESTRICTION_SAVE;
237 if (current_tab->ShowingInterstitialPage()) 237 if (current_tab->ShowingInterstitialPage())
238 content_restrictions |= content::CONTENT_RESTRICTION_PRINT; 238 content_restrictions |= content::CONTENT_RESTRICTION_PRINT;
239 } 239 }
240 return content_restrictions; 240 return content_restrictions;
241 } 241 }
242 242
243 void NewEmptyWindow(Profile* profile) { 243 void NewEmptyWindow(Profile* profile, HostDesktopType desktop_type) {
244 bool incognito = profile->IsOffTheRecord(); 244 bool incognito = profile->IsOffTheRecord();
245 PrefService* prefs = profile->GetPrefs(); 245 PrefService* prefs = profile->GetPrefs();
246 if (incognito) { 246 if (incognito) {
247 if (IncognitoModePrefs::GetAvailability(prefs) == 247 if (IncognitoModePrefs::GetAvailability(prefs) ==
248 IncognitoModePrefs::DISABLED) { 248 IncognitoModePrefs::DISABLED) {
249 incognito = false; 249 incognito = false;
250 } 250 }
251 } else { 251 } else {
252 if (browser_defaults::kAlwaysOpenIncognitoWindow && 252 if (browser_defaults::kAlwaysOpenIncognitoWindow &&
253 IncognitoModePrefs::ShouldLaunchIncognito( 253 IncognitoModePrefs::ShouldLaunchIncognito(
254 *CommandLine::ForCurrentProcess(), prefs)) { 254 *CommandLine::ForCurrentProcess(), prefs)) {
255 incognito = true; 255 incognito = true;
256 } 256 }
257 } 257 }
258 258
259 if (incognito) { 259 if (incognito) {
260 content::RecordAction(UserMetricsAction("NewIncognitoWindow")); 260 content::RecordAction(UserMetricsAction("NewIncognitoWindow"));
261 OpenEmptyWindow(profile->GetOffTheRecordProfile()); 261 OpenEmptyWindow(profile->GetOffTheRecordProfile(), desktop_type);
262 } else { 262 } else {
263 content::RecordAction(UserMetricsAction("NewWindow")); 263 content::RecordAction(UserMetricsAction("NewWindow"));
264 SessionService* session_service = 264 SessionService* session_service =
265 SessionServiceFactory::GetForProfile(profile->GetOriginalProfile()); 265 SessionServiceFactory::GetForProfile(profile->GetOriginalProfile());
266 if (!session_service || 266 if (!session_service ||
267 !session_service->RestoreIfNecessary(std::vector<GURL>())) { 267 !session_service->RestoreIfNecessary(std::vector<GURL>())) {
268 OpenEmptyWindow(profile->GetOriginalProfile()); 268 OpenEmptyWindow(profile->GetOriginalProfile(), desktop_type);
269 } 269 }
270 } 270 }
271 } 271 }
272 272
273 Browser* OpenEmptyWindow(Profile* profile) { 273 void NewEmptyWindow(Profile* profile) {
274 Browser* browser = new Browser(Browser::CreateParams(profile)); 274 NewEmptyWindow(profile, HOST_DESKTOP_TYPE_NATIVE);
275 }
276
277 Browser* OpenEmptyWindow(Profile* profile, HostDesktopType desktop_type) {
278 Browser* browser = new Browser(
279 Browser::CreateParams(Browser::TYPE_TABBED, profile, desktop_type));
275 AddBlankTab(browser, true); 280 AddBlankTab(browser, true);
276 browser->window()->Show(); 281 browser->window()->Show();
277 return browser; 282 return browser;
278 } 283 }
279 284
285 Browser* OpenEmptyWindow(Profile* profile) {
286 return OpenEmptyWindow(profile, HOST_DESKTOP_TYPE_NATIVE);
287 }
288
280 void OpenWindowWithRestoredTabs(Profile* profile) { 289 void OpenWindowWithRestoredTabs(Profile* profile) {
281 TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile); 290 TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile);
282 if (service) 291 if (service)
283 service->RestoreMostRecentEntry(NULL); 292 service->RestoreMostRecentEntry(NULL);
284 } 293 }
285 294
286 void OpenURLOffTheRecord(Profile* profile, 295 void OpenURLOffTheRecord(Profile* profile,
287 const GURL& url, 296 const GURL& url,
288 chrome::HostDesktopType desktop_type) { 297 chrome::HostDesktopType desktop_type) {
289 Browser* browser = browser::FindOrCreateTabbedBrowser( 298 Browser* browser = browser::FindOrCreateTabbedBrowser(
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 BrowserCommandsTabContentsCreator::CreateTabContents(contents); 1071 BrowserCommandsTabContentsCreator::CreateTabContents(contents);
1063 } 1072 }
1064 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); 1073 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true);
1065 1074
1066 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 1075 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
1067 contents->GetRenderViewHost()->SyncRendererPrefs(); 1076 contents->GetRenderViewHost()->SyncRendererPrefs();
1068 app_browser->window()->Show(); 1077 app_browser->window()->Show();
1069 } 1078 }
1070 1079
1071 } // namespace chrome 1080 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_commands.h ('k') | chrome/browser/ui/browser_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698