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

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

Issue 287123002: [WebModals] New API for browser-scoped popup management. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make PopupManager a thin API for WCMDM Created 6 years, 6 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 | Annotate | Revision Log
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 #include "chrome/browser/ui/tabs/tab_strip_model.h" 5 #include "chrome/browser/ui/tabs/tab_strip_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "apps/ui/web_contents_sizer.h" 11 #include "apps/ui/web_contents_sizer.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/browser_shutdown.h" 15 #include "chrome/browser/browser_shutdown.h"
16 #include "chrome/browser/defaults.h" 16 #include "chrome/browser/defaults.h"
17 #include "chrome/browser/extensions/tab_helper.h" 17 #include "chrome/browser/extensions/tab_helper.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/browser_finder.h"
19 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" 20 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
20 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" 21 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" 22 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
22 #include "chrome/browser/ui/tabs/tab_strip_model_order_controller.h" 23 #include "chrome/browser/ui/tabs/tab_strip_model_order_controller.h"
23 #include "chrome/common/url_constants.h" 24 #include "chrome/common/url_constants.h"
24 #include "components/web_modal/web_contents_modal_dialog_manager.h" 25 #include "components/web_modal/popup_manager.h"
25 #include "content/public/browser/render_process_host.h" 26 #include "content/public/browser/render_process_host.h"
26 #include "content/public/browser/user_metrics.h" 27 #include "content/public/browser/user_metrics.h"
27 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
28 #include "content/public/browser/web_contents_observer.h" 29 #include "content/public/browser/web_contents_observer.h"
29 using base::UserMetricsAction; 30 using base::UserMetricsAction;
30 using content::WebContents; 31 using content::WebContents;
31 32
32 namespace { 33 namespace {
33 34
34 // Returns true if the specified transition is one of the types that cause the 35 // Returns true if the specified transition is one of the types that cause the
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 data->set_opener(active_contents); 309 data->set_opener(active_contents);
309 } else if ((add_types & ADD_INHERIT_OPENER) && active_contents) { 310 } else if ((add_types & ADD_INHERIT_OPENER) && active_contents) {
310 if (active) { 311 if (active) {
311 // Forget any existing relationships, we don't want to make things too 312 // Forget any existing relationships, we don't want to make things too
312 // confusing by having multiple groups active at the same time. 313 // confusing by having multiple groups active at the same time.
313 ForgetAllOpeners(); 314 ForgetAllOpeners();
314 } 315 }
315 data->set_opener(active_contents); 316 data->set_opener(active_contents);
316 } 317 }
317 318
318 web_modal::WebContentsModalDialogManager* modal_dialog_manager = 319 // TODO(gbillock): This can be made more appropriate by asking the bubble
319 web_modal::WebContentsModalDialogManager::FromWebContents(contents); 320 // manager whether the WebContents should be blocked, or perhaps just by
320 if (modal_dialog_manager) 321 // letting the bubble manager make the blocking call directly and don't use
321 data->set_blocked(modal_dialog_manager->IsDialogActive()); 322 // this at all.
323 Browser* browser = chrome::FindBrowserWithWebContents(contents);
324 if (browser)
325 data->set_blocked(browser->popup_manager()->IsWebModalDialogActive(contents) );
322 326
323 contents_data_.insert(contents_data_.begin() + index, data); 327 contents_data_.insert(contents_data_.begin() + index, data);
324 328
325 selection_model_.IncrementFrom(index); 329 selection_model_.IncrementFrom(index);
326 330
327 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, 331 FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
328 TabInsertedAt(contents, index, active)); 332 TabInsertedAt(contents, index, active));
329 if (active) { 333 if (active) {
330 ui::ListSelectionModel new_model; 334 ui::ListSelectionModel new_model;
331 new_model.Copy(selection_model_); 335 new_model.Copy(selection_model_);
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 void TabStripModel::ForgetOpenersAndGroupsReferencing( 1410 void TabStripModel::ForgetOpenersAndGroupsReferencing(
1407 const WebContents* tab) { 1411 const WebContents* tab) {
1408 for (WebContentsDataVector::const_iterator i = contents_data_.begin(); 1412 for (WebContentsDataVector::const_iterator i = contents_data_.begin();
1409 i != contents_data_.end(); ++i) { 1413 i != contents_data_.end(); ++i) {
1410 if ((*i)->group() == tab) 1414 if ((*i)->group() == tab)
1411 (*i)->set_group(NULL); 1415 (*i)->set_group(NULL);
1412 if ((*i)->opener() == tab) 1416 if ((*i)->opener() == tab)
1413 (*i)->set_opener(NULL); 1417 (*i)->set_opener(NULL);
1414 } 1418 }
1415 } 1419 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698