OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/tab_contents.h" | 5 #include "chrome/browser/tab_contents.h" |
6 | 6 |
7 #include "chrome/browser/cert_store.h" | 7 #include "chrome/browser/cert_store.h" |
8 #include "chrome/browser/navigation_entry.h" | 8 #include "chrome/browser/navigation_entry.h" |
9 #include "chrome/browser/views/download_shelf_view.h" | 9 #include "chrome/browser/views/download_shelf_view.h" |
10 #include "chrome/browser/views/download_started_animation.h" | 10 #include "chrome/browser/views/download_started_animation.h" |
11 #include "chrome/browser/web_contents.h" | 11 #include "chrome/browser/web_contents.h" |
12 #include "chrome/browser/tab_contents_delegate.h" | 12 #include "chrome/browser/tab_contents_delegate.h" |
13 #include "chrome/common/l10n_util.h" | 13 #include "chrome/common/l10n_util.h" |
14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
15 #include "chrome/common/pref_service.h" | 15 #include "chrome/common/pref_service.h" |
16 #include "chrome/views/hwnd_view_container.h" | 16 #include "chrome/views/hwnd_view_container.h" |
17 #include "chrome/views/native_scroll_bar.h" | 17 #include "chrome/views/native_scroll_bar.h" |
18 #include "chrome/views/root_view.h" | 18 #include "chrome/views/root_view.h" |
19 #include "chrome/views/view.h" | 19 #include "chrome/views/view.h" |
20 #include "chrome/views/view_storage.h" | 20 #include "chrome/views/view_storage.h" |
21 | 21 |
22 #include "generated_resources.h" | 22 #include "generated_resources.h" |
23 | 23 |
24 static size_t kMaxNumberOfConstrainedPopups = 20; | |
25 | |
26 namespace { | 24 namespace { |
27 | 25 |
28 BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { | 26 BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { |
29 // Note: erase is required to properly paint some widgets borders. This can be | 27 // Note: erase is required to properly paint some widgets borders. This can be |
30 // seen with textfields. | 28 // seen with textfields. |
31 InvalidateRect(hwnd, NULL, TRUE); | 29 InvalidateRect(hwnd, NULL, TRUE); |
32 return TRUE; | 30 return TRUE; |
33 } | 31 } |
34 | 32 |
35 } // namespace | 33 } // namespace |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 return; | 275 return; |
278 | 276 |
279 if ((disposition == NEW_POPUP) && !user_gesture) { | 277 if ((disposition == NEW_POPUP) && !user_gesture) { |
280 // Unrequested popups from normal pages are constrained. | 278 // Unrequested popups from normal pages are constrained. |
281 TabContents* popup_owner = this; | 279 TabContents* popup_owner = this; |
282 TabContents* our_owner = delegate_->GetConstrainingContents(this); | 280 TabContents* our_owner = delegate_->GetConstrainingContents(this); |
283 if (our_owner) | 281 if (our_owner) |
284 popup_owner = our_owner; | 282 popup_owner = our_owner; |
285 popup_owner->AddConstrainedPopup(new_contents, initial_pos); | 283 popup_owner->AddConstrainedPopup(new_contents, initial_pos); |
286 } else { | 284 } else { |
| 285 new_contents->DisassociateFromPopupCount(); |
| 286 |
287 delegate_->AddNewContents(this, new_contents, disposition, initial_pos, | 287 delegate_->AddNewContents(this, new_contents, disposition, initial_pos, |
288 user_gesture); | 288 user_gesture); |
289 } | 289 } |
290 } | 290 } |
291 | 291 |
292 void TabContents::AddConstrainedPopup(TabContents* new_contents, | 292 void TabContents::AddConstrainedPopup(TabContents* new_contents, |
293 const gfx::Rect& initial_pos) { | 293 const gfx::Rect& initial_pos) { |
294 if (child_windows_.size() > kMaxNumberOfConstrainedPopups) { | |
295 new_contents->CloseContents(); | |
296 return; | |
297 } | |
298 | |
299 ConstrainedWindow* window = | 294 ConstrainedWindow* window = |
300 ConstrainedWindow::CreateConstrainedPopup( | 295 ConstrainedWindow::CreateConstrainedPopup( |
301 this, initial_pos, new_contents); | 296 this, initial_pos, new_contents); |
302 child_windows_.push_back(window); | 297 child_windows_.push_back(window); |
303 | 298 |
304 CRect client_rect; | 299 CRect client_rect; |
305 GetClientRect(GetContainerHWND(), &client_rect); | 300 GetClientRect(GetContainerHWND(), &client_rect); |
306 gfx::Size new_size(client_rect.Width(), client_rect.Height()); | 301 gfx::Size new_size(client_rect.Width(), client_rect.Height()); |
307 RepositionSupressedPopupsToFit(new_size); | 302 RepositionSupressedPopupsToFit(new_size); |
308 } | 303 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 } | 488 } |
494 } | 489 } |
495 | 490 |
496 void TabContents::DetachContents(ConstrainedWindow* window, | 491 void TabContents::DetachContents(ConstrainedWindow* window, |
497 TabContents* contents, | 492 TabContents* contents, |
498 const gfx::Rect& contents_bounds, | 493 const gfx::Rect& contents_bounds, |
499 const gfx::Point& mouse_pt, | 494 const gfx::Point& mouse_pt, |
500 int frame_component) { | 495 int frame_component) { |
501 WillClose(window); | 496 WillClose(window); |
502 if (delegate_) { | 497 if (delegate_) { |
| 498 contents->DisassociateFromPopupCount(); |
503 delegate_->StartDraggingDetachedContents( | 499 delegate_->StartDraggingDetachedContents( |
504 this, contents, contents_bounds, mouse_pt, frame_component); | 500 this, contents, contents_bounds, mouse_pt, frame_component); |
505 } | 501 } |
506 } | 502 } |
507 | 503 |
508 void TabContents::DidMoveOrResize(ConstrainedWindow* window) { | 504 void TabContents::DidMoveOrResize(ConstrainedWindow* window) { |
509 UpdateWindow(GetContainerHWND()); | 505 UpdateWindow(GetContainerHWND()); |
510 } | 506 } |
511 | 507 |
512 // static | 508 // static |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 for (int i = window_count - 1; i >= 0; --i) { | 549 for (int i = window_count - 1; i >= 0; --i) { |
554 ConstrainedWindow* window = child_windows_.at(i); | 550 ConstrainedWindow* window = child_windows_.at(i); |
555 if (window->IsSuppressedConstrainedWindow()) | 551 if (window->IsSuppressedConstrainedWindow()) |
556 window->RepositionConstrainedWindowTo(anchor_position); | 552 window->RepositionConstrainedWindowTo(anchor_position); |
557 } | 553 } |
558 } | 554 } |
559 | 555 |
560 void TabContents::ReleaseDownloadShelfView() { | 556 void TabContents::ReleaseDownloadShelfView() { |
561 download_shelf_view_.release(); | 557 download_shelf_view_.release(); |
562 } | 558 } |
OLD | NEW |