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

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

Issue 7520023: Converted IncognitoForced boolean policy into IncognitoModeAvailability enum policy. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Removed unnecessary comment. Created 9 years, 4 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_init.h" 5 #include "chrome/browser/ui/browser_init.h"
6 6
7 #include <algorithm> // For max(). 7 #include <algorithm> // For max().
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/environment.h" 10 #include "base/environment.h"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/defaults.h" 25 #include "chrome/browser/defaults.h"
26 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 26 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
27 #include "chrome/browser/extensions/extension_creator.h" 27 #include "chrome/browser/extensions/extension_creator.h"
28 #include "chrome/browser/extensions/extension_service.h" 28 #include "chrome/browser/extensions/extension_service.h"
29 #include "chrome/browser/extensions/pack_extension_job.h" 29 #include "chrome/browser/extensions/pack_extension_job.h"
30 #include "chrome/browser/first_run/first_run.h" 30 #include "chrome/browser/first_run/first_run.h"
31 #include "chrome/browser/net/predictor_api.h" 31 #include "chrome/browser/net/predictor_api.h"
32 #include "chrome/browser/net/url_fixer_upper.h" 32 #include "chrome/browser/net/url_fixer_upper.h"
33 #include "chrome/browser/notifications/desktop_notification_service.h" 33 #include "chrome/browser/notifications/desktop_notification_service.h"
34 #include "chrome/browser/prefs/incognito_mode_prefs.h"
34 #include "chrome/browser/prefs/pref_service.h" 35 #include "chrome/browser/prefs/pref_service.h"
35 #include "chrome/browser/prefs/session_startup_pref.h" 36 #include "chrome/browser/prefs/session_startup_pref.h"
36 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" 37 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
37 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" 38 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h"
38 #include "chrome/browser/printing/print_dialog_cloud.h" 39 #include "chrome/browser/printing/print_dialog_cloud.h"
39 #include "chrome/browser/profiles/profile.h" 40 #include "chrome/browser/profiles/profile.h"
40 #include "chrome/browser/profiles/profile_io_data.h" 41 #include "chrome/browser/profiles/profile_io_data.h"
41 #include "chrome/browser/search_engines/template_url.h" 42 #include "chrome/browser/search_engines/template_url.h"
42 #include "chrome/browser/search_engines/template_url_service.h" 43 #include "chrome/browser/search_engines/template_url_service.h"
43 #include "chrome/browser/search_engines/template_url_service_factory.h" 44 #include "chrome/browser/search_engines/template_url_service_factory.h"
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 behavior = SessionRestore::CLOBBER_CURRENT_TAB; 354 behavior = SessionRestore::CLOBBER_CURRENT_TAB;
354 } 355 }
355 SessionRestore::RestoreSession( 356 SessionRestore::RestoreSession(
356 profile_, browser_, behavior, std::vector<GURL>()); 357 profile_, browser_, behavior, std::vector<GURL>());
357 return true; 358 return true;
358 } 359 }
359 360
360 361
361 // Utility functions ---------------------------------------------------------- 362 // Utility functions ----------------------------------------------------------
362 363
364 bool IncognitoIsForced(const CommandLine& command_line,
365 const PrefService* prefs) {
366 IncognitoModePrefs::Availability incognito_avail =
367 IncognitoModePrefs::GetAvailability(prefs);
368 return incognito_avail != IncognitoModePrefs::DISABLED &&
369 (command_line.HasSwitch(switches::kIncognito) ||
370 incognito_avail == IncognitoModePrefs::FORCED);
371 }
372
363 SessionStartupPref GetSessionStartupPref(const CommandLine& command_line, 373 SessionStartupPref GetSessionStartupPref(const CommandLine& command_line,
364 Profile* profile) { 374 Profile* profile) {
365 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile); 375 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile);
366 if (command_line.HasSwitch(switches::kRestoreLastSession)) 376 if (command_line.HasSwitch(switches::kRestoreLastSession))
367 pref.type = SessionStartupPref::LAST; 377 pref.type = SessionStartupPref::LAST;
368 if ((command_line.HasSwitch(switches::kIncognito) || 378 if (pref.type == SessionStartupPref::LAST &&
369 profile->GetPrefs()->GetBoolean(prefs::kIncognitoForced)) && 379 IncognitoIsForced(command_line, profile->GetPrefs())) {
370 pref.type == SessionStartupPref::LAST &&
371 profile->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)) {
372 // We don't store session information when incognito. If the user has 380 // We don't store session information when incognito. If the user has
373 // chosen to restore last session and launched incognito, fallback to 381 // chosen to restore last session and launched incognito, fallback to
374 // default launch behavior. 382 // default launch behavior.
375 pref.type = SessionStartupPref::DEFAULT; 383 pref.type = SessionStartupPref::DEFAULT;
376 } 384 }
377 return pref; 385 return pref;
378 } 386 }
379 387
380 enum LaunchMode { 388 enum LaunchMode {
381 LM_TO_BE_DECIDED = 0, // Possibly direct launch or via a shortcut. 389 LM_TO_BE_DECIDED = 0, // Possibly direct launch or via a shortcut.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 if (process_startup) { 538 if (process_startup) {
531 // NetworkStateNotifier has to be initialized before Launching browser 539 // NetworkStateNotifier has to be initialized before Launching browser
532 // because the page load can happen in parallel to this UI thread 540 // because the page load can happen in parallel to this UI thread
533 // and IO thread may access the NetworkStateNotifier. 541 // and IO thread may access the NetworkStateNotifier.
534 chromeos::CrosLibrary::Get()->GetNetworkLibrary() 542 chromeos::CrosLibrary::Get()->GetNetworkLibrary()
535 ->AddNetworkManagerObserver( 543 ->AddNetworkManagerObserver(
536 chromeos::NetworkStateNotifier::GetInstance()); 544 chromeos::NetworkStateNotifier::GetInstance());
537 } 545 }
538 #endif 546 #endif
539 547
540 // Continue with the incognito profile from here on if --incognito 548 // Continue with the incognito profile from here on if Incognito mode
541 if ((command_line.HasSwitch(switches::kIncognito) || 549 // is forced.
542 profile->GetPrefs()->GetBoolean(prefs::kIncognitoForced)) && 550 if (IncognitoIsForced(command_line, profile->GetPrefs())) {
543 profile->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)) {
544 profile = profile->GetOffTheRecordProfile(); 551 profile = profile->GetOffTheRecordProfile();
545 } 552 }
546 553
547 BrowserInit::LaunchWithProfile lwp(cur_dir, command_line, this); 554 BrowserInit::LaunchWithProfile lwp(cur_dir, command_line, this);
548 std::vector<GURL> urls_to_launch = BrowserInit::GetURLsFromCommandLine( 555 std::vector<GURL> urls_to_launch = BrowserInit::GetURLsFromCommandLine(
549 command_line, cur_dir, profile); 556 command_line, cur_dir, profile);
550 bool launched = lwp.Launch(profile, urls_to_launch, process_startup); 557 bool launched = lwp.Launch(profile, urls_to_launch, process_startup);
551 in_startup = false; 558 in_startup = false;
552 559
553 if (!launched) { 560 if (!launched) {
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 return false; 1449 return false;
1443 automation->SetExpectedTabCount(expected_tabs); 1450 automation->SetExpectedTabCount(expected_tabs);
1444 1451
1445 AutomationProviderList* list = 1452 AutomationProviderList* list =
1446 g_browser_process->InitAutomationProviderList(); 1453 g_browser_process->InitAutomationProviderList();
1447 DCHECK(list); 1454 DCHECK(list);
1448 list->AddProvider(automation); 1455 list->AddProvider(automation);
1449 1456
1450 return true; 1457 return true;
1451 } 1458 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698