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

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

Issue 334019: Lazily create the find bar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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/browser.h ('k') | no next file » | 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) 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
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());
253 } 249 }
254 250
255 /////////////////////////////////////////////////////////////////////////////// 251 ///////////////////////////////////////////////////////////////////////////////
256 // Getters & Setters 252 // Getters & Setters
257 253
258 const std::vector<std::wstring>& Browser::user_data_dir_profiles() const { 254 const std::vector<std::wstring>& Browser::user_data_dir_profiles() const {
259 return g_browser_process->user_data_dir_profiles(); 255 return g_browser_process->user_data_dir_profiles();
260 } 256 }
261 257
262 void Browser::set_user_data_dir_profiles( 258 void Browser::set_user_data_dir_profiles(
263 const std::vector<std::wstring>& profiles) { 259 const std::vector<std::wstring>& profiles) {
264 g_browser_process->user_data_dir_profiles() = profiles; 260 g_browser_process->user_data_dir_profiles() = profiles;
265 } 261 }
266 262
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
267 /////////////////////////////////////////////////////////////////////////////// 274 ///////////////////////////////////////////////////////////////////////////////
268 // Browser, Creation Helpers: 275 // Browser, Creation Helpers:
269 276
270 // static 277 // static
271 void Browser::OpenEmptyWindow(Profile* profile) { 278 void Browser::OpenEmptyWindow(Profile* profile) {
272 Browser* browser = Browser::Create(profile); 279 Browser* browser = Browser::Create(profile);
273 browser->AddBlankTab(true); 280 browser->AddBlankTab(true);
274 browser->window()->Show(); 281 browser->window()->Show();
275 } 282 }
276 283
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 944
938 TabContents* current_tab = GetSelectedTabContents(); 945 TabContents* current_tab = GetSelectedTabContents();
939 NavigationEntry* entry = current_tab->controller().GetLastCommittedEntry(); 946 NavigationEntry* entry = current_tab->controller().GetLastCommittedEntry();
940 if (entry) { 947 if (entry) {
941 GURL url("view-source:" + entry->url().spec()); 948 GURL url("view-source:" + entry->url().spec());
942 OpenURL(url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); 949 OpenURL(url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK);
943 } 950 }
944 } 951 }
945 952
946 void Browser::ShowFindBar() { 953 void Browser::ShowFindBar() {
947 find_bar_controller_->Show(); 954 GetFindBarController()->Show();
948 } 955 }
949 956
950 bool Browser::SupportsWindowFeature(WindowFeature feature) const { 957 bool Browser::SupportsWindowFeature(WindowFeature feature) const {
951 unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF; 958 unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF;
952 if (type() == TYPE_NORMAL) { 959 if (type() == TYPE_NORMAL) {
953 features |= FEATURE_BOOKMARKBAR; 960 features |= FEATURE_BOOKMARKBAR;
954 features |= FEATURE_EXTENSIONSHELF; 961 features |= FEATURE_EXTENSIONSHELF;
955 } 962 }
956 if (!window_ || !window_->IsFullscreen()) { 963 if (!window_ || !window_->IsFullscreen()) {
957 if (type() == TYPE_NORMAL) 964 if (type() == TYPE_NORMAL)
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 StatusBubble* status_bubble = GetStatusBubble(); 1772 StatusBubble* status_bubble = GetStatusBubble();
1766 if (status_bubble) { 1773 if (status_bubble) {
1767 status_bubble->Hide(); 1774 status_bubble->Hide();
1768 1775
1769 // Show the loading state (if any). 1776 // Show the loading state (if any).
1770 status_bubble->SetStatus(GetSelectedTabContents()->GetStatusText()); 1777 status_bubble->SetStatus(GetSelectedTabContents()->GetStatusText());
1771 } 1778 }
1772 1779
1773 if (find_bar_controller_.get()) { 1780 if (find_bar_controller_.get()) {
1774 find_bar_controller_->ChangeTabContents(new_contents); 1781 find_bar_controller_->ChangeTabContents(new_contents);
1775 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), 1782 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true);
1776 true);
1777 } 1783 }
1778 1784
1779 // Update sessions. Don't force creation of sessions. If sessions doesn't 1785 // Update sessions. Don't force creation of sessions. If sessions doesn't
1780 // exist, the change will be picked up by sessions when created. 1786 // exist, the change will be picked up by sessions when created.
1781 if (profile_->HasSessionService()) { 1787 if (profile_->HasSessionService()) {
1782 SessionService* session_service = profile_->GetSessionService(); 1788 SessionService* session_service = profile_->GetSessionService();
1783 if (session_service && !tabstrip_model_.closing_all()) { 1789 if (session_service && !tabstrip_model_.closing_all()) {
1784 session_service->SetSelectedTabInWindow( 1790 session_service->SetSelectedTabInWindow(
1785 session_id(), tabstrip_model_.selected_index()); 1791 session_id(), tabstrip_model_.selected_index());
1786 } 1792 }
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after
2969 /////////////////////////////////////////////////////////////////////////////// 2975 ///////////////////////////////////////////////////////////////////////////////
2970 // BrowserToolbarModel (private): 2976 // BrowserToolbarModel (private):
2971 2977
2972 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { 2978 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() {
2973 // This |current_tab| can be NULL during the initialization of the 2979 // This |current_tab| can be NULL during the initialization of the
2974 // toolbar during window creation (i.e. before any tabs have been added 2980 // toolbar during window creation (i.e. before any tabs have been added
2975 // to the window). 2981 // to the window).
2976 TabContents* current_tab = browser_->GetSelectedTabContents(); 2982 TabContents* current_tab = browser_->GetSelectedTabContents();
2977 return current_tab ? &current_tab->controller() : NULL; 2983 return current_tab ? &current_tab->controller() : NULL;
2978 } 2984 }
OLDNEW
« no previous file with comments | « chrome/browser/browser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698