| 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 CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_ | 5 #ifndef CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_ |
| 6 #define CHROME_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/scoped_ptr.h" | 16 #include "base/scoped_ptr.h" |
| 17 #include "base/string16.h" | 17 #include "base/string16.h" |
| 18 #include "chrome/browser/dom_ui/web_ui_factory.h" | |
| 19 #include "chrome/browser/download/save_package.h" | 18 #include "chrome/browser/download/save_package.h" |
| 20 #include "chrome/browser/extensions/image_loading_tracker.h" | 19 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 21 #include "chrome/browser/fav_icon_helper.h" | 20 #include "chrome/browser/fav_icon_helper.h" |
| 22 #include "chrome/browser/prefs/pref_change_registrar.h" | 21 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 23 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 22 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
| 24 #include "chrome/browser/tab_contents/constrained_window.h" | |
| 25 #include "chrome/browser/tab_contents/language_state.h" | |
| 26 #include "chrome/browser/tab_contents/navigation_controller.h" | |
| 27 #include "chrome/browser/tab_contents/navigation_entry.h" | |
| 28 #include "chrome/browser/tab_contents/page_navigator.h" | |
| 29 #include "chrome/browser/tab_contents/render_view_host_manager.h" | |
| 30 #include "chrome/browser/tab_contents/tab_specific_content_settings.h" | 23 #include "chrome/browser/tab_contents/tab_specific_content_settings.h" |
| 31 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" | 24 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" |
| 25 #include "chrome/browser/webui/web_ui_factory.h" |
| 32 #include "chrome/common/notification_registrar.h" | 26 #include "chrome/common/notification_registrar.h" |
| 33 #include "chrome/common/property_bag.h" | 27 #include "chrome/common/property_bag.h" |
| 34 #include "chrome/common/renderer_preferences.h" | 28 #include "chrome/common/renderer_preferences.h" |
| 35 #include "chrome/common/translate_errors.h" | 29 #include "chrome/common/translate_errors.h" |
| 36 #include "chrome/common/web_apps.h" | 30 #include "chrome/common/web_apps.h" |
| 31 #include "content/browser/tab_contents/constrained_window.h" |
| 32 #include "content/browser/tab_contents/language_state.h" |
| 33 #include "content/browser/tab_contents/navigation_controller.h" |
| 34 #include "content/browser/tab_contents/navigation_entry.h" |
| 35 #include "content/browser/tab_contents/page_navigator.h" |
| 36 #include "content/browser/tab_contents/render_view_host_manager.h" |
| 37 #include "net/base/load_states.h" | 37 #include "net/base/load_states.h" |
| 38 #include "ui/gfx/native_widget_types.h" | 38 #include "ui/gfx/native_widget_types.h" |
| 39 | 39 |
| 40 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
| 41 #include "base/win/scoped_handle.h" | 41 #include "base/win/scoped_handle.h" |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 namespace gfx { | 44 namespace gfx { |
| 45 class Rect; | 45 class Rect; |
| 46 } | 46 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // tab contentses to share the same session storage (part of the WebStorage | 123 // tab contentses to share the same session storage (part of the WebStorage |
| 124 // spec) space. This is useful when restoring tabs, but most callers should | 124 // spec) space. This is useful when restoring tabs, but most callers should |
| 125 // pass in NULL which will cause a new SessionStorageNamespace to be created. | 125 // pass in NULL which will cause a new SessionStorageNamespace to be created. |
| 126 TabContents(Profile* profile, | 126 TabContents(Profile* profile, |
| 127 SiteInstance* site_instance, | 127 SiteInstance* site_instance, |
| 128 int routing_id, | 128 int routing_id, |
| 129 const TabContents* base_tab_contents, | 129 const TabContents* base_tab_contents, |
| 130 SessionStorageNamespace* session_storage_namespace); | 130 SessionStorageNamespace* session_storage_namespace); |
| 131 virtual ~TabContents(); | 131 virtual ~TabContents(); |
| 132 | 132 |
| 133 static void RegisterUserPrefs(PrefService* prefs); | |
| 134 | |
| 135 // Intrinsic tab state ------------------------------------------------------- | 133 // Intrinsic tab state ------------------------------------------------------- |
| 136 | 134 |
| 137 // Returns the property bag for this tab contents, where callers can add | 135 // Returns the property bag for this tab contents, where callers can add |
| 138 // extra data they may wish to associate with the tab. Returns a pointer | 136 // extra data they may wish to associate with the tab. Returns a pointer |
| 139 // rather than a reference since the PropertyAccessors expect this. | 137 // rather than a reference since the PropertyAccessors expect this. |
| 140 const PropertyBag* property_bag() const { return &property_bag_; } | 138 const PropertyBag* property_bag() const { return &property_bag_; } |
| 141 PropertyBag* property_bag() { return &property_bag_; } | 139 PropertyBag* property_bag() { return &property_bag_; } |
| 142 | 140 |
| 143 TabContentsDelegate* delegate() const { return delegate_; } | 141 TabContentsDelegate* delegate() const { return delegate_; } |
| 144 void set_delegate(TabContentsDelegate* d) { delegate_ = d; } | 142 void set_delegate(TabContentsDelegate* d) { delegate_ = d; } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 SkBitmap* GetExtensionAppIcon(); | 213 SkBitmap* GetExtensionAppIcon(); |
| 216 | 214 |
| 217 // Tab navigation state ------------------------------------------------------ | 215 // Tab navigation state ------------------------------------------------------ |
| 218 | 216 |
| 219 // Returns the current navigation properties, which if a navigation is | 217 // Returns the current navigation properties, which if a navigation is |
| 220 // pending may be provisional (e.g., the navigation could result in a | 218 // pending may be provisional (e.g., the navigation could result in a |
| 221 // download, in which case the URL would revert to what it was previously). | 219 // download, in which case the URL would revert to what it was previously). |
| 222 virtual const GURL& GetURL() const; | 220 virtual const GURL& GetURL() const; |
| 223 virtual const string16& GetTitle() const; | 221 virtual const string16& GetTitle() const; |
| 224 | 222 |
| 225 // Initial title assigned to NavigationEntries from Navigate. | |
| 226 static string16 GetDefaultTitle(); | |
| 227 | |
| 228 // The max PageID of any page that this TabContents has loaded. PageIDs | 223 // The max PageID of any page that this TabContents has loaded. PageIDs |
| 229 // increase with each new page that is loaded by a tab. If this is a | 224 // increase with each new page that is loaded by a tab. If this is a |
| 230 // TabContents, then the max PageID is kept separately on each SiteInstance. | 225 // TabContents, then the max PageID is kept separately on each SiteInstance. |
| 231 // Returns -1 if no PageIDs have yet been seen. | 226 // Returns -1 if no PageIDs have yet been seen. |
| 232 int32 GetMaxPageID(); | 227 int32 GetMaxPageID(); |
| 233 | 228 |
| 234 // Updates the max PageID to be at least the given PageID. | 229 // Updates the max PageID to be at least the given PageID. |
| 235 void UpdateMaxPageID(int32 page_id); | 230 void UpdateMaxPageID(int32 page_id); |
| 236 | 231 |
| 237 // Returns the site instance associated with the current page. By default, | 232 // Returns the site instance associated with the current page. By default, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 250 // entry. | 245 // entry. |
| 251 SkBitmap GetFavIcon() const; | 246 SkBitmap GetFavIcon() const; |
| 252 | 247 |
| 253 // Returns true if we are not using the default favicon. | 248 // Returns true if we are not using the default favicon. |
| 254 bool FavIconIsValid() const; | 249 bool FavIconIsValid() const; |
| 255 | 250 |
| 256 // Returns whether the favicon should be displayed. If this returns false, no | 251 // Returns whether the favicon should be displayed. If this returns false, no |
| 257 // space is provided for the favicon, and the favicon is never displayed. | 252 // space is provided for the favicon, and the favicon is never displayed. |
| 258 virtual bool ShouldDisplayFavIcon(); | 253 virtual bool ShouldDisplayFavIcon(); |
| 259 | 254 |
| 260 // Returns a human-readable description the tab's loading state. | |
| 261 virtual string16 GetStatusText() const; | |
| 262 | |
| 263 // Add and remove observers for page navigation notifications. Adding or | 255 // Add and remove observers for page navigation notifications. Adding or |
| 264 // removing multiple times has no effect. The order in which notifications | 256 // removing multiple times has no effect. The order in which notifications |
| 265 // are sent to observers is undefined. Clients must be sure to remove the | 257 // are sent to observers is undefined. Clients must be sure to remove the |
| 266 // observer before they go away. | 258 // observer before they go away. |
| 267 void AddObserver(TabContentsObserver* observer); | 259 void AddObserver(TabContentsObserver* observer); |
| 268 void RemoveObserver(TabContentsObserver* observer); | 260 void RemoveObserver(TabContentsObserver* observer); |
| 269 | 261 |
| 270 // Return whether this tab contents is loading a resource. | 262 // Return whether this tab contents is loading a resource. |
| 271 bool is_loading() const { return is_loading_; } | 263 bool is_loading() const { return is_loading_; } |
| 272 | 264 |
| 273 // Returns whether this tab contents is waiting for a first-response for the | 265 // Returns whether this tab contents is waiting for a first-response for the |
| 274 // main resource of the page. This controls whether the throbber state is | 266 // main resource of the page. This controls whether the throbber state is |
| 275 // "waiting" or "loading." | 267 // "waiting" or "loading." |
| 276 bool waiting_for_response() const { return waiting_for_response_; } | 268 bool waiting_for_response() const { return waiting_for_response_; } |
| 277 | 269 |
| 270 net::LoadState load_state() const { return load_state_; } |
| 271 string16 load_state_host() const { return load_state_host_; } |
| 272 uint64 upload_size() const { return upload_size_; } |
| 273 uint64 upload_position() const { return upload_position_; } |
| 274 |
| 278 const std::string& encoding() const { return encoding_; } | 275 const std::string& encoding() const { return encoding_; } |
| 279 void set_encoding(const std::string& encoding); | 276 void set_encoding(const std::string& encoding); |
| 280 void reset_encoding() { | 277 void reset_encoding() { |
| 281 encoding_.clear(); | 278 encoding_.clear(); |
| 282 } | 279 } |
| 283 | 280 |
| 284 const WebApplicationInfo& web_app_info() const { | 281 const WebApplicationInfo& web_app_info() const { |
| 285 return web_app_info_; | 282 return web_app_info_; |
| 286 } | 283 } |
| 287 | 284 |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 virtual void RunBeforeUnloadConfirm(const std::wstring& message, | 952 virtual void RunBeforeUnloadConfirm(const std::wstring& message, |
| 956 IPC::Message* reply_msg); | 953 IPC::Message* reply_msg); |
| 957 virtual void ShowModalHTMLDialog(const GURL& url, int width, int height, | 954 virtual void ShowModalHTMLDialog(const GURL& url, int width, int height, |
| 958 const std::string& json_arguments, | 955 const std::string& json_arguments, |
| 959 IPC::Message* reply_msg); | 956 IPC::Message* reply_msg); |
| 960 virtual GURL GetAlternateErrorPageURL() const; | 957 virtual GURL GetAlternateErrorPageURL() const; |
| 961 virtual RendererPreferences GetRendererPrefs(Profile* profile) const; | 958 virtual RendererPreferences GetRendererPrefs(Profile* profile) const; |
| 962 virtual WebPreferences GetWebkitPrefs(); | 959 virtual WebPreferences GetWebkitPrefs(); |
| 963 virtual void OnUserGesture(); | 960 virtual void OnUserGesture(); |
| 964 virtual void OnIgnoredUIEvent(); | 961 virtual void OnIgnoredUIEvent(); |
| 965 virtual void OnJSOutOfMemory(); | |
| 966 virtual void OnCrossSiteResponse(int new_render_process_host_id, | 962 virtual void OnCrossSiteResponse(int new_render_process_host_id, |
| 967 int new_request_id); | 963 int new_request_id); |
| 968 virtual void RendererUnresponsive(RenderViewHost* render_view_host, | 964 virtual void RendererUnresponsive(RenderViewHost* render_view_host, |
| 969 bool is_during_unload); | 965 bool is_during_unload); |
| 970 virtual void RendererResponsive(RenderViewHost* render_view_host); | 966 virtual void RendererResponsive(RenderViewHost* render_view_host); |
| 971 virtual void LoadStateChanged(const GURL& url, net::LoadState load_state, | 967 virtual void LoadStateChanged(const GURL& url, net::LoadState load_state, |
| 972 uint64 upload_position, uint64 upload_size); | 968 uint64 upload_position, uint64 upload_size); |
| 973 virtual bool IsExternalTabContainer() const; | 969 virtual bool IsExternalTabContainer() const; |
| 974 virtual void DidInsertCSS(); | 970 virtual void DidInsertCSS(); |
| 975 virtual void FocusedNodeChanged(bool is_editable_node); | 971 virtual void FocusedNodeChanged(bool is_editable_node); |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 // A list of observers notified when page state changes. Weak references. | 1248 // A list of observers notified when page state changes. Weak references. |
| 1253 ObserverList<TabContentsObserver> observers_; | 1249 ObserverList<TabContentsObserver> observers_; |
| 1254 | 1250 |
| 1255 // Content restrictions, used to disable print/copy etc based on content's | 1251 // Content restrictions, used to disable print/copy etc based on content's |
| 1256 // (full-page plugins for now only) permissions. | 1252 // (full-page plugins for now only) permissions. |
| 1257 int content_restrictions_; | 1253 int content_restrictions_; |
| 1258 | 1254 |
| 1259 DISALLOW_COPY_AND_ASSIGN(TabContents); | 1255 DISALLOW_COPY_AND_ASSIGN(TabContents); |
| 1260 }; | 1256 }; |
| 1261 | 1257 |
| 1262 #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_ | 1258 #endif // CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_ |
| OLD | NEW |