Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: chrome/browser/app_controller_mac.mm

Issue 2318303002: Remove stl_util's STLDeleteContainerPairSecondPointers. (Closed)
Patch Set: fix Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #import "chrome/browser/app_controller_mac.h" 5 #import "chrome/browser/app_controller_mac.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/mac/foundation_util.h" 13 #include "base/mac/foundation_util.h"
14 #include "base/mac/mac_util.h" 14 #include "base/mac/mac_util.h"
15 #include "base/mac/sdk_forward_declarations.h" 15 #include "base/mac/sdk_forward_declarations.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ptr_util.h"
17 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
18 #include "base/metrics/histogram_macros.h" 19 #include "base/metrics/histogram_macros.h"
19 #include "base/stl_util.h"
20 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/sys_string_conversions.h" 21 #include "base/strings/sys_string_conversions.h"
22 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
23 #include "chrome/app/chrome_command_ids.h" 23 #include "chrome/app/chrome_command_ids.h"
24 #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h" 24 #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h"
25 #include "chrome/browser/apps/app_window_registry_util.h" 25 #include "chrome/browser/apps/app_window_registry_util.h"
26 #include "chrome/browser/background/background_application_list_model.h" 26 #include "chrome/browser/background/background_application_list_model.h"
27 #include "chrome/browser/background/background_mode_manager.h" 27 #include "chrome/browser/background/background_mode_manager.h"
28 #include "chrome/browser/browser_process.h" 28 #include "chrome/browser/browser_process.h"
29 #include "chrome/browser/browser_shutdown.h" 29 #include "chrome/browser/browser_shutdown.h"
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 keep_alive_.reset(); 527 keep_alive_.reset();
528 528
529 // Reset all pref watching, as this object outlives the prefs system. 529 // Reset all pref watching, as this object outlives the prefs system.
530 profilePrefRegistrar_.reset(); 530 profilePrefRegistrar_.reset();
531 localPrefRegistrar_.RemoveAll(); 531 localPrefRegistrar_.RemoveAll();
532 532
533 [self unregisterEventHandlers]; 533 [self unregisterEventHandlers];
534 534
535 appShimMenuController_.reset(); 535 appShimMenuController_.reset();
536 536
537 base::STLDeleteContainerPairSecondPointers( 537 profileBookmarkMenuBridgeMap_.clear();
538 profileBookmarkMenuBridgeMap_.begin(),
539 profileBookmarkMenuBridgeMap_.end());
540 } 538 }
541 539
542 - (void)didEndMainMessageLoop { 540 - (void)didEndMainMessageLoop {
543 DCHECK_EQ(0u, chrome::GetBrowserCount([self lastProfile])); 541 DCHECK_EQ(0u, chrome::GetBrowserCount([self lastProfile]));
544 if (!chrome::GetBrowserCount([self lastProfile])) { 542 if (!chrome::GetBrowserCount([self lastProfile])) {
545 // As we're shutting down, we need to nuke the TabRestoreService, which 543 // As we're shutting down, we need to nuke the TabRestoreService, which
546 // will start the shutdown of the NavigationControllers and allow for 544 // will start the shutdown of the NavigationControllers and allow for
547 // proper shutdown. If we don't do this, Chrome won't shut down cleanly, 545 // proper shutdown. If we don't do this, Chrome won't shut down cleanly,
548 // and may end up crashing when some thread tries to use the IO thread (or 546 // and may end up crashing when some thread tries to use the IO thread (or
549 // another thread) that is no longer valid. 547 // another thread) that is no longer valid.
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 // In a browser test, the application is not brought to the front, so 874 // In a browser test, the application is not brought to the front, so
877 // |lastProfile_| might be null. 875 // |lastProfile_| might be null.
878 if (!lastProfile_ || profilePath == lastProfile_->GetPath()) { 876 if (!lastProfile_ || profilePath == lastProfile_->GetPath()) {
879 // Force windowChangedToProfile: to set the lastProfile_ and also update the 877 // Force windowChangedToProfile: to set the lastProfile_ and also update the
880 // relevant menuBridge objects. 878 // relevant menuBridge objects.
881 lastProfile_ = nullptr; 879 lastProfile_ = nullptr;
882 [self windowChangedToProfile:g_browser_process->profile_manager()-> 880 [self windowChangedToProfile:g_browser_process->profile_manager()->
883 GetLastUsedProfile()]; 881 GetLastUsedProfile()];
884 } 882 }
885 883
886 auto it = profileBookmarkMenuBridgeMap_.find(profilePath); 884 profileBookmarkMenuBridgeMap_.erase(profilePath);
887 if (it != profileBookmarkMenuBridgeMap_.end()) {
888 delete it->second;
889 profileBookmarkMenuBridgeMap_.erase(it);
890 }
891 } 885 }
892 886
893 // Returns true if there is a modal window (either window- or application- 887 // Returns true if there is a modal window (either window- or application-
894 // modal) blocking the active browser. Note that tab modal dialogs (HTTP auth 888 // modal) blocking the active browser. Note that tab modal dialogs (HTTP auth
895 // sheets) will not count as blocking the browser. But things like open/save 889 // sheets) will not count as blocking the browser. But things like open/save
896 // dialogs that are window modal will block the browser. 890 // dialogs that are window modal will block the browser.
897 - (BOOL)keyWindowIsModal { 891 - (BOOL)keyWindowIsModal {
898 if ([NSApp modalWindow]) 892 if ([NSApp modalWindow])
899 return YES; 893 return YES;
900 894
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 // See https://crbug.com/497813 for more details. 1546 // See https://crbug.com/497813 for more details.
1553 NSMenuItem* bookmarkItem = [[NSApp mainMenu] itemWithTag:IDC_BOOKMARKS_MENU]; 1547 NSMenuItem* bookmarkItem = [[NSApp mainMenu] itemWithTag:IDC_BOOKMARKS_MENU];
1554 BOOL hidden = [bookmarkItem isHidden]; 1548 BOOL hidden = [bookmarkItem isHidden];
1555 [bookmarkItem setHidden:NO]; 1549 [bookmarkItem setHidden:NO];
1556 lastProfile_ = profile; 1550 lastProfile_ = profile;
1557 1551
1558 auto it = profileBookmarkMenuBridgeMap_.find(profile->GetPath()); 1552 auto it = profileBookmarkMenuBridgeMap_.find(profile->GetPath());
1559 if (it == profileBookmarkMenuBridgeMap_.end()) { 1553 if (it == profileBookmarkMenuBridgeMap_.end()) {
1560 base::scoped_nsobject<NSMenu> submenu([[bookmarkItem submenu] copy]); 1554 base::scoped_nsobject<NSMenu> submenu([[bookmarkItem submenu] copy]);
1561 bookmarkMenuBridge_ = new BookmarkMenuBridge(profile, submenu); 1555 bookmarkMenuBridge_ = new BookmarkMenuBridge(profile, submenu);
1562 profileBookmarkMenuBridgeMap_[profile->GetPath()] = bookmarkMenuBridge_; 1556 profileBookmarkMenuBridgeMap_[profile->GetPath()] =
1557 base::WrapUnique(bookmarkMenuBridge_);
1563 } else { 1558 } else {
1564 bookmarkMenuBridge_ = it->second; 1559 bookmarkMenuBridge_ = it->second.get();
1565 } 1560 }
1566 1561
1567 // No need to |BuildMenu| here. It is done lazily upon menu access. 1562 // No need to |BuildMenu| here. It is done lazily upon menu access.
1568 [bookmarkItem setSubmenu:bookmarkMenuBridge_->BookmarkMenu()]; 1563 [bookmarkItem setSubmenu:bookmarkMenuBridge_->BookmarkMenu()];
1569 [bookmarkItem setHidden:hidden]; 1564 [bookmarkItem setHidden:hidden];
1570 1565
1571 historyMenuBridge_.reset(new HistoryMenuBridge(lastProfile_)); 1566 historyMenuBridge_.reset(new HistoryMenuBridge(lastProfile_));
1572 historyMenuBridge_->BuildMenu(); 1567 historyMenuBridge_->BuildMenu();
1573 1568
1574 chrome::BrowserCommandController:: 1569 chrome::BrowserCommandController::
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 1678
1684 //--------------------------------------------------------------------------- 1679 //---------------------------------------------------------------------------
1685 1680
1686 namespace app_controller_mac { 1681 namespace app_controller_mac {
1687 1682
1688 bool IsOpeningNewWindow() { 1683 bool IsOpeningNewWindow() {
1689 return g_is_opening_new_window; 1684 return g_is_opening_new_window;
1690 } 1685 }
1691 1686
1692 } // namespace app_controller_mac 1687 } // namespace app_controller_mac
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698