OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/views/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "chrome/browser/speech/extension_api/tts_extension_api.h" | 32 #include "chrome/browser/speech/extension_api/tts_extension_api.h" |
33 #include "chrome/browser/themes/theme_service.h" | 33 #include "chrome/browser/themes/theme_service.h" |
34 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 34 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
35 #include "chrome/browser/ui/browser.h" | 35 #include "chrome/browser/ui/browser.h" |
36 #include "chrome/browser/ui/browser_command_controller.h" | 36 #include "chrome/browser/ui/browser_command_controller.h" |
37 #include "chrome/browser/ui/browser_commands.h" | 37 #include "chrome/browser/ui/browser_commands.h" |
38 #include "chrome/browser/ui/browser_dialogs.h" | 38 #include "chrome/browser/ui/browser_dialogs.h" |
39 #include "chrome/browser/ui/browser_list.h" | 39 #include "chrome/browser/ui/browser_list.h" |
40 #include "chrome/browser/ui/browser_tabstrip.h" | 40 #include "chrome/browser/ui/browser_tabstrip.h" |
41 #include "chrome/browser/ui/browser_window_state.h" | 41 #include "chrome/browser/ui/browser_window_state.h" |
42 #include "chrome/browser/ui/metro_pin_tab_helper.h" | |
43 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 42 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
44 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" | 43 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" |
45 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 44 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
46 #include "chrome/browser/ui/search/search.h" | 45 #include "chrome/browser/ui/search/search.h" |
47 #include "chrome/browser/ui/search/search_model.h" | 46 #include "chrome/browser/ui/search/search_model.h" |
48 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 47 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
49 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 48 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
50 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 49 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
51 #include "chrome/browser/ui/view_ids.h" | 50 #include "chrome/browser/ui/view_ids.h" |
52 #include "chrome/browser/ui/views/accessibility/invert_bubble_view.h" | 51 #include "chrome/browser/ui/views/accessibility/invert_bubble_view.h" |
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 } | 935 } |
937 | 936 |
938 void BrowserView::UpdateReloadStopState(bool is_loading, bool force) { | 937 void BrowserView::UpdateReloadStopState(bool is_loading, bool force) { |
939 toolbar_->reload_button()->ChangeMode( | 938 toolbar_->reload_button()->ChangeMode( |
940 is_loading ? ReloadButton::MODE_STOP : ReloadButton::MODE_RELOAD, force); | 939 is_loading ? ReloadButton::MODE_STOP : ReloadButton::MODE_RELOAD, force); |
941 } | 940 } |
942 | 941 |
943 void BrowserView::UpdateToolbar(TabContents* contents, | 942 void BrowserView::UpdateToolbar(TabContents* contents, |
944 bool should_restore_state) { | 943 bool should_restore_state) { |
945 toolbar_->Update(contents->web_contents(), should_restore_state); | 944 toolbar_->Update(contents->web_contents(), should_restore_state); |
946 GetLocationBarView()->SetMetroPinnedState( | |
947 contents->metro_pin_tab_helper()->is_pinned()); | |
948 } | 945 } |
949 | 946 |
950 void BrowserView::FocusToolbar() { | 947 void BrowserView::FocusToolbar() { |
951 // Start the traversal within the main toolbar. SetPaneFocus stores | 948 // Start the traversal within the main toolbar. SetPaneFocus stores |
952 // the current focused view before changing focus. | 949 // the current focused view before changing focus. |
953 toolbar_->SetPaneFocus(NULL); | 950 toolbar_->SetPaneFocus(NULL); |
954 } | 951 } |
955 | 952 |
956 void BrowserView::FocusBookmarksToolbar() { | 953 void BrowserView::FocusBookmarksToolbar() { |
957 if (active_bookmark_bar_ && bookmark_bar_view_->visible()) | 954 if (active_bookmark_bar_ && bookmark_bar_view_->visible()) |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1408 return contents_container_; | 1405 return contents_container_; |
1409 } | 1406 } |
1410 | 1407 |
1411 ToolbarView* BrowserView::GetToolbarView() const { | 1408 ToolbarView* BrowserView::GetToolbarView() const { |
1412 return toolbar_; | 1409 return toolbar_; |
1413 } | 1410 } |
1414 | 1411 |
1415 /////////////////////////////////////////////////////////////////////////////// | 1412 /////////////////////////////////////////////////////////////////////////////// |
1416 // BrowserView, TabStripModelObserver implementation: | 1413 // BrowserView, TabStripModelObserver implementation: |
1417 | 1414 |
1418 void BrowserView::TabInsertedAt(TabContents* contents, | |
1419 int index, | |
1420 bool foreground) { | |
1421 contents->metro_pin_tab_helper()->set_observer(this); | |
1422 } | |
1423 | |
1424 void BrowserView::TabDetachedAt(TabContents* contents, int index) { | 1415 void BrowserView::TabDetachedAt(TabContents* contents, int index) { |
1425 contents->metro_pin_tab_helper()->set_observer(NULL); | |
1426 // We use index here rather than comparing |contents| because by this time | 1416 // We use index here rather than comparing |contents| because by this time |
1427 // the model has already removed |contents| from its list, so | 1417 // the model has already removed |contents| from its list, so |
1428 // browser_->GetActiveWebContents() will return NULL or something else. | 1418 // browser_->GetActiveWebContents() will return NULL or something else. |
1429 if (index == browser_->active_index()) { | 1419 if (index == browser_->active_index()) { |
1430 // We need to reset the current tab contents to NULL before it gets | 1420 // We need to reset the current tab contents to NULL before it gets |
1431 // freed. This is because the focus manager performs some operations | 1421 // freed. This is because the focus manager performs some operations |
1432 // on the selected WebContents when it is removed. | 1422 // on the selected WebContents when it is removed. |
1433 contents_container_->SetWebContents(NULL); | 1423 contents_container_->SetWebContents(NULL); |
1434 infobar_container_->ChangeTabContents(NULL); | 1424 infobar_container_->ChangeTabContents(NULL); |
1435 UpdateDevToolsForContents(NULL); | 1425 UpdateDevToolsForContents(NULL); |
(...skipping 16 matching lines...) Expand all Loading... |
1452 TabContents* new_contents, | 1442 TabContents* new_contents, |
1453 int index, | 1443 int index, |
1454 bool user_gesture) { | 1444 bool user_gesture) { |
1455 ProcessTabSelected(new_contents); | 1445 ProcessTabSelected(new_contents); |
1456 } | 1446 } |
1457 | 1447 |
1458 void BrowserView::TabReplacedAt(TabStripModel* tab_strip_model, | 1448 void BrowserView::TabReplacedAt(TabStripModel* tab_strip_model, |
1459 TabContents* old_contents, | 1449 TabContents* old_contents, |
1460 TabContents* new_contents, | 1450 TabContents* new_contents, |
1461 int index) { | 1451 int index) { |
1462 new_contents->metro_pin_tab_helper()->set_observer(this); | |
1463 | |
1464 if (index != browser_->tab_strip_model()->active_index()) | 1452 if (index != browser_->tab_strip_model()->active_index()) |
1465 return; | 1453 return; |
1466 | 1454 |
1467 if (contents_->preview_web_contents() == new_contents->web_contents()) { | 1455 if (contents_->preview_web_contents() == new_contents->web_contents()) { |
1468 // If 'preview' is becoming active, swap the 'active' and 'preview' and | 1456 // If 'preview' is becoming active, swap the 'active' and 'preview' and |
1469 // delete what was the active. | 1457 // delete what was the active. |
1470 contents_->MakePreviewContentsActiveContents(); | 1458 contents_->MakePreviewContentsActiveContents(); |
1471 views::WebView* old_container = contents_container_; | 1459 views::WebView* old_container = contents_container_; |
1472 contents_container_ = preview_container_; | 1460 contents_container_ = preview_container_; |
1473 old_container->SetWebContents(NULL); | 1461 old_container->SetWebContents(NULL); |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1877 sender->child_at(i)->InvalidateLayout(); | 1865 sender->child_at(i)->InvalidateLayout(); |
1878 SchedulePaint(); | 1866 SchedulePaint(); |
1879 Layout(); | 1867 Layout(); |
1880 return false; | 1868 return false; |
1881 } | 1869 } |
1882 | 1870 |
1883 void BrowserView::OnSysColorChange() { | 1871 void BrowserView::OnSysColorChange() { |
1884 browser::MaybeShowInvertBubbleView(browser_.get(), contents_); | 1872 browser::MaybeShowInvertBubbleView(browser_.get(), contents_); |
1885 } | 1873 } |
1886 | 1874 |
1887 void BrowserView::MetroPinnedStateChanged(content::WebContents* contents, | |
1888 bool is_pinned) { | |
1889 if (contents == chrome::GetActiveWebContents(browser())) | |
1890 GetLocationBarView()->SetMetroPinnedState(is_pinned); | |
1891 } | |
1892 | |
1893 int BrowserView::GetOTRIconResourceID() const { | 1875 int BrowserView::GetOTRIconResourceID() const { |
1894 int otr_resource_id = IDR_OTR_ICON; | 1876 int otr_resource_id = IDR_OTR_ICON; |
1895 if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) { | 1877 if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) { |
1896 if (IsFullscreen()) | 1878 if (IsFullscreen()) |
1897 otr_resource_id = IDR_OTR_ICON_FULLSCREEN; | 1879 otr_resource_id = IDR_OTR_ICON_FULLSCREEN; |
1898 #if defined(OS_WIN) && !defined(USE_AURA) | 1880 #if defined(OS_WIN) && !defined(USE_AURA) |
1899 if (base::win::IsMetroProcess()) | 1881 if (base::win::IsMetroProcess()) |
1900 otr_resource_id = IDR_OTR_ICON_FULLSCREEN; | 1882 otr_resource_id = IDR_OTR_ICON_FULLSCREEN; |
1901 #endif | 1883 #endif |
1902 } | 1884 } |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2602 if (contents && contents->GetContentNativeView() && | 2584 if (contents && contents->GetContentNativeView() && |
2603 contents->GetContentNativeView()->HasFocus()) { | 2585 contents->GetContentNativeView()->HasFocus()) { |
2604 (contents->GetRenderViewHost()->*method)(); | 2586 (contents->GetRenderViewHost()->*method)(); |
2605 return true; | 2587 return true; |
2606 } | 2588 } |
2607 #elif defined(OS_WIN) | 2589 #elif defined(OS_WIN) |
2608 // TODO(yusukes): Support non-Aura Windows. | 2590 // TODO(yusukes): Support non-Aura Windows. |
2609 #endif | 2591 #endif |
2610 return false; | 2592 return false; |
2611 } | 2593 } |
OLD | NEW |