| 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/views/frame/browser_view.h" | 5 #include "chrome/browser/views/frame/browser_view.h" |
| 6 | 6 |
| 7 #if defined(OS_LINUX) | 7 #if defined(OS_LINUX) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include "app/l10n_util.h" | 11 #include "app/l10n_util.h" |
| 12 #include "app/resource_bundle.h" | 12 #include "app/resource_bundle.h" |
| 13 #include "base/command_line.h" |
| 13 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
| 14 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
| 15 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/app/chrome_dll_resource.h" | 17 #include "chrome/app/chrome_dll_resource.h" |
| 17 #include "chrome/browser/app_modal_dialog_queue.h" | 18 #include "chrome/browser/app_modal_dialog_queue.h" |
| 18 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 19 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| 19 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" | 20 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" |
| 20 #include "chrome/browser/automation/ui_controls.h" | 21 #include "chrome/browser/automation/ui_controls.h" |
| 21 #include "chrome/browser/bookmarks/bookmark_utils.h" | 22 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 22 #include "chrome/browser/browser_list.h" | 23 #include "chrome/browser/browser_list.h" |
| 23 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| 24 #include "chrome/browser/browser_theme_provider.h" | 25 #include "chrome/browser/browser_theme_provider.h" |
| 25 #include "chrome/browser/debugger/devtools_window.h" | 26 #include "chrome/browser/debugger/devtools_window.h" |
| 26 #include "chrome/browser/download/download_manager.h" | 27 #include "chrome/browser/download/download_manager.h" |
| 27 #include "chrome/browser/ntp_background_util.h" | 28 #include "chrome/browser/ntp_background_util.h" |
| 28 #include "chrome/browser/page_info_window.h" | 29 #include "chrome/browser/page_info_window.h" |
| 29 #include "chrome/browser/pref_service.h" | 30 #include "chrome/browser/pref_service.h" |
| 30 #include "chrome/browser/profile.h" | 31 #include "chrome/browser/profile.h" |
| 31 #include "chrome/browser/sessions/tab_restore_service.h" | 32 #include "chrome/browser/sessions/tab_restore_service.h" |
| 32 #include "chrome/browser/tab_contents/match_preview.h" | 33 #include "chrome/browser/tab_contents/match_preview.h" |
| 33 #include "chrome/browser/tab_contents/tab_contents.h" | 34 #include "chrome/browser/tab_contents/tab_contents.h" |
| 34 #include "chrome/browser/tab_contents/tab_contents_view.h" | 35 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 35 #include "chrome/browser/view_ids.h" | 36 #include "chrome/browser/view_ids.h" |
| 36 #include "chrome/browser/views/accessible_view_helper.h" | 37 #include "chrome/browser/views/accessible_view_helper.h" |
| 37 #include "chrome/browser/views/bookmark_bar_view.h" | 38 #include "chrome/browser/views/bookmark_bar_view.h" |
| 38 #include "chrome/browser/views/browser_dialogs.h" | 39 #include "chrome/browser/views/browser_dialogs.h" |
| 39 #include "chrome/browser/views/download_shelf_view.h" | 40 #include "chrome/browser/views/download_shelf_view.h" |
| 40 #include "chrome/browser/views/extensions/extension_shelf.h" | |
| 41 #include "chrome/browser/views/frame/browser_view_layout.h" | 41 #include "chrome/browser/views/frame/browser_view_layout.h" |
| 42 #include "chrome/browser/views/fullscreen_exit_bubble.h" | 42 #include "chrome/browser/views/fullscreen_exit_bubble.h" |
| 43 #include "chrome/browser/views/status_bubble_views.h" | 43 #include "chrome/browser/views/status_bubble_views.h" |
| 44 #include "chrome/browser/views/tab_contents/tab_contents_container.h" | 44 #include "chrome/browser/views/tab_contents/tab_contents_container.h" |
| 45 #include "chrome/browser/views/tabs/browser_tab_strip_controller.h" | 45 #include "chrome/browser/views/tabs/browser_tab_strip_controller.h" |
| 46 #include "chrome/browser/views/tabs/side_tab_strip.h" | 46 #include "chrome/browser/views/tabs/side_tab_strip.h" |
| 47 #include "chrome/browser/views/theme_install_bubble_view.h" | 47 #include "chrome/browser/views/theme_install_bubble_view.h" |
| 48 #include "chrome/browser/views/toolbar_view.h" | 48 #include "chrome/browser/views/toolbar_view.h" |
| 49 #include "chrome/browser/views/update_recommended_message_box.h" | 49 #include "chrome/browser/views/update_recommended_message_box.h" |
| 50 #include "chrome/browser/window_sizer.h" | 50 #include "chrome/browser/window_sizer.h" |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 active_bookmark_bar_(NULL), | 481 active_bookmark_bar_(NULL), |
| 482 tabstrip_(NULL), | 482 tabstrip_(NULL), |
| 483 toolbar_(NULL), | 483 toolbar_(NULL), |
| 484 infobar_container_(NULL), | 484 infobar_container_(NULL), |
| 485 contents_container_(NULL), | 485 contents_container_(NULL), |
| 486 devtools_container_(NULL), | 486 devtools_container_(NULL), |
| 487 preview_container_(NULL), | 487 preview_container_(NULL), |
| 488 contents_(NULL), | 488 contents_(NULL), |
| 489 contents_split_(NULL), | 489 contents_split_(NULL), |
| 490 initialized_(false), | 490 initialized_(false), |
| 491 ignore_layout_(true), | 491 ignore_layout_(true) |
| 492 #if defined(OS_WIN) | 492 #if defined(OS_WIN) |
| 493 hung_window_detector_(&hung_plugin_action_), | 493 ,hung_window_detector_(&hung_plugin_action_), |
| 494 ticker_(0), | 494 ticker_(0) |
| 495 #endif | 495 #endif |
| 496 extension_shelf_(NULL) { | 496 { |
| 497 browser_->tabstrip_model()->AddObserver(this); | 497 browser_->tabstrip_model()->AddObserver(this); |
| 498 } | 498 } |
| 499 | 499 |
| 500 BrowserView::~BrowserView() { | 500 BrowserView::~BrowserView() { |
| 501 browser_->tabstrip_model()->RemoveObserver(this); | 501 browser_->tabstrip_model()->RemoveObserver(this); |
| 502 | 502 |
| 503 #if defined(OS_WIN) | 503 #if defined(OS_WIN) |
| 504 // Remove this observer. | 504 // Remove this observer. |
| 505 if (aeropeek_manager_.get()) | 505 if (aeropeek_manager_.get()) |
| 506 browser_->tabstrip_model()->RemoveObserver(aeropeek_manager_.get()); | 506 browser_->tabstrip_model()->RemoveObserver(aeropeek_manager_.get()); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 if (is_animating) { | 800 if (is_animating) { |
| 801 contents_container_->SetFastResize(true); | 801 contents_container_->SetFastResize(true); |
| 802 UpdateUIForContents(browser_->GetSelectedTabContents()); | 802 UpdateUIForContents(browser_->GetSelectedTabContents()); |
| 803 contents_container_->SetFastResize(false); | 803 contents_container_->SetFastResize(false); |
| 804 } else { | 804 } else { |
| 805 UpdateUIForContents(browser_->GetSelectedTabContents()); | 805 UpdateUIForContents(browser_->GetSelectedTabContents()); |
| 806 contents_split_->Layout(); | 806 contents_split_->Layout(); |
| 807 } | 807 } |
| 808 } | 808 } |
| 809 | 809 |
| 810 void BrowserView::SelectedTabExtensionShelfSizeChanged() { | |
| 811 Layout(); | |
| 812 } | |
| 813 | |
| 814 void BrowserView::UpdateTitleBar() { | 810 void BrowserView::UpdateTitleBar() { |
| 815 frame_->GetWindow()->UpdateWindowTitle(); | 811 frame_->GetWindow()->UpdateWindowTitle(); |
| 816 if (ShouldShowWindowIcon() && !loading_animation_timer_.IsRunning()) | 812 if (ShouldShowWindowIcon() && !loading_animation_timer_.IsRunning()) |
| 817 frame_->GetWindow()->UpdateWindowIcon(); | 813 frame_->GetWindow()->UpdateWindowIcon(); |
| 818 } | 814 } |
| 819 | 815 |
| 820 void BrowserView::ShelfVisibilityChanged() { | 816 void BrowserView::ShelfVisibilityChanged() { |
| 821 Layout(); | 817 Layout(); |
| 822 } | 818 } |
| 823 | 819 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 void BrowserView::ConfirmAddSearchProvider(const TemplateURL* template_url, | 1057 void BrowserView::ConfirmAddSearchProvider(const TemplateURL* template_url, |
| 1062 Profile* profile) { | 1058 Profile* profile) { |
| 1063 browser::EditSearchEngine(GetWindow()->GetNativeWindow(), template_url, NULL, | 1059 browser::EditSearchEngine(GetWindow()->GetNativeWindow(), template_url, NULL, |
| 1064 profile); | 1060 profile); |
| 1065 } | 1061 } |
| 1066 | 1062 |
| 1067 void BrowserView::ToggleBookmarkBar() { | 1063 void BrowserView::ToggleBookmarkBar() { |
| 1068 bookmark_utils::ToggleWhenVisible(browser_->profile()); | 1064 bookmark_utils::ToggleWhenVisible(browser_->profile()); |
| 1069 } | 1065 } |
| 1070 | 1066 |
| 1071 void BrowserView::ToggleExtensionShelf() { | |
| 1072 ExtensionShelf::ToggleWhenExtensionShelfVisible(browser_->profile()); | |
| 1073 } | |
| 1074 | |
| 1075 views::Window* BrowserView::ShowAboutChromeDialog() { | 1067 views::Window* BrowserView::ShowAboutChromeDialog() { |
| 1076 return browser::ShowAboutChromeView(GetWindow()->GetNativeWindow(), | 1068 return browser::ShowAboutChromeView(GetWindow()->GetNativeWindow(), |
| 1077 browser_->profile()); | 1069 browser_->profile()); |
| 1078 } | 1070 } |
| 1079 | 1071 |
| 1080 void BrowserView::ShowUpdateChromeDialog() { | 1072 void BrowserView::ShowUpdateChromeDialog() { |
| 1081 #if defined(OS_WIN) | 1073 #if defined(OS_WIN) |
| 1082 UpdateRecommendedMessageBox::ShowMessageBox(GetWindow()->GetNativeWindow()); | 1074 UpdateRecommendedMessageBox::ShowMessageBox(GetWindow()->GetNativeWindow()); |
| 1083 #endif | 1075 #endif |
| 1084 } | 1076 } |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1865 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_WEB_CONTENTS)); | 1857 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_WEB_CONTENTS)); |
| 1866 SkColor bg_color = GetWidget()->GetThemeProvider()-> | 1858 SkColor bg_color = GetWidget()->GetThemeProvider()-> |
| 1867 GetColor(BrowserThemeProvider::COLOR_TOOLBAR); | 1859 GetColor(BrowserThemeProvider::COLOR_TOOLBAR); |
| 1868 contents_split_->set_background( | 1860 contents_split_->set_background( |
| 1869 views::Background::CreateSolidBackground(bg_color)); | 1861 views::Background::CreateSolidBackground(bg_color)); |
| 1870 AddChildView(contents_split_); | 1862 AddChildView(contents_split_); |
| 1871 set_contents_view(contents_split_); | 1863 set_contents_view(contents_split_); |
| 1872 | 1864 |
| 1873 status_bubble_.reset(new StatusBubbleViews(GetWidget())); | 1865 status_bubble_.reset(new StatusBubbleViews(GetWidget())); |
| 1874 | 1866 |
| 1875 if (browser_->SupportsWindowFeature(Browser::FEATURE_EXTENSIONSHELF)) { | |
| 1876 extension_shelf_ = new ExtensionShelf(browser_.get()); | |
| 1877 extension_shelf_->set_background( | |
| 1878 new BookmarkExtensionBackground(this, extension_shelf_, | |
| 1879 browser_.get())); | |
| 1880 extension_shelf_-> | |
| 1881 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_EXTENSIONS)); | |
| 1882 AddChildView(extension_shelf_); | |
| 1883 } | |
| 1884 | |
| 1885 #if defined(OS_WIN) | 1867 #if defined(OS_WIN) |
| 1886 InitSystemMenu(); | 1868 InitSystemMenu(); |
| 1887 | 1869 |
| 1888 // Create a custom JumpList and add it to an observer of TabRestoreService | 1870 // Create a custom JumpList and add it to an observer of TabRestoreService |
| 1889 // so we can update the custom JumpList when a tab is added or removed. | 1871 // so we can update the custom JumpList when a tab is added or removed. |
| 1890 if (JumpList::Enabled()) { | 1872 if (JumpList::Enabled()) { |
| 1891 jumplist_.reset(new JumpList); | 1873 jumplist_.reset(new JumpList); |
| 1892 jumplist_->AddObserver(browser_->profile()); | 1874 jumplist_->AddObserver(browser_->profile()); |
| 1893 } | 1875 } |
| 1894 | 1876 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2106 #endif | 2088 #endif |
| 2107 } | 2089 } |
| 2108 #if defined(OS_WIN) | 2090 #if defined(OS_WIN) |
| 2109 frame_->GetWindow()->PushForceHidden(); | 2091 frame_->GetWindow()->PushForceHidden(); |
| 2110 #endif | 2092 #endif |
| 2111 | 2093 |
| 2112 // Notify bookmark bar, so it can set itself to the appropriate drawing state. | 2094 // Notify bookmark bar, so it can set itself to the appropriate drawing state. |
| 2113 if (bookmark_bar_view_.get()) | 2095 if (bookmark_bar_view_.get()) |
| 2114 bookmark_bar_view_->OnFullscreenToggled(fullscreen); | 2096 bookmark_bar_view_->OnFullscreenToggled(fullscreen); |
| 2115 | 2097 |
| 2116 // Notify extension shelf, so it can set itself to the appropriate drawing | |
| 2117 // state. | |
| 2118 if (extension_shelf_) | |
| 2119 extension_shelf_->OnFullscreenToggled(fullscreen); | |
| 2120 | |
| 2121 // Toggle fullscreen mode. | 2098 // Toggle fullscreen mode. |
| 2122 #if defined(OS_WIN) | 2099 #if defined(OS_WIN) |
| 2123 frame_->GetWindow()->SetFullscreen(fullscreen); | 2100 frame_->GetWindow()->SetFullscreen(fullscreen); |
| 2124 #endif // No need to invoke SetFullscreen for linux as this code is executed | 2101 #endif // No need to invoke SetFullscreen for linux as this code is executed |
| 2125 // once we're already fullscreen on linux. | 2102 // once we're already fullscreen on linux. |
| 2126 | 2103 |
| 2127 #if defined(OS_LINUX) | 2104 #if defined(OS_LINUX) |
| 2128 // Updating of commands for fullscreen mode is called from SetFullScreen on | 2105 // Updating of commands for fullscreen mode is called from SetFullScreen on |
| 2129 // Wndows (see just above), but for ChromeOS, this method (ProcessFullScreen) | 2106 // Wndows (see just above), but for ChromeOS, this method (ProcessFullScreen) |
| 2130 // is called after full screen has happened successfully (via GTK's | 2107 // is called after full screen has happened successfully (via GTK's |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2401 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); | 2378 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); |
| 2402 | 2379 |
| 2403 return view; | 2380 return view; |
| 2404 } | 2381 } |
| 2405 #endif | 2382 #endif |
| 2406 | 2383 |
| 2407 // static | 2384 // static |
| 2408 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 2385 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
| 2409 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 2386 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
| 2410 } | 2387 } |
| OLD | NEW |