| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "app/animation.h" | 7 #include "app/animation.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/keyboard_codes.h" | 10 #include "base/keyboard_codes.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 return; | 239 return; |
| 240 if (local_state->IsPrefRegistered(prefs::kShouldShowFirstRunBubble) && | 240 if (local_state->IsPrefRegistered(prefs::kShouldShowFirstRunBubble) && |
| 241 local_state->GetBoolean(prefs::kShouldShowFirstRunBubble)) { | 241 local_state->GetBoolean(prefs::kShouldShowFirstRunBubble)) { |
| 242 bool show_OEM_bubble = (local_state-> | 242 bool show_OEM_bubble = (local_state-> |
| 243 IsPrefRegistered(prefs::kShouldUseOEMFirstRunBubble) && | 243 IsPrefRegistered(prefs::kShouldUseOEMFirstRunBubble) && |
| 244 local_state->GetBoolean(prefs::kShouldUseOEMFirstRunBubble)); | 244 local_state->GetBoolean(prefs::kShouldUseOEMFirstRunBubble)); |
| 245 // Reset the preference so we don't show the bubble for subsequent windows. | 245 // Reset the preference so we don't show the bubble for subsequent windows. |
| 246 local_state->ClearPref(prefs::kShouldShowFirstRunBubble); | 246 local_state->ClearPref(prefs::kShouldShowFirstRunBubble); |
| 247 window_->GetLocationBar()->ShowFirstRunBubble(show_OEM_bubble); | 247 window_->GetLocationBar()->ShowFirstRunBubble(show_OEM_bubble); |
| 248 } | 248 } |
| 249 |
| 250 FindBar* find_bar = BrowserWindow::CreateFindBar(this); |
| 251 find_bar_controller_.reset(new FindBarController(find_bar)); |
| 252 find_bar->SetFindBarController(find_bar_controller_.get()); |
| 249 } | 253 } |
| 250 | 254 |
| 251 /////////////////////////////////////////////////////////////////////////////// | 255 /////////////////////////////////////////////////////////////////////////////// |
| 252 // Getters & Setters | 256 // Getters & Setters |
| 253 | 257 |
| 254 const std::vector<std::wstring>& Browser::user_data_dir_profiles() const { | 258 const std::vector<std::wstring>& Browser::user_data_dir_profiles() const { |
| 255 return g_browser_process->user_data_dir_profiles(); | 259 return g_browser_process->user_data_dir_profiles(); |
| 256 } | 260 } |
| 257 | 261 |
| 258 void Browser::set_user_data_dir_profiles( | 262 void Browser::set_user_data_dir_profiles( |
| 259 const std::vector<std::wstring>& profiles) { | 263 const std::vector<std::wstring>& profiles) { |
| 260 g_browser_process->user_data_dir_profiles() = profiles; | 264 g_browser_process->user_data_dir_profiles() = profiles; |
| 261 } | 265 } |
| 262 | 266 |
| 263 FindBarController* Browser::GetFindBarController() { | |
| 264 if (!find_bar_controller_.get()) { | |
| 265 FindBar* find_bar = BrowserWindow::CreateFindBar(this); | |
| 266 find_bar_controller_.reset(new FindBarController(find_bar)); | |
| 267 find_bar->SetFindBarController(find_bar_controller_.get()); | |
| 268 find_bar_controller_->ChangeTabContents(GetSelectedTabContents()); | |
| 269 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true); | |
| 270 } | |
| 271 return find_bar_controller_.get(); | |
| 272 } | |
| 273 | |
| 274 /////////////////////////////////////////////////////////////////////////////// | 267 /////////////////////////////////////////////////////////////////////////////// |
| 275 // Browser, Creation Helpers: | 268 // Browser, Creation Helpers: |
| 276 | 269 |
| 277 // static | 270 // static |
| 278 void Browser::OpenEmptyWindow(Profile* profile) { | 271 void Browser::OpenEmptyWindow(Profile* profile) { |
| 279 Browser* browser = Browser::Create(profile); | 272 Browser* browser = Browser::Create(profile); |
| 280 browser->AddBlankTab(true); | 273 browser->AddBlankTab(true); |
| 281 browser->window()->Show(); | 274 browser->window()->Show(); |
| 282 } | 275 } |
| 283 | 276 |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 | 928 |
| 936 TabContents* current_tab = GetSelectedTabContents(); | 929 TabContents* current_tab = GetSelectedTabContents(); |
| 937 NavigationEntry* entry = current_tab->controller().GetLastCommittedEntry(); | 930 NavigationEntry* entry = current_tab->controller().GetLastCommittedEntry(); |
| 938 if (entry) { | 931 if (entry) { |
| 939 GURL url("view-source:" + entry->url().spec()); | 932 GURL url("view-source:" + entry->url().spec()); |
| 940 OpenURL(url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); | 933 OpenURL(url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); |
| 941 } | 934 } |
| 942 } | 935 } |
| 943 | 936 |
| 944 void Browser::ShowFindBar() { | 937 void Browser::ShowFindBar() { |
| 945 GetFindBarController()->Show(); | 938 find_bar_controller_->Show(); |
| 946 } | 939 } |
| 947 | 940 |
| 948 bool Browser::SupportsWindowFeature(WindowFeature feature) const { | 941 bool Browser::SupportsWindowFeature(WindowFeature feature) const { |
| 949 unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF; | 942 unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF; |
| 950 if (type() == TYPE_NORMAL) { | 943 if (type() == TYPE_NORMAL) { |
| 951 features |= FEATURE_BOOKMARKBAR; | 944 features |= FEATURE_BOOKMARKBAR; |
| 952 features |= FEATURE_EXTENSIONSHELF; | 945 features |= FEATURE_EXTENSIONSHELF; |
| 953 } | 946 } |
| 954 if (!window_ || !window_->IsFullscreen()) { | 947 if (!window_ || !window_->IsFullscreen()) { |
| 955 if (type() == TYPE_NORMAL) | 948 if (type() == TYPE_NORMAL) |
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1758 StatusBubble* status_bubble = GetStatusBubble(); | 1751 StatusBubble* status_bubble = GetStatusBubble(); |
| 1759 if (status_bubble) { | 1752 if (status_bubble) { |
| 1760 status_bubble->Hide(); | 1753 status_bubble->Hide(); |
| 1761 | 1754 |
| 1762 // Show the loading state (if any). | 1755 // Show the loading state (if any). |
| 1763 status_bubble->SetStatus(GetSelectedTabContents()->GetStatusText()); | 1756 status_bubble->SetStatus(GetSelectedTabContents()->GetStatusText()); |
| 1764 } | 1757 } |
| 1765 | 1758 |
| 1766 if (find_bar_controller_.get()) { | 1759 if (find_bar_controller_.get()) { |
| 1767 find_bar_controller_->ChangeTabContents(new_contents); | 1760 find_bar_controller_->ChangeTabContents(new_contents); |
| 1768 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true); | 1761 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), |
| 1762 true); |
| 1769 } | 1763 } |
| 1770 | 1764 |
| 1771 // Update sessions. Don't force creation of sessions. If sessions doesn't | 1765 // Update sessions. Don't force creation of sessions. If sessions doesn't |
| 1772 // exist, the change will be picked up by sessions when created. | 1766 // exist, the change will be picked up by sessions when created. |
| 1773 if (profile_->HasSessionService()) { | 1767 if (profile_->HasSessionService()) { |
| 1774 SessionService* session_service = profile_->GetSessionService(); | 1768 SessionService* session_service = profile_->GetSessionService(); |
| 1775 if (session_service && !tabstrip_model_.closing_all()) { | 1769 if (session_service && !tabstrip_model_.closing_all()) { |
| 1776 session_service->SetSelectedTabInWindow( | 1770 session_service->SetSelectedTabInWindow( |
| 1777 session_id(), tabstrip_model_.selected_index()); | 1771 session_id(), tabstrip_model_.selected_index()); |
| 1778 } | 1772 } |
| (...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2958 /////////////////////////////////////////////////////////////////////////////// | 2952 /////////////////////////////////////////////////////////////////////////////// |
| 2959 // BrowserToolbarModel (private): | 2953 // BrowserToolbarModel (private): |
| 2960 | 2954 |
| 2961 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { | 2955 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { |
| 2962 // This |current_tab| can be NULL during the initialization of the | 2956 // This |current_tab| can be NULL during the initialization of the |
| 2963 // toolbar during window creation (i.e. before any tabs have been added | 2957 // toolbar during window creation (i.e. before any tabs have been added |
| 2964 // to the window). | 2958 // to the window). |
| 2965 TabContents* current_tab = browser_->GetSelectedTabContents(); | 2959 TabContents* current_tab = browser_->GetSelectedTabContents(); |
| 2966 return current_tab ? ¤t_tab->controller() : NULL; | 2960 return current_tab ? ¤t_tab->controller() : NULL; |
| 2967 } | 2961 } |
| OLD | NEW |