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