OLD | NEW |
---|---|
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.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 #endif // OS_WIN | 10 #endif // OS_WIN |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 | 218 |
219 // Need to know when to alert the user of theme install delay. | 219 // Need to know when to alert the user of theme install delay. |
220 registrar_.Add(this, NotificationType::EXTENSION_READY_FOR_INSTALL, | 220 registrar_.Add(this, NotificationType::EXTENSION_READY_FOR_INSTALL, |
221 NotificationService::AllSources()); | 221 NotificationService::AllSources()); |
222 | 222 |
223 PrefService* local_state = g_browser_process->local_state(); | 223 PrefService* local_state = g_browser_process->local_state(); |
224 if (local_state) | 224 if (local_state) |
225 printing_enabled_.Init(prefs::kPrintingEnabled, local_state, this); | 225 printing_enabled_.Init(prefs::kPrintingEnabled, local_state, this); |
226 dev_tools_disabled_.Init(prefs::kDevToolsDisabled, | 226 dev_tools_disabled_.Init(prefs::kDevToolsDisabled, |
227 profile_->GetPrefs(), this); | 227 profile_->GetPrefs(), this); |
228 incognito_mode_allowed_.Init(prefs::kIncognitoEnabled, | |
229 profile_->GetPrefs(), this); | |
Finnur
2011/01/26 13:23:38
Daniel/Matthias: I checked this in after the try s
Finnur
2011/01/26 13:44:35
Hmm... I believe this is because of a missing Dest
| |
228 | 230 |
229 InitCommandState(); | 231 InitCommandState(); |
230 BrowserList::AddBrowser(this); | 232 BrowserList::AddBrowser(this); |
231 | 233 |
232 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, | 234 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, |
233 profile_->GetPrefs(), NULL); | 235 profile_->GetPrefs(), NULL); |
234 use_vertical_tabs_.Init(prefs::kUseVerticalTabs, profile_->GetPrefs(), this); | 236 use_vertical_tabs_.Init(prefs::kUseVerticalTabs, profile_->GetPrefs(), this); |
235 instant_enabled_.Init(prefs::kInstantEnabled, profile_->GetPrefs(), this); | 237 instant_enabled_.Init(prefs::kInstantEnabled, profile_->GetPrefs(), this); |
236 if (!TabMenuModel::AreVerticalTabsEnabled()) { | 238 if (!TabMenuModel::AreVerticalTabsEnabled()) { |
237 // If vertical tabs aren't enabled, explicitly turn them off. Otherwise we | 239 // If vertical tabs aren't enabled, explicitly turn them off. Otherwise we |
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1280 browser::Navigate(¶ms); | 1282 browser::Navigate(¶ms); |
1281 } | 1283 } |
1282 | 1284 |
1283 void Browser::Stop() { | 1285 void Browser::Stop() { |
1284 UserMetrics::RecordAction(UserMetricsAction("Stop"), profile_); | 1286 UserMetrics::RecordAction(UserMetricsAction("Stop"), profile_); |
1285 GetSelectedTabContentsWrapper()->tab_contents()->Stop(); | 1287 GetSelectedTabContentsWrapper()->tab_contents()->Stop(); |
1286 } | 1288 } |
1287 | 1289 |
1288 void Browser::NewWindow() { | 1290 void Browser::NewWindow() { |
1289 if (browser_defaults::kAlwaysOpenIncognitoWindow && | 1291 if (browser_defaults::kAlwaysOpenIncognitoWindow && |
1290 CommandLine::ForCurrentProcess()->HasSwitch(switches::kIncognito)) { | 1292 CommandLine::ForCurrentProcess()->HasSwitch(switches::kIncognito) && |
1293 incognito_mode_allowed_.GetValue()) { | |
1291 NewIncognitoWindow(); | 1294 NewIncognitoWindow(); |
1292 return; | 1295 return; |
1293 } | 1296 } |
1294 UserMetrics::RecordAction(UserMetricsAction("NewWindow"), profile_); | 1297 UserMetrics::RecordAction(UserMetricsAction("NewWindow"), profile_); |
1295 SessionService* session_service = | 1298 SessionService* session_service = |
1296 profile_->GetOriginalProfile()->GetSessionService(); | 1299 profile_->GetOriginalProfile()->GetSessionService(); |
1297 if (!session_service || | 1300 if (!session_service || |
1298 !session_service->RestoreIfNecessary(std::vector<GURL>())) { | 1301 !session_service->RestoreIfNecessary(std::vector<GURL>())) { |
1299 Browser::OpenEmptyWindow(profile_->GetOriginalProfile()); | 1302 Browser::OpenEmptyWindow(profile_->GetOriginalProfile()); |
1300 } | 1303 } |
1301 } | 1304 } |
1302 | 1305 |
1303 void Browser::NewIncognitoWindow() { | 1306 void Browser::NewIncognitoWindow() { |
1307 if (!incognito_mode_allowed_.GetValue()) { | |
1308 NewWindow(); | |
1309 return; | |
1310 } | |
1311 | |
1304 UserMetrics::RecordAction(UserMetricsAction("NewIncognitoWindow"), profile_); | 1312 UserMetrics::RecordAction(UserMetricsAction("NewIncognitoWindow"), profile_); |
1305 Browser::OpenEmptyWindow(profile_->GetOffTheRecordProfile()); | 1313 Browser::OpenEmptyWindow(profile_->GetOffTheRecordProfile()); |
1306 } | 1314 } |
1307 | 1315 |
1308 void Browser::CloseWindow() { | 1316 void Browser::CloseWindow() { |
1309 UserMetrics::RecordAction(UserMetricsAction("CloseWindow"), profile_); | 1317 UserMetrics::RecordAction(UserMetricsAction("CloseWindow"), profile_); |
1310 window_->Close(); | 1318 window_->Close(); |
1311 } | 1319 } |
1312 | 1320 |
1313 void Browser::NewTab() { | 1321 void Browser::NewTab() { |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1922 } | 1930 } |
1923 } | 1931 } |
1924 | 1932 |
1925 void Browser::OpenLanguageOptionsDialog() { | 1933 void Browser::OpenLanguageOptionsDialog() { |
1926 UserMetrics::RecordAction(UserMetricsAction("OpenLanguageOptionsDialog"), | 1934 UserMetrics::RecordAction(UserMetricsAction("OpenLanguageOptionsDialog"), |
1927 profile_); | 1935 profile_); |
1928 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 1936 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
1929 switches::kDisableTabbedOptions)) { | 1937 switches::kDisableTabbedOptions)) { |
1930 ShowOptionsTab(chrome::kLanguageOptionsSubPage); | 1938 ShowOptionsTab(chrome::kLanguageOptionsSubPage); |
1931 } else { | 1939 } else { |
1932 // Language options dialog has been replaced by DOMUI. | 1940 // Language options dialog has been replaced by DOMUI. |
1933 } | 1941 } |
1934 } | 1942 } |
1935 | 1943 |
1936 void Browser::OpenSystemTabAndActivate() { | 1944 void Browser::OpenSystemTabAndActivate() { |
1937 OpenURL(GURL(chrome::kChromeUISystemInfoURL), GURL(), | 1945 OpenURL(GURL(chrome::kChromeUISystemInfoURL), GURL(), |
1938 NEW_FOREGROUND_TAB, PageTransition::LINK); | 1946 NEW_FOREGROUND_TAB, PageTransition::LINK); |
1939 window_->Activate(); | 1947 window_->Activate(); |
1940 } | 1948 } |
1941 | 1949 |
1942 void Browser::OpenMobilePlanTabAndActivate() { | 1950 void Browser::OpenMobilePlanTabAndActivate() { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2018 prefs->RegisterBooleanPref(prefs::kCheckDefaultBrowser, true); | 2026 prefs->RegisterBooleanPref(prefs::kCheckDefaultBrowser, true); |
2019 prefs->RegisterBooleanPref(prefs::kShowOmniboxSearchHint, true); | 2027 prefs->RegisterBooleanPref(prefs::kShowOmniboxSearchHint, true); |
2020 prefs->RegisterBooleanPref(prefs::kWebAppCreateOnDesktop, true); | 2028 prefs->RegisterBooleanPref(prefs::kWebAppCreateOnDesktop, true); |
2021 prefs->RegisterBooleanPref(prefs::kWebAppCreateInAppsMenu, true); | 2029 prefs->RegisterBooleanPref(prefs::kWebAppCreateInAppsMenu, true); |
2022 prefs->RegisterBooleanPref(prefs::kWebAppCreateInQuickLaunchBar, true); | 2030 prefs->RegisterBooleanPref(prefs::kWebAppCreateInQuickLaunchBar, true); |
2023 prefs->RegisterBooleanPref(prefs::kUseVerticalTabs, false); | 2031 prefs->RegisterBooleanPref(prefs::kUseVerticalTabs, false); |
2024 prefs->RegisterBooleanPref(prefs::kEnableTranslate, true); | 2032 prefs->RegisterBooleanPref(prefs::kEnableTranslate, true); |
2025 prefs->RegisterBooleanPref(prefs::kRemotingHasSetupCompleted, false); | 2033 prefs->RegisterBooleanPref(prefs::kRemotingHasSetupCompleted, false); |
2026 prefs->RegisterStringPref(prefs::kCloudPrintEmail, std::string()); | 2034 prefs->RegisterStringPref(prefs::kCloudPrintEmail, std::string()); |
2027 prefs->RegisterBooleanPref(prefs::kDevToolsDisabled, false); | 2035 prefs->RegisterBooleanPref(prefs::kDevToolsDisabled, false); |
2036 prefs->RegisterBooleanPref(prefs::kIncognitoEnabled, true); | |
2028 prefs->RegisterRealPref(prefs::kDefaultZoomLevel, 0.0); | 2037 prefs->RegisterRealPref(prefs::kDefaultZoomLevel, 0.0); |
2029 prefs->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0); | 2038 prefs->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0); |
2030 // We need to register the type of this preference in order to query | 2039 // We need to register the type of this preference in order to query |
2031 // it even though it's only typically controlled via policy. | 2040 // it even though it's only typically controlled via policy. |
2032 prefs->RegisterBooleanPref(prefs::kDisable3DAPIs, false); | 2041 prefs->RegisterBooleanPref(prefs::kDisable3DAPIs, false); |
2033 } | 2042 } |
2034 | 2043 |
2035 // static | 2044 // static |
2036 bool Browser::RunUnloadEventsHelper(TabContents* contents) { | 2045 bool Browser::RunUnloadEventsHelper(TabContents* contents) { |
2037 // If the TabContents is not connected yet, then there's no unload | 2046 // If the TabContents is not connected yet, then there's no unload |
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3421 // All browser commands whose state isn't set automagically some other way | 3430 // All browser commands whose state isn't set automagically some other way |
3422 // (like Back & Forward with initial page load) must have their state | 3431 // (like Back & Forward with initial page load) must have their state |
3423 // initialized here, otherwise they will be forever disabled. | 3432 // initialized here, otherwise they will be forever disabled. |
3424 | 3433 |
3425 // Navigation commands | 3434 // Navigation commands |
3426 command_updater_.UpdateCommandEnabled(IDC_RELOAD, true); | 3435 command_updater_.UpdateCommandEnabled(IDC_RELOAD, true); |
3427 command_updater_.UpdateCommandEnabled(IDC_RELOAD_IGNORING_CACHE, true); | 3436 command_updater_.UpdateCommandEnabled(IDC_RELOAD_IGNORING_CACHE, true); |
3428 | 3437 |
3429 // Window management commands | 3438 // Window management commands |
3430 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW, true); | 3439 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW, true); |
3431 command_updater_.UpdateCommandEnabled(IDC_NEW_INCOGNITO_WINDOW, true); | 3440 command_updater_.UpdateCommandEnabled(IDC_NEW_INCOGNITO_WINDOW, |
3441 incognito_mode_allowed_.GetValue()); | |
3432 command_updater_.UpdateCommandEnabled(IDC_CLOSE_WINDOW, true); | 3442 command_updater_.UpdateCommandEnabled(IDC_CLOSE_WINDOW, true); |
3433 command_updater_.UpdateCommandEnabled(IDC_NEW_TAB, true); | 3443 command_updater_.UpdateCommandEnabled(IDC_NEW_TAB, true); |
3434 command_updater_.UpdateCommandEnabled(IDC_CLOSE_TAB, true); | 3444 command_updater_.UpdateCommandEnabled(IDC_CLOSE_TAB, true); |
3435 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, true); | 3445 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, true); |
3436 command_updater_.UpdateCommandEnabled(IDC_RESTORE_TAB, false); | 3446 command_updater_.UpdateCommandEnabled(IDC_RESTORE_TAB, false); |
3437 command_updater_.UpdateCommandEnabled(IDC_EXIT, true); | 3447 command_updater_.UpdateCommandEnabled(IDC_EXIT, true); |
3438 command_updater_.UpdateCommandEnabled(IDC_TOGGLE_VERTICAL_TABS, true); | 3448 command_updater_.UpdateCommandEnabled(IDC_TOGGLE_VERTICAL_TABS, true); |
3439 | 3449 |
3440 // Page-related commands | 3450 // Page-related commands |
3441 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, true); | 3451 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, true); |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4262 // The page transition below is only for the purpose of inserting the tab. | 4272 // The page transition below is only for the purpose of inserting the tab. |
4263 browser->AddTab(view_source_contents, PageTransition::LINK); | 4273 browser->AddTab(view_source_contents, PageTransition::LINK); |
4264 } | 4274 } |
4265 | 4275 |
4266 if (profile_->HasSessionService()) { | 4276 if (profile_->HasSessionService()) { |
4267 SessionService* session_service = profile_->GetSessionService(); | 4277 SessionService* session_service = profile_->GetSessionService(); |
4268 if (session_service) | 4278 if (session_service) |
4269 session_service->TabRestored(&view_source_contents->controller(), false); | 4279 session_service->TabRestored(&view_source_contents->controller(), false); |
4270 } | 4280 } |
4271 } | 4281 } |
OLD | NEW |