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

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 586933002: Re-Revert "[WebModals] New API for browser-scoped popup management." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2125
Patch Set: Created 6 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
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_commands.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 #include "chrome/common/custom_handlers/protocol_handler.h" 147 #include "chrome/common/custom_handlers/protocol_handler.h"
148 #include "chrome/common/pref_names.h" 148 #include "chrome/common/pref_names.h"
149 #include "chrome/common/profiling.h" 149 #include "chrome/common/profiling.h"
150 #include "chrome/common/search_types.h" 150 #include "chrome/common/search_types.h"
151 #include "chrome/common/url_constants.h" 151 #include "chrome/common/url_constants.h"
152 #include "components/bookmarks/browser/bookmark_model.h" 152 #include "components/bookmarks/browser/bookmark_model.h"
153 #include "components/bookmarks/browser/bookmark_utils.h" 153 #include "components/bookmarks/browser/bookmark_utils.h"
154 #include "components/google/core/browser/google_url_tracker.h" 154 #include "components/google/core/browser/google_url_tracker.h"
155 #include "components/search/search.h" 155 #include "components/search/search.h"
156 #include "components/startup_metric_utils/startup_metric_utils.h" 156 #include "components/startup_metric_utils/startup_metric_utils.h"
157 #include "components/web_modal/popup_manager.h"
158 #include "components/web_modal/web_contents_modal_dialog_manager.h" 157 #include "components/web_modal/web_contents_modal_dialog_manager.h"
159 #include "content/public/browser/devtools_manager.h" 158 #include "content/public/browser/devtools_manager.h"
160 #include "content/public/browser/download_item.h" 159 #include "content/public/browser/download_item.h"
161 #include "content/public/browser/download_manager.h" 160 #include "content/public/browser/download_manager.h"
162 #include "content/public/browser/interstitial_page.h" 161 #include "content/public/browser/interstitial_page.h"
163 #include "content/public/browser/invalidate_type.h" 162 #include "content/public/browser/invalidate_type.h"
164 #include "content/public/browser/navigation_controller.h" 163 #include "content/public/browser/navigation_controller.h"
165 #include "content/public/browser/navigation_entry.h" 164 #include "content/public/browser/navigation_entry.h"
166 #include "content/public/browser/notification_details.h" 165 #include "content/public/browser/notification_details.h"
167 #include "content/public/browser/notification_service.h" 166 #include "content/public/browser/notification_service.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 // TODO(beng): move to ChromeBrowserMain: 441 // TODO(beng): move to ChromeBrowserMain:
443 if (first_run::ShouldDoPersonalDataManagerFirstRun()) { 442 if (first_run::ShouldDoPersonalDataManagerFirstRun()) {
444 #if defined(OS_WIN) 443 #if defined(OS_WIN)
445 // Notify PDM that this is a first run. 444 // Notify PDM that this is a first run.
446 ImportAutofillDataWin( 445 ImportAutofillDataWin(
447 autofill::PersonalDataManagerFactory::GetForProfile(profile_)); 446 autofill::PersonalDataManagerFactory::GetForProfile(profile_));
448 #endif // defined(OS_WIN) 447 #endif // defined(OS_WIN)
449 } 448 }
450 449
451 fullscreen_controller_.reset(new FullscreenController(this)); 450 fullscreen_controller_.reset(new FullscreenController(this));
452
453 // Must be initialized after window_.
454 // Also: surprise! a modal dialog host is not necessary to host modal dialogs
455 // without a modal dialog host, so that value may be null.
456 popup_manager_.reset(new web_modal::PopupManager(
457 GetWebContentsModalDialogHost()));
458 } 451 }
459 452
460 Browser::~Browser() { 453 Browser::~Browser() {
461 // Stop observing notifications before continuing with destruction. Profile 454 // Stop observing notifications before continuing with destruction. Profile
462 // destruction will unload extensions and reentrant calls to Browser:: should 455 // destruction will unload extensions and reentrant calls to Browser:: should
463 // be avoided while it is being torn down. 456 // be avoided while it is being torn down.
464 registrar_.RemoveAll(); 457 registrar_.RemoveAll();
465 458
466 // The tab strip should not have any tabs at this point. 459 // The tab strip should not have any tabs at this point.
467 DCHECK(tab_strip_model_->empty()); 460 DCHECK(tab_strip_model_->empty());
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 return OpenURLFromTab(NULL, params); 889 return OpenURLFromTab(NULL, params);
897 } 890 }
898 891
899 /////////////////////////////////////////////////////////////////////////////// 892 ///////////////////////////////////////////////////////////////////////////////
900 // Browser, TabStripModelObserver implementation: 893 // Browser, TabStripModelObserver implementation:
901 894
902 void Browser::TabInsertedAt(WebContents* contents, 895 void Browser::TabInsertedAt(WebContents* contents,
903 int index, 896 int index,
904 bool foreground) { 897 bool foreground) {
905 SetAsDelegate(contents, true); 898 SetAsDelegate(contents, true);
906
907 if (popup_manager_)
908 popup_manager_->RegisterWith(contents);
909
910 SessionTabHelper* session_tab_helper = 899 SessionTabHelper* session_tab_helper =
911 SessionTabHelper::FromWebContents(contents); 900 SessionTabHelper::FromWebContents(contents);
912 session_tab_helper->SetWindowID(session_id()); 901 session_tab_helper->SetWindowID(session_id());
913 902
914 content::NotificationService::current()->Notify( 903 content::NotificationService::current()->Notify(
915 chrome::NOTIFICATION_TAB_PARENTED, 904 chrome::NOTIFICATION_TAB_PARENTED,
916 content::Source<content::WebContents>(contents), 905 content::Source<content::WebContents>(contents),
917 content::NotificationService::NoDetails()); 906 content::NotificationService::NoDetails());
918 907
919 SyncHistoryWithTabs(index); 908 SyncHistoryWithTabs(index);
(...skipping 21 matching lines...) Expand all
941 fullscreen_controller_->OnTabClosing(contents); 930 fullscreen_controller_->OnTabClosing(contents);
942 SessionService* session_service = 931 SessionService* session_service =
943 SessionServiceFactory::GetForProfile(profile_); 932 SessionServiceFactory::GetForProfile(profile_);
944 if (session_service) 933 if (session_service)
945 session_service->TabClosing(contents); 934 session_service->TabClosing(contents);
946 content::NotificationService::current()->Notify( 935 content::NotificationService::current()->Notify(
947 chrome::NOTIFICATION_TAB_CLOSING, 936 chrome::NOTIFICATION_TAB_CLOSING,
948 content::Source<NavigationController>(&contents->GetController()), 937 content::Source<NavigationController>(&contents->GetController()),
949 content::NotificationService::NoDetails()); 938 content::NotificationService::NoDetails());
950 939
951 if (popup_manager_)
952 popup_manager_->UnregisterWith(contents);
953
954 // Sever the WebContents' connection back to us. 940 // Sever the WebContents' connection back to us.
955 SetAsDelegate(contents, false); 941 SetAsDelegate(contents, false);
956 } 942 }
957 943
958 void Browser::TabDetachedAt(WebContents* contents, int index) { 944 void Browser::TabDetachedAt(WebContents* contents, int index) {
959 // TabDetachedAt is called before TabStripModel has updated the 945 // TabDetachedAt is called before TabStripModel has updated the
960 // active index. 946 // active index.
961 int old_active_index = tab_strip_model_->active_index(); 947 int old_active_index = tab_strip_model_->active_index();
962 if (index < old_active_index && !tab_strip_model_->closing_all()) { 948 if (index < old_active_index && !tab_strip_model_->closing_all()) {
963 SessionService* session_service = 949 SessionService* session_service =
964 SessionServiceFactory::GetForProfileIfExisting(profile_); 950 SessionServiceFactory::GetForProfileIfExisting(profile_);
965 if (session_service) 951 if (session_service)
966 session_service->SetSelectedTabInWindow(session_id(), 952 session_service->SetSelectedTabInWindow(session_id(),
967 old_active_index - 1); 953 old_active_index - 1);
968 } 954 }
969
970 if (popup_manager_)
971 popup_manager_->UnregisterWith(contents);
972
973 TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH); 955 TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH);
974 } 956 }
975 957
976 void Browser::TabDeactivated(WebContents* contents) { 958 void Browser::TabDeactivated(WebContents* contents) {
977 fullscreen_controller_->OnTabDeactivated(contents); 959 fullscreen_controller_->OnTabDeactivated(contents);
978 search_delegate_->OnTabDeactivated(contents); 960 search_delegate_->OnTabDeactivated(contents);
979 SearchTabHelper::FromWebContents(contents)->OnTabDeactivated(); 961 SearchTabHelper::FromWebContents(contents)->OnTabDeactivated();
980 962
981 // Save what the user's currently typing, so it can be restored when we 963 // Save what the user's currently typing, so it can be restored when we
982 // switch back to this tab. 964 // switch back to this tab.
(...skipping 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after
2474 if (contents && !allow_js_access) { 2456 if (contents && !allow_js_access) {
2475 contents->web_contents()->GetController().LoadURL( 2457 contents->web_contents()->GetController().LoadURL(
2476 target_url, 2458 target_url,
2477 content::Referrer(), 2459 content::Referrer(),
2478 content::PAGE_TRANSITION_LINK, 2460 content::PAGE_TRANSITION_LINK,
2479 std::string()); // No extra headers. 2461 std::string()); // No extra headers.
2480 } 2462 }
2481 2463
2482 return contents != NULL; 2464 return contents != NULL;
2483 } 2465 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_commands.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698