| 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" | |
| 20 #include "chrome/browser/prefs/pref_change_registrar.h" | 19 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 21 #include "chrome/browser/tab_contents/tab_specific_content_settings.h" | 20 #include "chrome/browser/tab_contents/tab_specific_content_settings.h" |
| 22 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" | 21 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" |
| 23 #include "chrome/common/instant_types.h" | 22 #include "chrome/common/instant_types.h" |
| 24 #include "chrome/common/translate_errors.h" | 23 #include "chrome/common/translate_errors.h" |
| 25 #include "chrome/common/web_apps.h" | 24 #include "chrome/common/web_apps.h" |
| 26 #include "content/browser/renderer_host/render_view_host_delegate.h" | 25 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 27 #include "content/browser/tab_contents/constrained_window.h" | 26 #include "content/browser/tab_contents/constrained_window.h" |
| 28 #include "content/browser/tab_contents/language_state.h" | 27 #include "content/browser/tab_contents/language_state.h" |
| 29 #include "content/browser/tab_contents/navigation_controller.h" | 28 #include "content/browser/tab_contents/navigation_controller.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 // time and can be NULL (during setup and teardown). | 165 // time and can be NULL (during setup and teardown). |
| 167 RenderWidgetHostView* GetRenderWidgetHostView() const { | 166 RenderWidgetHostView* GetRenderWidgetHostView() const { |
| 168 return render_manager_.GetRenderWidgetHostView(); | 167 return render_manager_.GetRenderWidgetHostView(); |
| 169 } | 168 } |
| 170 | 169 |
| 171 // The TabContentsView will never change and is guaranteed non-NULL. | 170 // The TabContentsView will never change and is guaranteed non-NULL. |
| 172 TabContentsView* view() const { | 171 TabContentsView* view() const { |
| 173 return view_.get(); | 172 return view_.get(); |
| 174 } | 173 } |
| 175 | 174 |
| 176 // Returns the FaviconHelper of this TabContents. | |
| 177 FaviconHelper& favicon_helper() { | |
| 178 return *favicon_helper_.get(); | |
| 179 } | |
| 180 | |
| 181 // Tab navigation state ------------------------------------------------------ | 175 // Tab navigation state ------------------------------------------------------ |
| 182 | 176 |
| 183 // Returns the current navigation properties, which if a navigation is | 177 // Returns the current navigation properties, which if a navigation is |
| 184 // pending may be provisional (e.g., the navigation could result in a | 178 // pending may be provisional (e.g., the navigation could result in a |
| 185 // download, in which case the URL would revert to what it was previously). | 179 // download, in which case the URL would revert to what it was previously). |
| 186 virtual const GURL& GetURL() const; | 180 virtual const GURL& GetURL() const; |
| 187 virtual const string16& GetTitle() const; | 181 virtual const string16& GetTitle() const; |
| 188 | 182 |
| 189 // The max PageID of any page that this TabContents has loaded. PageIDs | 183 // The max PageID of any page that this TabContents has loaded. PageIDs |
| 190 // increase with each new page that is loaded by a tab. If this is a | 184 // increase with each new page that is loaded by a tab. If this is a |
| 191 // TabContents, then the max PageID is kept separately on each SiteInstance. | 185 // TabContents, then the max PageID is kept separately on each SiteInstance. |
| 192 // Returns -1 if no PageIDs have yet been seen. | 186 // Returns -1 if no PageIDs have yet been seen. |
| 193 int32 GetMaxPageID(); | 187 int32 GetMaxPageID(); |
| 194 | 188 |
| 195 // Updates the max PageID to be at least the given PageID. | 189 // Updates the max PageID to be at least the given PageID. |
| 196 void UpdateMaxPageID(int32 page_id); | 190 void UpdateMaxPageID(int32 page_id); |
| 197 | 191 |
| 198 // Returns the site instance associated with the current page. By default, | 192 // Returns the site instance associated with the current page. By default, |
| 199 // there is no site instance. TabContents overrides this to provide proper | 193 // there is no site instance. TabContents overrides this to provide proper |
| 200 // access to its site instance. | 194 // access to its site instance. |
| 201 virtual SiteInstance* GetSiteInstance() const; | 195 virtual SiteInstance* GetSiteInstance() const; |
| 202 | 196 |
| 203 // Defines whether this tab's URL should be displayed in the browser's URL | 197 // Defines whether this tab's URL should be displayed in the browser's URL |
| 204 // bar. Normally this is true so you can see the URL. This is set to false | 198 // bar. Normally this is true so you can see the URL. This is set to false |
| 205 // for the new tab page and related pages so that the URL bar is empty and | 199 // for the new tab page and related pages so that the URL bar is empty and |
| 206 // the user is invited to type into it. | 200 // the user is invited to type into it. |
| 207 virtual bool ShouldDisplayURL(); | 201 virtual bool ShouldDisplayURL(); |
| 208 | 202 |
| 209 // Returns the favicon for this tab, or an isNull() bitmap if the tab does not | |
| 210 // have a favicon. The default implementation uses the current navigation | |
| 211 // entry. | |
| 212 SkBitmap GetFavicon() const; | |
| 213 | |
| 214 // Returns true if we are not using the default favicon. | |
| 215 bool FaviconIsValid() const; | |
| 216 | |
| 217 // Returns whether the favicon should be displayed. If this returns false, no | |
| 218 // space is provided for the favicon, and the favicon is never displayed. | |
| 219 virtual bool ShouldDisplayFavicon(); | |
| 220 | |
| 221 // Return whether this tab contents is loading a resource. | 203 // Return whether this tab contents is loading a resource. |
| 222 bool is_loading() const { return is_loading_; } | 204 bool is_loading() const { return is_loading_; } |
| 223 | 205 |
| 224 // Returns whether this tab contents is waiting for a first-response for the | 206 // Returns whether this tab contents is waiting for a first-response for the |
| 225 // main resource of the page. This controls whether the throbber state is | 207 // main resource of the page. This controls whether the throbber state is |
| 226 // "waiting" or "loading." | 208 // "waiting" or "loading." |
| 227 bool waiting_for_response() const { return waiting_for_response_; } | 209 bool waiting_for_response() const { return waiting_for_response_; } |
| 228 | 210 |
| 229 net::LoadState load_state() const { return load_state_; } | 211 net::LoadState load_state() const { return load_state_; } |
| 230 string16 load_state_host() const { return load_state_host_; } | 212 string16 load_state_host() const { return load_state_host_; } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 | 323 |
| 342 // Creates a new TabContents with the same state as this one. The returned | 324 // Creates a new TabContents with the same state as this one. The returned |
| 343 // heap-allocated pointer is owned by the caller. | 325 // heap-allocated pointer is owned by the caller. |
| 344 virtual TabContents* Clone(); | 326 virtual TabContents* Clone(); |
| 345 | 327 |
| 346 // Shows the page info. | 328 // Shows the page info. |
| 347 void ShowPageInfo(const GURL& url, | 329 void ShowPageInfo(const GURL& url, |
| 348 const NavigationEntry::SSLStatus& ssl, | 330 const NavigationEntry::SSLStatus& ssl, |
| 349 bool show_history); | 331 bool show_history); |
| 350 | 332 |
| 351 // Saves the favicon for the current page. | |
| 352 void SaveFavicon(); | |
| 353 | |
| 354 // Window management --------------------------------------------------------- | 333 // Window management --------------------------------------------------------- |
| 355 | 334 |
| 356 // Create a new window constrained to this TabContents' clip and visibility. | 335 // Create a new window constrained to this TabContents' clip and visibility. |
| 357 // The window is initialized by using the supplied delegate to obtain basic | 336 // The window is initialized by using the supplied delegate to obtain basic |
| 358 // window characteristics, and the supplied view for the content. Note that | 337 // window characteristics, and the supplied view for the content. Note that |
| 359 // the returned ConstrainedWindow might not yet be visible. | 338 // the returned ConstrainedWindow might not yet be visible. |
| 360 ConstrainedWindow* CreateConstrainedDialog( | 339 ConstrainedWindow* CreateConstrainedDialog( |
| 361 ConstrainedWindowDelegate* delegate); | 340 ConstrainedWindowDelegate* delegate); |
| 362 | 341 |
| 363 // Adds a new tab or window with the given already-created contents | 342 // 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... |
| 636 int content_restrictions() const { return content_restrictions_; } | 615 int content_restrictions() const { return content_restrictions_; } |
| 637 void SetContentRestrictions(int restrictions); | 616 void SetContentRestrictions(int restrictions); |
| 638 | 617 |
| 639 safe_browsing::ClientSideDetectionHost* safebrowsing_detection_host() { | 618 safe_browsing::ClientSideDetectionHost* safebrowsing_detection_host() { |
| 640 return safebrowsing_detection_host_.get(); | 619 return safebrowsing_detection_host_.get(); |
| 641 } | 620 } |
| 642 | 621 |
| 643 // Query the WebUIFactory for the TypeID for the current URL. | 622 // Query the WebUIFactory for the TypeID for the current URL. |
| 644 WebUI::TypeID GetWebUITypeForCurrentState(); | 623 WebUI::TypeID GetWebUITypeForCurrentState(); |
| 645 | 624 |
| 625 // Returns the WebUI for the current state of the tab. This will either be |
| 626 // the pending WebUI, the committed WebUI, or NULL. |
| 627 WebUI* GetWebUIForCurrentState(); |
| 628 |
| 646 protected: | 629 protected: |
| 647 friend class TabContentsObserver; | 630 friend class TabContentsObserver; |
| 648 friend class TabContentsObserver::Registrar; | 631 friend class TabContentsObserver::Registrar; |
| 649 | 632 |
| 650 // Add and remove observers for page navigation notifications. Adding or | 633 // Add and remove observers for page navigation notifications. Adding or |
| 651 // removing multiple times has no effect. The order in which notifications | 634 // removing multiple times has no effect. The order in which notifications |
| 652 // are sent to observers is undefined. Clients must be sure to remove the | 635 // are sent to observers is undefined. Clients must be sure to remove the |
| 653 // observer before they go away. | 636 // observer before they go away. |
| 654 void AddObserver(TabContentsObserver* observer); | 637 void AddObserver(TabContentsObserver* observer); |
| 655 void RemoveObserver(TabContentsObserver* observer); | 638 void RemoveObserver(TabContentsObserver* observer); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 void SetNotWaitingForResponse() { waiting_for_response_ = false; } | 728 void SetNotWaitingForResponse() { waiting_for_response_ = false; } |
| 746 | 729 |
| 747 ConstrainedWindowList child_windows_; | 730 ConstrainedWindowList child_windows_; |
| 748 | 731 |
| 749 // Expires InfoBars that need to be expired, according to the state carried | 732 // Expires InfoBars that need to be expired, according to the state carried |
| 750 // in |details|, in response to a new NavigationEntry being committed (the | 733 // in |details|, in response to a new NavigationEntry being committed (the |
| 751 // user navigated to another page). | 734 // user navigated to another page). |
| 752 void ExpireInfoBars( | 735 void ExpireInfoBars( |
| 753 const NavigationController::LoadCommittedDetails& details); | 736 const NavigationController::LoadCommittedDetails& details); |
| 754 | 737 |
| 755 // Returns the WebUI for the current state of the tab. This will either be | |
| 756 // the pending WebUI, the committed WebUI, or NULL. | |
| 757 WebUI* GetWebUIForCurrentState(); | |
| 758 | |
| 759 // Navigation helpers -------------------------------------------------------- | 738 // Navigation helpers -------------------------------------------------------- |
| 760 // | 739 // |
| 761 // These functions are helpers for Navigate() and DidNavigate(). | 740 // These functions are helpers for Navigate() and DidNavigate(). |
| 762 | 741 |
| 763 // Handles post-navigation tasks in DidNavigate AFTER the entry has been | 742 // Handles post-navigation tasks in DidNavigate AFTER the entry has been |
| 764 // committed to the navigation controller. Note that the navigation entry is | 743 // committed to the navigation controller. Note that the navigation entry is |
| 765 // not provided since it may be invalid/changed after being committed. The | 744 // not provided since it may be invalid/changed after being committed. The |
| 766 // current navigation entry is in the NavigationController at this point. | 745 // current navigation entry is in the NavigationController at this point. |
| 767 void DidNavigateMainFramePostCommit( | 746 void DidNavigateMainFramePostCommit( |
| 768 const NavigationController::LoadCommittedDetails& details, | 747 const NavigationController::LoadCommittedDetails& details, |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 | 953 |
| 975 // Handles plugin messages. | 954 // Handles plugin messages. |
| 976 scoped_ptr<PluginObserver> plugin_observer_; | 955 scoped_ptr<PluginObserver> plugin_observer_; |
| 977 | 956 |
| 978 // TabContentsSSLHelper, lazily created. | 957 // TabContentsSSLHelper, lazily created. |
| 979 scoped_ptr<TabContentsSSLHelper> ssl_helper_; | 958 scoped_ptr<TabContentsSSLHelper> ssl_helper_; |
| 980 | 959 |
| 981 // Handles drag and drop event forwarding to extensions. | 960 // Handles drag and drop event forwarding to extensions. |
| 982 BookmarkDrag* bookmark_drag_; | 961 BookmarkDrag* bookmark_drag_; |
| 983 | 962 |
| 984 // Handles downloading favicons. | |
| 985 scoped_ptr<FaviconHelper> favicon_helper_; | |
| 986 | |
| 987 // Cached web app icon. | 963 // Cached web app icon. |
| 988 SkBitmap app_icon_; | 964 SkBitmap app_icon_; |
| 989 | 965 |
| 990 // RenderViewHost::ContentSettingsDelegate. | 966 // RenderViewHost::ContentSettingsDelegate. |
| 991 scoped_ptr<TabSpecificContentSettings> content_settings_delegate_; | 967 scoped_ptr<TabSpecificContentSettings> content_settings_delegate_; |
| 992 | 968 |
| 993 // Handles desktop notification IPCs. | 969 // Handles desktop notification IPCs. |
| 994 scoped_ptr<DesktopNotificationHandlerForTC> desktop_notification_handler_; | 970 scoped_ptr<DesktopNotificationHandlerForTC> desktop_notification_handler_; |
| 995 | 971 |
| 996 // Handles IPCs related to SafeBrowsing client-side phishing detection. | 972 // Handles IPCs related to SafeBrowsing client-side phishing detection. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 | 1041 |
| 1066 // See getter above. | 1042 // See getter above. |
| 1067 bool is_being_destroyed_; | 1043 bool is_being_destroyed_; |
| 1068 | 1044 |
| 1069 // Indicates whether we should notify about disconnection of this | 1045 // Indicates whether we should notify about disconnection of this |
| 1070 // TabContents. This is used to ensure disconnection notifications only | 1046 // TabContents. This is used to ensure disconnection notifications only |
| 1071 // happen if a connection notification has happened and that they happen only | 1047 // happen if a connection notification has happened and that they happen only |
| 1072 // once. | 1048 // once. |
| 1073 bool notify_disconnection_; | 1049 bool notify_disconnection_; |
| 1074 | 1050 |
| 1075 // Maps from handle to page_id. | |
| 1076 typedef std::map<FaviconService::Handle, int32> HistoryRequestMap; | |
| 1077 HistoryRequestMap history_requests_; | |
| 1078 | |
| 1079 #if defined(OS_WIN) | 1051 #if defined(OS_WIN) |
| 1080 // Handle to an event that's set when the page is showing a message box (or | 1052 // Handle to an event that's set when the page is showing a message box (or |
| 1081 // equivalent constrained window). Plugin processes check this to know if | 1053 // equivalent constrained window). Plugin processes check this to know if |
| 1082 // they should pump messages then. | 1054 // they should pump messages then. |
| 1083 base::win::ScopedHandle message_box_active_; | 1055 base::win::ScopedHandle message_box_active_; |
| 1084 #endif | 1056 #endif |
| 1085 | 1057 |
| 1086 // The time that the last javascript message was dismissed. | 1058 // The time that the last javascript message was dismissed. |
| 1087 base::TimeTicks last_javascript_message_dismissal_; | 1059 base::TimeTicks last_javascript_message_dismissal_; |
| 1088 | 1060 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 ObserverList<TabContentsObserver> observers_; | 1105 ObserverList<TabContentsObserver> observers_; |
| 1134 | 1106 |
| 1135 // Content restrictions, used to disable print/copy etc based on content's | 1107 // Content restrictions, used to disable print/copy etc based on content's |
| 1136 // (full-page plugins for now only) permissions. | 1108 // (full-page plugins for now only) permissions. |
| 1137 int content_restrictions_; | 1109 int content_restrictions_; |
| 1138 | 1110 |
| 1139 DISALLOW_COPY_AND_ASSIGN(TabContents); | 1111 DISALLOW_COPY_AND_ASSIGN(TabContents); |
| 1140 }; | 1112 }; |
| 1141 | 1113 |
| 1142 #endif // CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_ | 1114 #endif // CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_ |
| OLD | NEW |