Chromium Code Reviews| 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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 Browser::~Browser() { | 464 Browser::~Browser() { |
| 465 // Stop observing notifications before continuing with destruction. Profile | 465 // Stop observing notifications before continuing with destruction. Profile |
| 466 // destruction will unload extensions and reentrant calls to Browser:: should | 466 // destruction will unload extensions and reentrant calls to Browser:: should |
| 467 // be avoided while it is being torn down. | 467 // be avoided while it is being torn down. |
| 468 registrar_.RemoveAll(); | 468 registrar_.RemoveAll(); |
| 469 extension_registry_observer_.RemoveAll(); | 469 extension_registry_observer_.RemoveAll(); |
| 470 | 470 |
| 471 // The tab strip should not have any tabs at this point. | 471 // The tab strip should not have any tabs at this point. |
| 472 DCHECK(tab_strip_model_->empty()); | 472 DCHECK(tab_strip_model_->empty()); |
| 473 tab_strip_model_->RemoveObserver(this); | 473 tab_strip_model_->RemoveObserver(this); |
| 474 if (bubble_manager_) | |
| 475 tab_strip_model_->RemoveObserver(bubble_manager_.get()); | |
|
msw
2015/08/26 01:42:35
Make the ChromeBubbleManager dtor remove itself as
hcarmona
2015/08/26 17:25:58
Done.
| |
| 474 | 476 |
| 475 // Destroy the BrowserCommandController before removing the browser, so that | 477 // Destroy the BrowserCommandController before removing the browser, so that |
| 476 // it doesn't act on any notifications that are sent as a result of removing | 478 // it doesn't act on any notifications that are sent as a result of removing |
| 477 // the browser. | 479 // the browser. |
| 478 command_controller_.reset(); | 480 command_controller_.reset(); |
| 479 BrowserList::RemoveBrowser(this); | 481 BrowserList::RemoveBrowser(this); |
| 480 | 482 |
| 481 SessionService* session_service = | 483 SessionService* session_service = |
| 482 SessionServiceFactory::GetForProfile(profile_); | 484 SessionServiceFactory::GetForProfile(profile_); |
| 483 if (session_service) | 485 if (session_service) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 if (OkToCloseWithInProgressDownloads(&num_downloads) == | 544 if (OkToCloseWithInProgressDownloads(&num_downloads) == |
| 543 DOWNLOAD_CLOSE_BROWSER_SHUTDOWN && | 545 DOWNLOAD_CLOSE_BROWSER_SHUTDOWN && |
| 544 !browser_defaults::kBrowserAliveWithNoWindows) { | 546 !browser_defaults::kBrowserAliveWithNoWindows) { |
| 545 DownloadService::CancelAllDownloads(); | 547 DownloadService::CancelAllDownloads(); |
| 546 } | 548 } |
| 547 } | 549 } |
| 548 | 550 |
| 549 /////////////////////////////////////////////////////////////////////////////// | 551 /////////////////////////////////////////////////////////////////////////////// |
| 550 // Getters & Setters | 552 // Getters & Setters |
| 551 | 553 |
| 554 ChromeBubbleManager* Browser::GetBubbleManager() { | |
| 555 if (!bubble_manager_) { | |
| 556 bubble_manager_.reset(new ChromeBubbleManager); | |
| 557 tab_strip_model_->AddObserver(bubble_manager_.get()); | |
|
msw
2015/08/26 01:42:35
Do this in the ChromeBubbleManager ctor; pass it |
hcarmona
2015/08/26 17:25:58
Done.
| |
| 558 } | |
| 559 return bubble_manager_.get(); | |
| 560 } | |
| 561 | |
| 552 FindBarController* Browser::GetFindBarController() { | 562 FindBarController* Browser::GetFindBarController() { |
| 553 if (!find_bar_controller_.get()) { | 563 if (!find_bar_controller_.get()) { |
| 554 FindBar* find_bar = window_->CreateFindBar(); | 564 FindBar* find_bar = window_->CreateFindBar(); |
| 555 find_bar_controller_.reset(new FindBarController(find_bar)); | 565 find_bar_controller_.reset(new FindBarController(find_bar)); |
| 556 find_bar->SetFindBarController(find_bar_controller_.get()); | 566 find_bar->SetFindBarController(find_bar_controller_.get()); |
| 557 find_bar_controller_->ChangeWebContents( | 567 find_bar_controller_->ChangeWebContents( |
| 558 tab_strip_model_->GetActiveWebContents()); | 568 tab_strip_model_->GetActiveWebContents()); |
| 559 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect()); | 569 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect()); |
| 560 } | 570 } |
| 561 return find_bar_controller_.get(); | 571 return find_bar_controller_.get(); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 802 } | 812 } |
| 803 | 813 |
| 804 //////////////////////////////////////////////////////////////////////////////// | 814 //////////////////////////////////////////////////////////////////////////////// |
| 805 // Browser, Tab adding/showing functions: | 815 // Browser, Tab adding/showing functions: |
| 806 | 816 |
| 807 void Browser::WindowFullscreenStateChanged() { | 817 void Browser::WindowFullscreenStateChanged() { |
| 808 exclusive_access_manager_->fullscreen_controller() | 818 exclusive_access_manager_->fullscreen_controller() |
| 809 ->WindowFullscreenStateChanged(); | 819 ->WindowFullscreenStateChanged(); |
| 810 command_controller_->FullscreenStateChanged(); | 820 command_controller_->FullscreenStateChanged(); |
| 811 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN); | 821 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN); |
| 822 | |
| 823 GetBubbleManager()->WindowFullscreenStateChanged(); | |
|
msw
2015/08/26 01:42:35
Make this conditional on the existence of a manage
hcarmona
2015/08/26 17:25:58
Done.
| |
| 812 } | 824 } |
| 813 | 825 |
| 814 /////////////////////////////////////////////////////////////////////////////// | 826 /////////////////////////////////////////////////////////////////////////////// |
| 815 // Browser, Assorted browser commands: | 827 // Browser, Assorted browser commands: |
| 816 | 828 |
| 817 void Browser::ToggleFullscreenModeWithExtension(const GURL& extension_url) { | 829 void Browser::ToggleFullscreenModeWithExtension(const GURL& extension_url) { |
| 818 exclusive_access_manager_->fullscreen_controller() | 830 exclusive_access_manager_->fullscreen_controller() |
| 819 ->ToggleBrowserFullscreenModeWithExtension(extension_url); | 831 ->ToggleBrowserFullscreenModeWithExtension(extension_url); |
| 820 } | 832 } |
| 821 | 833 |
| (...skipping 1834 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 |