| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_ | 5 #ifndef CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_ |
| 6 #define CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_ | 6 #define CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <deque> | 9 #include <deque> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/string16.h" | 17 #include "base/string16.h" |
| 18 #include "chrome/browser/download/save_package.h" | 18 #include "chrome/browser/download/save_package.h" |
| 19 #include "chrome/browser/favicon_helper.h" |
| 19 #include "chrome/browser/prefs/pref_change_registrar.h" | 20 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 20 #include "chrome/browser/tab_contents/tab_specific_content_settings.h" | 21 #include "chrome/browser/tab_contents/tab_specific_content_settings.h" |
| 21 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" | 22 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" |
| 22 #include "chrome/common/instant_types.h" | 23 #include "chrome/common/instant_types.h" |
| 23 #include "chrome/common/translate_errors.h" | 24 #include "chrome/common/translate_errors.h" |
| 24 #include "content/browser/renderer_host/render_view_host_delegate.h" | 25 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 25 #include "content/browser/tab_contents/constrained_window.h" | 26 #include "content/browser/tab_contents/constrained_window.h" |
| 26 #include "content/browser/tab_contents/language_state.h" | 27 #include "content/browser/tab_contents/language_state.h" |
| 27 #include "content/browser/tab_contents/navigation_controller.h" | 28 #include "content/browser/tab_contents/navigation_controller.h" |
| 28 #include "content/browser/tab_contents/navigation_entry.h" | 29 #include "content/browser/tab_contents/navigation_entry.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 // time and can be NULL (during setup and teardown). | 165 // time and can be NULL (during setup and teardown). |
| 165 RenderWidgetHostView* GetRenderWidgetHostView() const { | 166 RenderWidgetHostView* GetRenderWidgetHostView() const { |
| 166 return render_manager_.GetRenderWidgetHostView(); | 167 return render_manager_.GetRenderWidgetHostView(); |
| 167 } | 168 } |
| 168 | 169 |
| 169 // The TabContentsView will never change and is guaranteed non-NULL. | 170 // The TabContentsView will never change and is guaranteed non-NULL. |
| 170 TabContentsView* view() const { | 171 TabContentsView* view() const { |
| 171 return view_.get(); | 172 return view_.get(); |
| 172 } | 173 } |
| 173 | 174 |
| 175 // Returns the FaviconHelper of this TabContents. |
| 176 FaviconHelper& favicon_helper() { |
| 177 return *favicon_helper_.get(); |
| 178 } |
| 179 |
| 174 // Tab navigation state ------------------------------------------------------ | 180 // Tab navigation state ------------------------------------------------------ |
| 175 | 181 |
| 176 // Returns the current navigation properties, which if a navigation is | 182 // Returns the current navigation properties, which if a navigation is |
| 177 // pending may be provisional (e.g., the navigation could result in a | 183 // pending may be provisional (e.g., the navigation could result in a |
| 178 // download, in which case the URL would revert to what it was previously). | 184 // download, in which case the URL would revert to what it was previously). |
| 179 virtual const GURL& GetURL() const; | 185 virtual const GURL& GetURL() const; |
| 180 virtual const string16& GetTitle() const; | 186 virtual const string16& GetTitle() const; |
| 181 | 187 |
| 182 // The max PageID of any page that this TabContents has loaded. PageIDs | 188 // The max PageID of any page that this TabContents has loaded. PageIDs |
| 183 // increase with each new page that is loaded by a tab. If this is a | 189 // increase with each new page that is loaded by a tab. If this is a |
| 184 // TabContents, then the max PageID is kept separately on each SiteInstance. | 190 // TabContents, then the max PageID is kept separately on each SiteInstance. |
| 185 // Returns -1 if no PageIDs have yet been seen. | 191 // Returns -1 if no PageIDs have yet been seen. |
| 186 int32 GetMaxPageID(); | 192 int32 GetMaxPageID(); |
| 187 | 193 |
| 188 // Updates the max PageID to be at least the given PageID. | 194 // Updates the max PageID to be at least the given PageID. |
| 189 void UpdateMaxPageID(int32 page_id); | 195 void UpdateMaxPageID(int32 page_id); |
| 190 | 196 |
| 191 // Returns the site instance associated with the current page. By default, | 197 // Returns the site instance associated with the current page. By default, |
| 192 // there is no site instance. TabContents overrides this to provide proper | 198 // there is no site instance. TabContents overrides this to provide proper |
| 193 // access to its site instance. | 199 // access to its site instance. |
| 194 virtual SiteInstance* GetSiteInstance() const; | 200 virtual SiteInstance* GetSiteInstance() const; |
| 195 | 201 |
| 196 // Defines whether this tab's URL should be displayed in the browser's URL | 202 // Defines whether this tab's URL should be displayed in the browser's URL |
| 197 // bar. Normally this is true so you can see the URL. This is set to false | 203 // bar. Normally this is true so you can see the URL. This is set to false |
| 198 // for the new tab page and related pages so that the URL bar is empty and | 204 // for the new tab page and related pages so that the URL bar is empty and |
| 199 // the user is invited to type into it. | 205 // the user is invited to type into it. |
| 200 virtual bool ShouldDisplayURL(); | 206 virtual bool ShouldDisplayURL(); |
| 201 | 207 |
| 208 // Returns the favicon for this tab, or an isNull() bitmap if the tab does not |
| 209 // have a favicon. The default implementation uses the current navigation |
| 210 // entry. |
| 211 SkBitmap GetFavicon() const; |
| 212 |
| 213 // Returns true if we are not using the default favicon. |
| 214 bool FaviconIsValid() const; |
| 215 |
| 216 // Returns whether the favicon should be displayed. If this returns false, no |
| 217 // space is provided for the favicon, and the favicon is never displayed. |
| 218 virtual bool ShouldDisplayFavicon(); |
| 219 |
| 202 // Return whether this tab contents is loading a resource. | 220 // Return whether this tab contents is loading a resource. |
| 203 bool is_loading() const { return is_loading_; } | 221 bool is_loading() const { return is_loading_; } |
| 204 | 222 |
| 205 // Returns whether this tab contents is waiting for a first-response for the | 223 // Returns whether this tab contents is waiting for a first-response for the |
| 206 // main resource of the page. This controls whether the throbber state is | 224 // main resource of the page. This controls whether the throbber state is |
| 207 // "waiting" or "loading." | 225 // "waiting" or "loading." |
| 208 bool waiting_for_response() const { return waiting_for_response_; } | 226 bool waiting_for_response() const { return waiting_for_response_; } |
| 209 | 227 |
| 210 net::LoadState load_state() const { return load_state_; } | 228 net::LoadState load_state() const { return load_state_; } |
| 211 string16 load_state_host() const { return load_state_host_; } | 229 string16 load_state_host() const { return load_state_host_; } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 | 334 |
| 317 // Creates a new TabContents with the same state as this one. The returned | 335 // Creates a new TabContents with the same state as this one. The returned |
| 318 // heap-allocated pointer is owned by the caller. | 336 // heap-allocated pointer is owned by the caller. |
| 319 virtual TabContents* Clone(); | 337 virtual TabContents* Clone(); |
| 320 | 338 |
| 321 // Shows the page info. | 339 // Shows the page info. |
| 322 void ShowPageInfo(const GURL& url, | 340 void ShowPageInfo(const GURL& url, |
| 323 const NavigationEntry::SSLStatus& ssl, | 341 const NavigationEntry::SSLStatus& ssl, |
| 324 bool show_history); | 342 bool show_history); |
| 325 | 343 |
| 344 // Saves the favicon for the current page. |
| 345 void SaveFavicon(); |
| 346 |
| 326 // Window management --------------------------------------------------------- | 347 // Window management --------------------------------------------------------- |
| 327 | 348 |
| 328 // Create a new window constrained to this TabContents' clip and visibility. | 349 // Create a new window constrained to this TabContents' clip and visibility. |
| 329 // The window is initialized by using the supplied delegate to obtain basic | 350 // The window is initialized by using the supplied delegate to obtain basic |
| 330 // window characteristics, and the supplied view for the content. Note that | 351 // window characteristics, and the supplied view for the content. Note that |
| 331 // the returned ConstrainedWindow might not yet be visible. | 352 // the returned ConstrainedWindow might not yet be visible. |
| 332 ConstrainedWindow* CreateConstrainedDialog( | 353 ConstrainedWindow* CreateConstrainedDialog( |
| 333 ConstrainedWindowDelegate* delegate); | 354 ConstrainedWindowDelegate* delegate); |
| 334 | 355 |
| 335 // Adds a new tab or window with the given already-created contents | 356 // Adds a new tab or window with the given already-created contents |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 int content_restrictions() const { return content_restrictions_; } | 629 int content_restrictions() const { return content_restrictions_; } |
| 609 void SetContentRestrictions(int restrictions); | 630 void SetContentRestrictions(int restrictions); |
| 610 | 631 |
| 611 safe_browsing::ClientSideDetectionHost* safebrowsing_detection_host() { | 632 safe_browsing::ClientSideDetectionHost* safebrowsing_detection_host() { |
| 612 return safebrowsing_detection_host_.get(); | 633 return safebrowsing_detection_host_.get(); |
| 613 } | 634 } |
| 614 | 635 |
| 615 // Query the WebUIFactory for the TypeID for the current URL. | 636 // Query the WebUIFactory for the TypeID for the current URL. |
| 616 WebUI::TypeID GetWebUITypeForCurrentState(); | 637 WebUI::TypeID GetWebUITypeForCurrentState(); |
| 617 | 638 |
| 618 // Returns the WebUI for the current state of the tab. This will either be | |
| 619 // the pending WebUI, the committed WebUI, or NULL. | |
| 620 WebUI* GetWebUIForCurrentState(); | |
| 621 | |
| 622 protected: | 639 protected: |
| 623 friend class TabContentsObserver; | 640 friend class TabContentsObserver; |
| 624 friend class TabContentsObserver::Registrar; | 641 friend class TabContentsObserver::Registrar; |
| 625 | 642 |
| 626 // Add and remove observers for page navigation notifications. Adding or | 643 // Add and remove observers for page navigation notifications. Adding or |
| 627 // removing multiple times has no effect. The order in which notifications | 644 // removing multiple times has no effect. The order in which notifications |
| 628 // are sent to observers is undefined. Clients must be sure to remove the | 645 // are sent to observers is undefined. Clients must be sure to remove the |
| 629 // observer before they go away. | 646 // observer before they go away. |
| 630 void AddObserver(TabContentsObserver* observer); | 647 void AddObserver(TabContentsObserver* observer); |
| 631 void RemoveObserver(TabContentsObserver* observer); | 648 void RemoveObserver(TabContentsObserver* observer); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 void SetNotWaitingForResponse() { waiting_for_response_ = false; } | 738 void SetNotWaitingForResponse() { waiting_for_response_ = false; } |
| 722 | 739 |
| 723 ConstrainedWindowList child_windows_; | 740 ConstrainedWindowList child_windows_; |
| 724 | 741 |
| 725 // Expires InfoBars that need to be expired, according to the state carried | 742 // Expires InfoBars that need to be expired, according to the state carried |
| 726 // in |details|, in response to a new NavigationEntry being committed (the | 743 // in |details|, in response to a new NavigationEntry being committed (the |
| 727 // user navigated to another page). | 744 // user navigated to another page). |
| 728 void ExpireInfoBars( | 745 void ExpireInfoBars( |
| 729 const NavigationController::LoadCommittedDetails& details); | 746 const NavigationController::LoadCommittedDetails& details); |
| 730 | 747 |
| 748 // Returns the WebUI for the current state of the tab. This will either be |
| 749 // the pending WebUI, the committed WebUI, or NULL. |
| 750 WebUI* GetWebUIForCurrentState(); |
| 751 |
| 731 // Navigation helpers -------------------------------------------------------- | 752 // Navigation helpers -------------------------------------------------------- |
| 732 // | 753 // |
| 733 // These functions are helpers for Navigate() and DidNavigate(). | 754 // These functions are helpers for Navigate() and DidNavigate(). |
| 734 | 755 |
| 735 // Handles post-navigation tasks in DidNavigate AFTER the entry has been | 756 // Handles post-navigation tasks in DidNavigate AFTER the entry has been |
| 736 // committed to the navigation controller. Note that the navigation entry is | 757 // committed to the navigation controller. Note that the navigation entry is |
| 737 // not provided since it may be invalid/changed after being committed. The | 758 // not provided since it may be invalid/changed after being committed. The |
| 738 // current navigation entry is in the NavigationController at this point. | 759 // current navigation entry is in the NavigationController at this point. |
| 739 void DidNavigateMainFramePostCommit( | 760 void DidNavigateMainFramePostCommit( |
| 740 const NavigationController::LoadCommittedDetails& details, | 761 const NavigationController::LoadCommittedDetails& details, |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 | 967 |
| 947 // Handles plugin messages. | 968 // Handles plugin messages. |
| 948 scoped_ptr<PluginObserver> plugin_observer_; | 969 scoped_ptr<PluginObserver> plugin_observer_; |
| 949 | 970 |
| 950 // TabContentsSSLHelper, lazily created. | 971 // TabContentsSSLHelper, lazily created. |
| 951 scoped_ptr<TabContentsSSLHelper> ssl_helper_; | 972 scoped_ptr<TabContentsSSLHelper> ssl_helper_; |
| 952 | 973 |
| 953 // Handles drag and drop event forwarding to extensions. | 974 // Handles drag and drop event forwarding to extensions. |
| 954 BookmarkDrag* bookmark_drag_; | 975 BookmarkDrag* bookmark_drag_; |
| 955 | 976 |
| 977 // Handles downloading favicons. |
| 978 scoped_ptr<FaviconHelper> favicon_helper_; |
| 979 |
| 956 // RenderViewHost::ContentSettingsDelegate. | 980 // RenderViewHost::ContentSettingsDelegate. |
| 957 scoped_ptr<TabSpecificContentSettings> content_settings_delegate_; | 981 scoped_ptr<TabSpecificContentSettings> content_settings_delegate_; |
| 958 | 982 |
| 959 // Handles desktop notification IPCs. | 983 // Handles desktop notification IPCs. |
| 960 scoped_ptr<DesktopNotificationHandlerForTC> desktop_notification_handler_; | 984 scoped_ptr<DesktopNotificationHandlerForTC> desktop_notification_handler_; |
| 961 | 985 |
| 962 // Handles IPCs related to SafeBrowsing client-side phishing detection. | 986 // Handles IPCs related to SafeBrowsing client-side phishing detection. |
| 963 scoped_ptr<safe_browsing::ClientSideDetectionHost> | 987 scoped_ptr<safe_browsing::ClientSideDetectionHost> |
| 964 safebrowsing_detection_host_; | 988 safebrowsing_detection_host_; |
| 965 | 989 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 | 1055 |
| 1032 // See getter above. | 1056 // See getter above. |
| 1033 bool is_being_destroyed_; | 1057 bool is_being_destroyed_; |
| 1034 | 1058 |
| 1035 // Indicates whether we should notify about disconnection of this | 1059 // Indicates whether we should notify about disconnection of this |
| 1036 // TabContents. This is used to ensure disconnection notifications only | 1060 // TabContents. This is used to ensure disconnection notifications only |
| 1037 // happen if a connection notification has happened and that they happen only | 1061 // happen if a connection notification has happened and that they happen only |
| 1038 // once. | 1062 // once. |
| 1039 bool notify_disconnection_; | 1063 bool notify_disconnection_; |
| 1040 | 1064 |
| 1065 // Maps from handle to page_id. |
| 1066 typedef std::map<FaviconService::Handle, int32> HistoryRequestMap; |
| 1067 HistoryRequestMap history_requests_; |
| 1068 |
| 1041 #if defined(OS_WIN) | 1069 #if defined(OS_WIN) |
| 1042 // Handle to an event that's set when the page is showing a message box (or | 1070 // Handle to an event that's set when the page is showing a message box (or |
| 1043 // equivalent constrained window). Plugin processes check this to know if | 1071 // equivalent constrained window). Plugin processes check this to know if |
| 1044 // they should pump messages then. | 1072 // they should pump messages then. |
| 1045 base::win::ScopedHandle message_box_active_; | 1073 base::win::ScopedHandle message_box_active_; |
| 1046 #endif | 1074 #endif |
| 1047 | 1075 |
| 1048 // The time that the last javascript message was dismissed. | 1076 // The time that the last javascript message was dismissed. |
| 1049 base::TimeTicks last_javascript_message_dismissal_; | 1077 base::TimeTicks last_javascript_message_dismissal_; |
| 1050 | 1078 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 ObserverList<TabContentsObserver> observers_; | 1123 ObserverList<TabContentsObserver> observers_; |
| 1096 | 1124 |
| 1097 // Content restrictions, used to disable print/copy etc based on content's | 1125 // Content restrictions, used to disable print/copy etc based on content's |
| 1098 // (full-page plugins for now only) permissions. | 1126 // (full-page plugins for now only) permissions. |
| 1099 int content_restrictions_; | 1127 int content_restrictions_; |
| 1100 | 1128 |
| 1101 DISALLOW_COPY_AND_ASSIGN(TabContents); | 1129 DISALLOW_COPY_AND_ASSIGN(TabContents); |
| 1102 }; | 1130 }; |
| 1103 | 1131 |
| 1104 #endif // CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_ | 1132 #endif // CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_ |
| OLD | NEW |