OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser.h" | 5 #include "chrome/browser/browser.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "app/animation.h" | 10 #include "app/animation.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 183 |
184 // Need to know when to alert the user of theme install delay. | 184 // Need to know when to alert the user of theme install delay. |
185 registrar_.Add(this, NotificationType::EXTENSION_READY_FOR_INSTALL, | 185 registrar_.Add(this, NotificationType::EXTENSION_READY_FOR_INSTALL, |
186 NotificationService::AllSources()); | 186 NotificationService::AllSources()); |
187 | 187 |
188 InitCommandState(); | 188 InitCommandState(); |
189 BrowserList::AddBrowser(this); | 189 BrowserList::AddBrowser(this); |
190 | 190 |
191 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, | 191 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, |
192 profile_->GetPrefs(), NULL); | 192 profile_->GetPrefs(), NULL); |
| 193 use_vertical_tabs_.Init(prefs::kUseVerticalTabs, profile_->GetPrefs(), this); |
193 } | 194 } |
194 | 195 |
195 Browser::~Browser() { | 196 Browser::~Browser() { |
196 // The tab strip should not have any significant tabs at this point. | 197 // The tab strip should not have any significant tabs at this point. |
197 DCHECK(!tabstrip_model_.HasNonPhantomTabs()); | 198 DCHECK(!tabstrip_model_.HasNonPhantomTabs()); |
198 tabstrip_model_.RemoveObserver(this); | 199 tabstrip_model_.RemoveObserver(this); |
199 | 200 |
200 BrowserList::RemoveBrowser(this); | 201 BrowserList::RemoveBrowser(this); |
201 | 202 |
202 #if defined(OS_WIN) || defined(OS_LINUX) | 203 #if defined(OS_WIN) || defined(OS_LINUX) |
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 prefs->RegisterBooleanPref(prefs::kDeleteFormData, true); | 1515 prefs->RegisterBooleanPref(prefs::kDeleteFormData, true); |
1515 prefs->RegisterIntegerPref(prefs::kDeleteTimePeriod, 0); | 1516 prefs->RegisterIntegerPref(prefs::kDeleteTimePeriod, 0); |
1516 prefs->RegisterBooleanPref(prefs::kCheckDefaultBrowser, true); | 1517 prefs->RegisterBooleanPref(prefs::kCheckDefaultBrowser, true); |
1517 prefs->RegisterBooleanPref(prefs::kShowOmniboxSearchHint, true); | 1518 prefs->RegisterBooleanPref(prefs::kShowOmniboxSearchHint, true); |
1518 prefs->RegisterIntegerPref(prefs::kNTPPromoLineRemaining, 5); | 1519 prefs->RegisterIntegerPref(prefs::kNTPPromoLineRemaining, 5); |
1519 prefs->RegisterIntegerPref(prefs::kNTPPromoImageRemaining, 5); | 1520 prefs->RegisterIntegerPref(prefs::kNTPPromoImageRemaining, 5); |
1520 prefs->RegisterBooleanPref(prefs::kShowExtensionShelf, true); | 1521 prefs->RegisterBooleanPref(prefs::kShowExtensionShelf, true); |
1521 prefs->RegisterBooleanPref(prefs::kWebAppCreateOnDesktop, true); | 1522 prefs->RegisterBooleanPref(prefs::kWebAppCreateOnDesktop, true); |
1522 prefs->RegisterBooleanPref(prefs::kWebAppCreateInAppsMenu, true); | 1523 prefs->RegisterBooleanPref(prefs::kWebAppCreateInAppsMenu, true); |
1523 prefs->RegisterBooleanPref(prefs::kWebAppCreateInQuickLaunchBar, true); | 1524 prefs->RegisterBooleanPref(prefs::kWebAppCreateInQuickLaunchBar, true); |
1524 prefs->RegisterBooleanPref(prefs::kUseVerticalTabs, true); | 1525 prefs->RegisterBooleanPref(prefs::kUseVerticalTabs, false); |
1525 prefs->RegisterBooleanPref(prefs::kEnableTranslate, true); | 1526 prefs->RegisterBooleanPref(prefs::kEnableTranslate, true); |
1526 } | 1527 } |
1527 | 1528 |
1528 // static | 1529 // static |
1529 Browser* Browser::GetBrowserForController( | 1530 Browser* Browser::GetBrowserForController( |
1530 const NavigationController* controller, int* index_result) { | 1531 const NavigationController* controller, int* index_result) { |
1531 BrowserList::const_iterator it; | 1532 BrowserList::const_iterator it; |
1532 for (it = BrowserList::begin(); it != BrowserList::end(); ++it) { | 1533 for (it = BrowserList::begin(); it != BrowserList::end(); ++it) { |
1533 int index = (*it)->tabstrip_model_.GetIndexOfController(controller); | 1534 int index = (*it)->tabstrip_model_.GetIndexOfController(controller); |
1534 if (index != TabStripModel::kNoTab) { | 1535 if (index != TabStripModel::kNoTab) { |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1942 BookmarkEditor::EditDetails details; | 1943 BookmarkEditor::EditDetails details; |
1943 details.type = BookmarkEditor::EditDetails::NEW_FOLDER; | 1944 details.type = BookmarkEditor::EditDetails::NEW_FOLDER; |
1944 bookmark_utils::GetURLsForOpenTabs(this, &(details.urls)); | 1945 bookmark_utils::GetURLsForOpenTabs(this, &(details.urls)); |
1945 DCHECK(!details.urls.empty()); | 1946 DCHECK(!details.urls.empty()); |
1946 | 1947 |
1947 BookmarkEditor::Show(window()->GetNativeHandle(), profile_, | 1948 BookmarkEditor::Show(window()->GetNativeHandle(), profile_, |
1948 model->GetParentForNewNodes(), details, | 1949 model->GetParentForNewNodes(), details, |
1949 BookmarkEditor::SHOW_TREE, NULL); | 1950 BookmarkEditor::SHOW_TREE, NULL); |
1950 } | 1951 } |
1951 | 1952 |
| 1953 bool Browser::UseVerticalTabs() const { |
| 1954 return use_vertical_tabs_.GetValue(); |
| 1955 } |
| 1956 |
| 1957 void Browser::ToggleUseVerticalTabs() { |
| 1958 use_vertical_tabs_.SetValue(!UseVerticalTabs()); |
| 1959 window()->ToggleTabStripMode(); |
| 1960 } |
| 1961 |
1952 /////////////////////////////////////////////////////////////////////////////// | 1962 /////////////////////////////////////////////////////////////////////////////// |
1953 // Browser, TabStripModelObserver implementation: | 1963 // Browser, TabStripModelObserver implementation: |
1954 | 1964 |
1955 void Browser::TabInsertedAt(TabContents* contents, | 1965 void Browser::TabInsertedAt(TabContents* contents, |
1956 int index, | 1966 int index, |
1957 bool foreground) { | 1967 bool foreground) { |
1958 contents->set_delegate(this); | 1968 contents->set_delegate(this); |
1959 contents->controller().SetWindowID(session_id()); | 1969 contents->controller().SetWindowID(session_id()); |
1960 | 1970 |
1961 SyncHistoryWithTabs(index); | 1971 SyncHistoryWithTabs(index); |
(...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3402 return; | 3412 return; |
3403 | 3413 |
3404 ExtensionsService* extension_service = profile()->GetExtensionsService(); | 3414 ExtensionsService* extension_service = profile()->GetExtensionsService(); |
3405 if (extension_service && extension_service->is_ready()) { | 3415 if (extension_service && extension_service->is_ready()) { |
3406 Extension* extension = | 3416 Extension* extension = |
3407 extension_service->GetExtensionById(app_extension_id, false); | 3417 extension_service->GetExtensionById(app_extension_id, false); |
3408 if (extension) | 3418 if (extension) |
3409 contents->SetAppExtension(extension); | 3419 contents->SetAppExtension(extension); |
3410 } | 3420 } |
3411 } | 3421 } |
OLD | NEW |