| 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 #ifndef CHROME_BROWSER_TAB_CONTENTS_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_H_ |
| 6 #define CHROME_BROWSER_TAB_CONTENTS_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 11 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 12 #include "chrome/browser/constrained_window.h" | 12 #include "chrome/browser/constrained_window.h" |
| 13 #include "chrome/browser/infobar_delegate.h" |
| 13 #include "chrome/browser/navigation_controller.h" | 14 #include "chrome/browser/navigation_controller.h" |
| 14 #include "chrome/browser/page_navigator.h" | 15 #include "chrome/browser/page_navigator.h" |
| 15 #include "chrome/browser/tab_contents_type.h" | 16 #include "chrome/browser/tab_contents_type.h" |
| 16 #include "chrome/common/navigation_types.h" | 17 #include "chrome/common/navigation_types.h" |
| 17 | 18 |
| 18 namespace gfx { | 19 namespace gfx { |
| 19 class Rect; | 20 class Rect; |
| 20 class Size; | 21 class Size; |
| 21 } | 22 } |
| 22 namespace views { | 23 namespace views { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 46 // Once they reside within a NavigationController, TabContents objects are | 47 // Once they reside within a NavigationController, TabContents objects are |
| 47 // owned by that NavigationController. When the active TabContents within that | 48 // owned by that NavigationController. When the active TabContents within that |
| 48 // NavigationController is closed, that TabContents destroys the | 49 // NavigationController is closed, that TabContents destroys the |
| 49 // NavigationController, which then destroys all of the TabContentses in it. | 50 // NavigationController, which then destroys all of the TabContentses in it. |
| 50 // | 51 // |
| 51 // NOTE: When the NavigationController is navigated to an URL corresponding to | 52 // NOTE: When the NavigationController is navigated to an URL corresponding to |
| 52 // a different type of TabContents (see the TabContents::TypeForURL method), | 53 // a different type of TabContents (see the TabContents::TypeForURL method), |
| 53 // the NavigationController makes the active TabContents inactive, notifies the | 54 // the NavigationController makes the active TabContents inactive, notifies the |
| 54 // TabContentsDelegate that the TabContents is being replaced, and then | 55 // TabContentsDelegate that the TabContents is being replaced, and then |
| 55 // activates the new TabContents. | 56 // activates the new TabContents. |
| 56 class TabContents : public PageNavigator { | 57 class TabContents : public PageNavigator, |
| 58 public NotificationObserver { |
| 57 public: | 59 public: |
| 58 // Flags passed to the TabContentsDelegate.NavigationStateChanged to tell it | 60 // Flags passed to the TabContentsDelegate.NavigationStateChanged to tell it |
| 59 // what has changed. Combine them to update more than one thing. | 61 // what has changed. Combine them to update more than one thing. |
| 60 enum InvalidateTypes { | 62 enum InvalidateTypes { |
| 61 INVALIDATE_URL = 1, // The URL has changed. | 63 INVALIDATE_URL = 1, // The URL has changed. |
| 62 INVALIDATE_TITLE = 2, // The title has changed. | 64 INVALIDATE_TITLE = 2, // The title has changed. |
| 63 INVALIDATE_FAVICON = 4, // The favicon has changed. | 65 INVALIDATE_FAVICON = 4, // The favicon has changed. |
| 64 INVALIDATE_LOAD = 8, // The loading state has changed | 66 INVALIDATE_LOAD = 8, // The loading state has changed |
| 65 | 67 |
| 66 // Helper for forcing a refresh. | 68 // Helper for forcing a refresh. |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 // return their RootView. Other TabContents (such as WebContents) should | 377 // return their RootView. Other TabContents (such as WebContents) should |
| 376 // return NULL. | 378 // return NULL. |
| 377 // This is used by the focus manager to figure out what to focus when the tab | 379 // This is used by the focus manager to figure out what to focus when the tab |
| 378 // is focused (when a tab with no view hierarchy is focused, the | 380 // is focused (when a tab with no view hierarchy is focused, the |
| 379 // TabContentsContainerView is focused) and how to process tab events. If | 381 // TabContentsContainerView is focused) and how to process tab events. If |
| 380 // this returns NULL, the TabContents is supposed to know how to process TAB | 382 // this returns NULL, the TabContents is supposed to know how to process TAB |
| 381 // key events and is just sent the key messages. If this returns a RootView, | 383 // key events and is just sent the key messages. If this returns a RootView, |
| 382 // the focus is passed to the RootView. | 384 // the focus is passed to the RootView. |
| 383 virtual views::RootView* GetContentsRootView() { return NULL; } | 385 virtual views::RootView* GetContentsRootView() { return NULL; } |
| 384 | 386 |
| 387 // Infobars ------------------------------------------------------------------ |
| 388 |
| 389 // Adds an InfoBar for the specified |delegate|. |
| 390 void AddInfoBar(InfoBarDelegate* delegate); |
| 391 |
| 392 // Removes the InfoBar for the specified |delegate|. |
| 393 void RemoveInfoBar(InfoBarDelegate* delegate); |
| 394 |
| 395 // Enumeration and access functions. |
| 396 size_t infobar_delegate_count() const { return infobar_delegates_.size(); } |
| 397 InfoBarDelegate* GetInfoBarDelegateAt(size_t index) { |
| 398 return infobar_delegates_.at(index); |
| 399 } |
| 400 |
| 385 // Toolbars and such --------------------------------------------------------- | 401 // Toolbars and such --------------------------------------------------------- |
| 386 | 402 |
| 387 // Returns whether the bookmark bar should be visible. | 403 // Returns whether the bookmark bar should be visible. |
| 388 virtual bool IsBookmarkBarAlwaysVisible() { return false; } | 404 virtual bool IsBookmarkBarAlwaysVisible() { return false; } |
| 389 | 405 |
| 390 // Whether or not the shelf view is visible. | 406 // Whether or not the shelf view is visible. |
| 391 virtual void SetDownloadShelfVisible(bool visible); | 407 virtual void SetDownloadShelfVisible(bool visible); |
| 392 bool IsDownloadShelfVisible() { return shelf_visible_; } | 408 bool IsDownloadShelfVisible() { return shelf_visible_; } |
| 393 | 409 |
| 394 // Notify our delegate that some of our content has animated. | 410 // Notify our delegate that some of our content has animated. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 410 // want to generalize this if we need to migrate some other state. | 426 // want to generalize this if we need to migrate some other state. |
| 411 static void MigrateShelfView(TabContents* from, TabContents* to); | 427 static void MigrateShelfView(TabContents* from, TabContents* to); |
| 412 | 428 |
| 413 // Called when a ConstrainedWindow we own is about to be closed. | 429 // Called when a ConstrainedWindow we own is about to be closed. |
| 414 void WillClose(ConstrainedWindow* window); | 430 void WillClose(ConstrainedWindow* window); |
| 415 | 431 |
| 416 // Called when a ConstrainedWindow we own is moved or resized. | 432 // Called when a ConstrainedWindow we own is moved or resized. |
| 417 void DidMoveOrResize(ConstrainedWindow* window); | 433 void DidMoveOrResize(ConstrainedWindow* window); |
| 418 | 434 |
| 419 protected: | 435 protected: |
| 436 // NotificationObserver implementation: |
| 437 virtual void Observe(NotificationType type, |
| 438 const NotificationSource& source, |
| 439 const NotificationDetails& details); |
| 440 |
| 420 friend class NavigationController; | 441 friend class NavigationController; |
| 421 // Used to access the child_windows_ (ConstrainedWindowList) for testing | 442 // Used to access the child_windows_ (ConstrainedWindowList) for testing |
| 422 // automation purposes. | 443 // automation purposes. |
| 423 friend class AutomationProvider; | 444 friend class AutomationProvider; |
| 424 | 445 |
| 425 explicit TabContents(TabContentsType type); | 446 explicit TabContents(TabContentsType type); |
| 426 | 447 |
| 427 // Some tab contents types need to override the type. | 448 // Some tab contents types need to override the type. |
| 428 void set_type(TabContentsType type) { type_ = type; } | 449 void set_type(TabContentsType type) { type_ = type; } |
| 429 | 450 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 | 484 |
| 464 typedef std::vector<ConstrainedWindow*> ConstrainedWindowList; | 485 typedef std::vector<ConstrainedWindow*> ConstrainedWindowList; |
| 465 ConstrainedWindowList child_windows_; | 486 ConstrainedWindowList child_windows_; |
| 466 | 487 |
| 467 // Whether we have a notification AND the notification owns popups windows. | 488 // Whether we have a notification AND the notification owns popups windows. |
| 468 // (We keep the notification object around even when it's not shown since it | 489 // (We keep the notification object around even when it's not shown since it |
| 469 // determines whether to show itself). | 490 // determines whether to show itself). |
| 470 bool ShowingBlockedPopupNotification() const; | 491 bool ShowingBlockedPopupNotification() const; |
| 471 | 492 |
| 472 private: | 493 private: |
| 494 // Expires InfoBars that need to be expired, according to the state carried |
| 495 // in |details|, in response to a new NavigationEntry being committed (the |
| 496 // user navigated to another page). |
| 497 void ExpireInfoBars( |
| 498 const NavigationController::LoadCommittedDetails& details); |
| 499 |
| 473 // Data ---------------------------------------------------------------------- | 500 // Data ---------------------------------------------------------------------- |
| 474 | 501 |
| 475 TabContentsType type_; | 502 TabContentsType type_; |
| 476 | 503 |
| 477 TabContentsDelegate* delegate_; | 504 TabContentsDelegate* delegate_; |
| 478 NavigationController* controller_; | 505 NavigationController* controller_; |
| 479 | 506 |
| 480 // Indicates whether we're currently loading a resource. | 507 // Indicates whether we're currently loading a resource. |
| 481 bool is_loading_; | 508 bool is_loading_; |
| 482 | 509 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 505 int last_focused_view_storage_id_; | 532 int last_focused_view_storage_id_; |
| 506 | 533 |
| 507 // See capturing_contents() above. | 534 // See capturing_contents() above. |
| 508 bool capturing_contents_; | 535 bool capturing_contents_; |
| 509 | 536 |
| 510 // ConstrainedWindow with additional methods for managing blocked | 537 // ConstrainedWindow with additional methods for managing blocked |
| 511 // popups. This pointer alsog goes in |child_windows_| for ownership, | 538 // popups. This pointer alsog goes in |child_windows_| for ownership, |
| 512 // repositioning, etc. | 539 // repositioning, etc. |
| 513 BlockedPopupContainer* blocked_popups_; | 540 BlockedPopupContainer* blocked_popups_; |
| 514 | 541 |
| 542 // Delegates for InfoBars associated with this TabContents. |
| 543 std::vector<InfoBarDelegate*> infobar_delegates_; |
| 544 |
| 515 DISALLOW_COPY_AND_ASSIGN(TabContents); | 545 DISALLOW_COPY_AND_ASSIGN(TabContents); |
| 516 }; | 546 }; |
| 517 | 547 |
| 518 #endif // CHROME_BROWSER_TAB_CONTENTS_H_ | 548 #endif // CHROME_BROWSER_TAB_CONTENTS_H_ |
| OLD | NEW |