| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #endif // defined(OS_WIN) | 10 #endif // defined(OS_WIN) |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 if (OkToCloseWithInProgressDownloads(&num_downloads) == | 542 if (OkToCloseWithInProgressDownloads(&num_downloads) == |
| 543 DOWNLOAD_CLOSE_BROWSER_SHUTDOWN && | 543 DOWNLOAD_CLOSE_BROWSER_SHUTDOWN && |
| 544 !browser_defaults::kBrowserAliveWithNoWindows) { | 544 !browser_defaults::kBrowserAliveWithNoWindows) { |
| 545 DownloadService::CancelAllDownloads(); | 545 DownloadService::CancelAllDownloads(); |
| 546 } | 546 } |
| 547 } | 547 } |
| 548 | 548 |
| 549 /////////////////////////////////////////////////////////////////////////////// | 549 /////////////////////////////////////////////////////////////////////////////// |
| 550 // Getters & Setters | 550 // Getters & Setters |
| 551 | 551 |
| 552 ChromeBubbleManager* Browser::GetBubbleManager() { |
| 553 if (!bubble_manager_) |
| 554 bubble_manager_.reset(new ChromeBubbleManager); |
| 555 return bubble_manager_.get(); |
| 556 } |
| 557 |
| 552 FindBarController* Browser::GetFindBarController() { | 558 FindBarController* Browser::GetFindBarController() { |
| 553 if (!find_bar_controller_.get()) { | 559 if (!find_bar_controller_.get()) { |
| 554 FindBar* find_bar = window_->CreateFindBar(); | 560 FindBar* find_bar = window_->CreateFindBar(); |
| 555 find_bar_controller_.reset(new FindBarController(find_bar)); | 561 find_bar_controller_.reset(new FindBarController(find_bar)); |
| 556 find_bar->SetFindBarController(find_bar_controller_.get()); | 562 find_bar->SetFindBarController(find_bar_controller_.get()); |
| 557 find_bar_controller_->ChangeWebContents( | 563 find_bar_controller_->ChangeWebContents( |
| 558 tab_strip_model_->GetActiveWebContents()); | 564 tab_strip_model_->GetActiveWebContents()); |
| 559 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect()); | 565 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect()); |
| 560 } | 566 } |
| 561 return find_bar_controller_.get(); | 567 return find_bar_controller_.get(); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 } | 808 } |
| 803 | 809 |
| 804 //////////////////////////////////////////////////////////////////////////////// | 810 //////////////////////////////////////////////////////////////////////////////// |
| 805 // Browser, Tab adding/showing functions: | 811 // Browser, Tab adding/showing functions: |
| 806 | 812 |
| 807 void Browser::WindowFullscreenStateChanged() { | 813 void Browser::WindowFullscreenStateChanged() { |
| 808 exclusive_access_manager_->fullscreen_controller() | 814 exclusive_access_manager_->fullscreen_controller() |
| 809 ->WindowFullscreenStateChanged(); | 815 ->WindowFullscreenStateChanged(); |
| 810 command_controller_->FullscreenStateChanged(); | 816 command_controller_->FullscreenStateChanged(); |
| 811 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN); | 817 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN); |
| 818 |
| 819 GetBubbleManager()->WindowFullscreenStateChanged(); |
| 812 } | 820 } |
| 813 | 821 |
| 814 /////////////////////////////////////////////////////////////////////////////// | 822 /////////////////////////////////////////////////////////////////////////////// |
| 815 // Browser, Assorted browser commands: | 823 // Browser, Assorted browser commands: |
| 816 | 824 |
| 817 void Browser::ToggleFullscreenModeWithExtension(const GURL& extension_url) { | 825 void Browser::ToggleFullscreenModeWithExtension(const GURL& extension_url) { |
| 818 exclusive_access_manager_->fullscreen_controller() | 826 exclusive_access_manager_->fullscreen_controller() |
| 819 ->ToggleBrowserFullscreenModeWithExtension(extension_url); | 827 ->ToggleBrowserFullscreenModeWithExtension(extension_url); |
| 820 } | 828 } |
| 821 | 829 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 int old_active_index = tab_strip_model_->active_index(); | 991 int old_active_index = tab_strip_model_->active_index(); |
| 984 if (index < old_active_index && !tab_strip_model_->closing_all()) { | 992 if (index < old_active_index && !tab_strip_model_->closing_all()) { |
| 985 SessionService* session_service = | 993 SessionService* session_service = |
| 986 SessionServiceFactory::GetForProfileIfExisting(profile_); | 994 SessionServiceFactory::GetForProfileIfExisting(profile_); |
| 987 if (session_service) | 995 if (session_service) |
| 988 session_service->SetSelectedTabInWindow(session_id(), | 996 session_service->SetSelectedTabInWindow(session_id(), |
| 989 old_active_index - 1); | 997 old_active_index - 1); |
| 990 } | 998 } |
| 991 | 999 |
| 992 TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH); | 1000 TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH); |
| 1001 |
| 1002 GetBubbleManager()->TabDetached(); |
| 993 } | 1003 } |
| 994 | 1004 |
| 995 void Browser::TabDeactivated(WebContents* contents) { | 1005 void Browser::TabDeactivated(WebContents* contents) { |
| 996 exclusive_access_manager_->OnTabDeactivated(contents); | 1006 exclusive_access_manager_->OnTabDeactivated(contents); |
| 997 search_delegate_->OnTabDeactivated(contents); | 1007 search_delegate_->OnTabDeactivated(contents); |
| 998 SearchTabHelper::FromWebContents(contents)->OnTabDeactivated(); | 1008 SearchTabHelper::FromWebContents(contents)->OnTabDeactivated(); |
| 999 | 1009 |
| 1000 // Save what the user's currently typing, so it can be restored when we | 1010 // Save what the user's currently typing, so it can be restored when we |
| 1001 // switch back to this tab. | 1011 // switch back to this tab. |
| 1002 window_->GetLocationBar()->SaveStateToContents(contents); | 1012 window_->GetLocationBar()->SaveStateToContents(contents); |
| 1003 | 1013 |
| 1004 if (instant_controller_) | 1014 if (instant_controller_) |
| 1005 instant_controller_->TabDeactivated(contents); | 1015 instant_controller_->TabDeactivated(contents); |
| 1016 |
| 1017 GetBubbleManager()->TabDeactivated(); |
| 1006 } | 1018 } |
| 1007 | 1019 |
| 1008 void Browser::ActiveTabChanged(WebContents* old_contents, | 1020 void Browser::ActiveTabChanged(WebContents* old_contents, |
| 1009 WebContents* new_contents, | 1021 WebContents* new_contents, |
| 1010 int index, | 1022 int index, |
| 1011 int reason) { | 1023 int reason) { |
| 1012 content::RecordAction(UserMetricsAction("ActiveTabChanged")); | 1024 content::RecordAction(UserMetricsAction("ActiveTabChanged")); |
| 1013 | 1025 |
| 1014 // Update the bookmark state, since the BrowserWindow may query it during | 1026 // Update the bookmark state, since the BrowserWindow may query it during |
| 1015 // OnActiveTabChanged() below. | 1027 // OnActiveTabChanged() below. |
| (...skipping 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2656 if (contents && !allow_js_access) { | 2668 if (contents && !allow_js_access) { |
| 2657 contents->web_contents()->GetController().LoadURL( | 2669 contents->web_contents()->GetController().LoadURL( |
| 2658 target_url, | 2670 target_url, |
| 2659 content::Referrer(), | 2671 content::Referrer(), |
| 2660 ui::PAGE_TRANSITION_LINK, | 2672 ui::PAGE_TRANSITION_LINK, |
| 2661 std::string()); // No extra headers. | 2673 std::string()); // No extra headers. |
| 2662 } | 2674 } |
| 2663 | 2675 |
| 2664 return contents != NULL; | 2676 return contents != NULL; |
| 2665 } | 2677 } |
| OLD | NEW |