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

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

Issue 39158: Take two at hooking up title bar on linux. (Closed)
Patch Set: rebase Created 11 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/gtk/browser_window_gtk.cc » ('j') | 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-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/idle_timer.h" 8 #include "base/idle_timer.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 20 matching lines...) Expand all
31 #include "chrome/common/chrome_constants.h" 31 #include "chrome/common/chrome_constants.h"
32 #include "chrome/common/chrome_switches.h" 32 #include "chrome/common/chrome_switches.h"
33 #include "chrome/common/l10n_util.h" 33 #include "chrome/common/l10n_util.h"
34 #include "chrome/common/notification_service.h" 34 #include "chrome/common/notification_service.h"
35 #include "chrome/common/page_transition_types.h" 35 #include "chrome/common/page_transition_types.h"
36 #include "chrome/common/pref_names.h" 36 #include "chrome/common/pref_names.h"
37 #include "chrome/common/pref_service.h" 37 #include "chrome/common/pref_service.h"
38 #ifdef CHROME_PERSONALIZATION 38 #ifdef CHROME_PERSONALIZATION
39 #include "chrome/personalization/personalization.h" 39 #include "chrome/personalization/personalization.h"
40 #endif 40 #endif
41 #include "grit/chromium_strings.h"
42 #include "grit/generated_resources.h"
43 #include "grit/locale_settings.h"
41 #include "net/base/cookie_monster.h" 44 #include "net/base/cookie_monster.h"
42 #include "net/base/cookie_policy.h" 45 #include "net/base/cookie_policy.h"
43 #include "net/base/net_util.h" 46 #include "net/base/net_util.h"
44 #include "net/base/registry_controlled_domain.h" 47 #include "net/base/registry_controlled_domain.h"
45 #include "net/url_request/url_request_context.h" 48 #include "net/url_request/url_request_context.h"
46 #include "webkit/glue/window_open_disposition.h" 49 #include "webkit/glue/window_open_disposition.h"
47 50
48 #if defined(OS_WIN) 51 #if defined(OS_WIN)
49 #include <windows.h> 52 #include <windows.h>
50 #include <shellapi.h> 53 #include <shellapi.h>
(...skipping 11 matching lines...) Expand all
62 #include "chrome/browser/options_window.h" 65 #include "chrome/browser/options_window.h"
63 #include "chrome/browser/ssl/ssl_error_info.h" 66 #include "chrome/browser/ssl/ssl_error_info.h"
64 #include "chrome/browser/tab_contents/web_contents_view.h" 67 #include "chrome/browser/tab_contents/web_contents_view.h"
65 #include "chrome/browser/task_manager.h" 68 #include "chrome/browser/task_manager.h"
66 #include "chrome/browser/user_data_manager.h" 69 #include "chrome/browser/user_data_manager.h"
67 #include "chrome/browser/view_ids.h" 70 #include "chrome/browser/view_ids.h"
68 #include "chrome/browser/views/location_bar_view.h" 71 #include "chrome/browser/views/location_bar_view.h"
69 #include "chrome/browser/window_sizer.h" 72 #include "chrome/browser/window_sizer.h"
70 #include "chrome/common/child_process_host.h" 73 #include "chrome/common/child_process_host.h"
71 #include "chrome/common/win_util.h" 74 #include "chrome/common/win_util.h"
72 #include "grit/chromium_strings.h"
73 #include "grit/generated_resources.h"
74 #include "grit/locale_settings.h"
75 75
76 #endif // OS_WIN 76 #endif // OS_WIN
77 77
78 using base::TimeDelta; 78 using base::TimeDelta;
79 79
80 // How long we wait before updating the browser chrome while loading a page. 80 // How long we wait before updating the browser chrome while loading a page.
81 static const int kUIUpdateCoalescingTimeMS = 200; 81 static const int kUIUpdateCoalescingTimeMS = 200;
82 82
83 // Idle time before helping prune memory consumption. 83 // Idle time before helping prune memory consumption.
84 static const int kBrowserReleaseMemoryInterval = 30; // In seconds. 84 static const int kBrowserReleaseMemoryInterval = 30; // In seconds.
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 } 384 }
385 385
386 SkBitmap Browser::GetCurrentPageIcon() const { 386 SkBitmap Browser::GetCurrentPageIcon() const {
387 TabContents* contents = GetSelectedTabContents(); 387 TabContents* contents = GetSelectedTabContents();
388 // |contents| can be NULL since GetCurrentPageIcon() is called by the window 388 // |contents| can be NULL since GetCurrentPageIcon() is called by the window
389 // during the window's creation (before tabs have been added). 389 // during the window's creation (before tabs have been added).
390 return contents ? contents->GetFavIcon() : SkBitmap(); 390 return contents ? contents->GetFavIcon() : SkBitmap();
391 } 391 }
392 392
393 std::wstring Browser::GetCurrentPageTitle() const { 393 std::wstring Browser::GetCurrentPageTitle() const {
394 #if defined(OS_WIN)
395 TabContents* contents = tabstrip_model_.GetSelectedTabContents(); 394 TabContents* contents = tabstrip_model_.GetSelectedTabContents();
396 std::wstring title; 395 std::wstring title;
397 396
398 // |contents| can be NULL because GetCurrentPageTitle is called by the window 397 // |contents| can be NULL because GetCurrentPageTitle is called by the window
399 // during the window's creation (before tabs have been added). 398 // during the window's creation (before tabs have been added).
400 if (contents) { 399 if (contents) {
401 title = UTF16ToWideHack(contents->GetTitle()); 400 title = UTF16ToWideHack(contents->GetTitle());
402 FormatTitleForDisplay(&title); 401 FormatTitleForDisplay(&title);
403 } 402 }
404 if (title.empty()) 403 if (title.empty())
405 title = l10n_util::GetString(IDS_TAB_UNTITLED_TITLE); 404 title = l10n_util::GetString(IDS_TAB_UNTITLED_TITLE);
406 405
407 return l10n_util::GetStringF(IDS_BROWSER_WINDOW_TITLE_FORMAT, title); 406 return l10n_util::GetStringF(IDS_BROWSER_WINDOW_TITLE_FORMAT, title);
408 #elif defined(OS_POSIX)
409 // TODO(port): turn on when generating chrome_strings.h from grit
410 return L"untitled";
411 #endif
412 } 407 }
413 408
414 // static 409 // static
415 void Browser::FormatTitleForDisplay(std::wstring* title) { 410 void Browser::FormatTitleForDisplay(std::wstring* title) {
416 size_t current_index = 0; 411 size_t current_index = 0;
417 size_t match_index; 412 size_t match_index;
418 while ((match_index = title->find(L'\n', current_index)) != 413 while ((match_index = title->find(L'\n', current_index)) !=
419 std::wstring::npos) { 414 std::wstring::npos) {
420 title->replace(match_index, 1, L""); 415 title->replace(match_index, 1, L"");
421 current_index = match_index; 416 current_index = match_index;
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 UserMetrics::RecordAction(L"ViewSource", profile_); 750 UserMetrics::RecordAction(L"ViewSource", profile_);
756 751
757 TabContents* current_tab = GetSelectedTabContents(); 752 TabContents* current_tab = GetSelectedTabContents();
758 NavigationEntry* entry = current_tab->controller()->GetLastCommittedEntry(); 753 NavigationEntry* entry = current_tab->controller()->GetLastCommittedEntry();
759 if (entry) { 754 if (entry) {
760 GURL url("view-source:" + entry->url().spec()); 755 GURL url("view-source:" + entry->url().spec());
761 OpenURL(url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); 756 OpenURL(url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK);
762 } 757 }
763 } 758 }
764 759
760 bool Browser::SupportsWindowFeature(WindowFeature feature) const {
761 unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF;
762 if (type() == TYPE_NORMAL)
763 features |= FEATURE_BOOKMARKBAR;
764 if (!window_ || !window_->IsFullscreen()) {
765 if (type() == TYPE_NORMAL)
766 features |= FEATURE_TABSTRIP | FEATURE_TOOLBAR;
767 else
768 features |= FEATURE_TITLEBAR;
769 if ((type() & Browser::TYPE_APP) == 0)
770 features |= FEATURE_LOCATIONBAR;
771 }
772 return !!(features & feature);
773 }
774
765 #if defined(OS_WIN) 775 #if defined(OS_WIN)
766 776
767 void Browser::ClosePopups() { 777 void Browser::ClosePopups() {
768 UserMetrics::RecordAction(L"CloseAllSuppressedPopups", profile_); 778 UserMetrics::RecordAction(L"CloseAllSuppressedPopups", profile_);
769 GetSelectedTabContents()->CloseAllSuppressedPopups(); 779 GetSelectedTabContents()->CloseAllSuppressedPopups();
770 } 780 }
771 781
772 void Browser::Print() { 782 void Browser::Print() {
773 UserMetrics::RecordAction(L"PrintPreview", profile_); 783 UserMetrics::RecordAction(L"PrintPreview", profile_);
774 GetSelectedTabContents()->AsWebContents()->PrintPreview(); 784 GetSelectedTabContents()->AsWebContents()->PrintPreview();
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 void Browser::OpenBookmarkManager() { 980 void Browser::OpenBookmarkManager() {
971 UserMetrics::RecordAction(L"ShowBookmarkManager", profile_); 981 UserMetrics::RecordAction(L"ShowBookmarkManager", profile_);
972 window_->ShowBookmarkManager(); 982 window_->ShowBookmarkManager();
973 } 983 }
974 984
975 void Browser::ShowDownloadsTab() { 985 void Browser::ShowDownloadsTab() {
976 UserMetrics::RecordAction(L"ShowDownloads", profile_); 986 UserMetrics::RecordAction(L"ShowDownloads", profile_);
977 ShowSingleDOMUITab(DownloadsUI::GetBaseURL()); 987 ShowSingleDOMUITab(DownloadsUI::GetBaseURL());
978 } 988 }
979 989
980 bool Browser::SupportsWindowFeature(WindowFeature feature) const {
981 unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF;
982 if (type() == TYPE_NORMAL)
983 features |= FEATURE_BOOKMARKBAR;
984 if (!window_ || !window_->IsFullscreen()) {
985 if (type() == TYPE_NORMAL)
986 features |= FEATURE_TABSTRIP | FEATURE_TOOLBAR;
987 else
988 features |= FEATURE_TITLEBAR;
989 if ((type() & Browser::TYPE_APP) == 0)
990 features |= FEATURE_LOCATIONBAR;
991 }
992 return !!(features & feature);
993 }
994
995 void Browser::OpenClearBrowsingDataDialog() { 990 void Browser::OpenClearBrowsingDataDialog() {
996 UserMetrics::RecordAction(L"ClearBrowsingData_ShowDlg", profile_); 991 UserMetrics::RecordAction(L"ClearBrowsingData_ShowDlg", profile_);
997 window_->ShowClearBrowsingDataDialog(); 992 window_->ShowClearBrowsingDataDialog();
998 } 993 }
999 994
1000 void Browser::OpenImportSettingsDialog() { 995 void Browser::OpenImportSettingsDialog() {
1001 UserMetrics::RecordAction(L"Import_ShowDlg", profile_); 996 UserMetrics::RecordAction(L"Import_ShowDlg", profile_);
1002 window_->ShowImportDialog(); 997 window_->ShowImportDialog();
1003 } 998 }
1004 999
(...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after
2453 2448
2454 // We need to register the window position pref. 2449 // We need to register the window position pref.
2455 std::wstring window_pref(prefs::kBrowserWindowPlacement); 2450 std::wstring window_pref(prefs::kBrowserWindowPlacement);
2456 window_pref.append(L"_"); 2451 window_pref.append(L"_");
2457 window_pref.append(app_name); 2452 window_pref.append(app_name);
2458 PrefService* prefs = g_browser_process->local_state(); 2453 PrefService* prefs = g_browser_process->local_state();
2459 DCHECK(prefs); 2454 DCHECK(prefs);
2460 2455
2461 prefs->RegisterDictionaryPref(window_pref.c_str()); 2456 prefs->RegisterDictionaryPref(window_pref.c_str());
2462 } 2457 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/gtk/browser_window_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698