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 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/string16.h" | 16 #include "base/string16.h" |
17 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" | 17 #include "content/browser/javascript_dialogs.h" |
18 #include "content/browser/renderer_host/render_view_host_delegate.h" | 18 #include "content/browser/renderer_host/render_view_host_delegate.h" |
19 #include "content/browser/tab_contents/constrained_window.h" | 19 #include "content/browser/tab_contents/constrained_window.h" |
20 #include "content/browser/tab_contents/navigation_controller.h" | 20 #include "content/browser/tab_contents/navigation_controller.h" |
21 #include "content/browser/tab_contents/navigation_entry.h" | 21 #include "content/browser/tab_contents/navigation_entry.h" |
22 #include "content/browser/tab_contents/page_navigator.h" | 22 #include "content/browser/tab_contents/page_navigator.h" |
23 #include "content/browser/tab_contents/render_view_host_manager.h" | 23 #include "content/browser/tab_contents/render_view_host_manager.h" |
24 #include "content/browser/tab_contents/tab_contents_observer.h" | 24 #include "content/browser/tab_contents/tab_contents_observer.h" |
25 #include "content/browser/webui/web_ui.h" | 25 #include "content/browser/webui/web_ui.h" |
26 #include "content/common/notification_registrar.h" | 26 #include "content/common/notification_registrar.h" |
27 #include "content/common/property_bag.h" | 27 #include "content/common/property_bag.h" |
(...skipping 26 matching lines...) Expand all Loading... |
54 struct ViewHostMsg_FrameNavigate_Params; | 54 struct ViewHostMsg_FrameNavigate_Params; |
55 struct WebPreferences; | 55 struct WebPreferences; |
56 class WebUI; | 56 class WebUI; |
57 | 57 |
58 // Describes what goes in the main content area of a tab. TabContents is | 58 // Describes what goes in the main content area of a tab. TabContents is |
59 // the only type of TabContents, and these should be merged together. | 59 // the only type of TabContents, and these should be merged together. |
60 class TabContents : public PageNavigator, | 60 class TabContents : public PageNavigator, |
61 public NotificationObserver, | 61 public NotificationObserver, |
62 public RenderViewHostDelegate, | 62 public RenderViewHostDelegate, |
63 public RenderViewHostManager::Delegate, | 63 public RenderViewHostManager::Delegate, |
64 public JavaScriptAppModalDialogDelegate, | 64 public content::JavaScriptDialogDelegate, |
65 public net::NetworkChangeNotifier::OnlineStateObserver { | 65 public net::NetworkChangeNotifier::OnlineStateObserver { |
66 public: | 66 public: |
67 // Flags passed to the TabContentsDelegate.NavigationStateChanged to tell it | 67 // Flags passed to the TabContentsDelegate.NavigationStateChanged to tell it |
68 // what has changed. Combine them to update more than one thing. | 68 // what has changed. Combine them to update more than one thing. |
69 enum InvalidateTypes { | 69 enum InvalidateTypes { |
70 INVALIDATE_URL = 1 << 0, // The URL has changed. | 70 INVALIDATE_URL = 1 << 0, // The URL has changed. |
71 INVALIDATE_TAB = 1 << 1, // The favicon, app icon, or crashed | 71 INVALIDATE_TAB = 1 << 1, // The favicon, app icon, or crashed |
72 // state changed. | 72 // state changed. |
73 INVALIDATE_LOAD = 1 << 2, // The loading state has changed. | 73 INVALIDATE_LOAD = 1 << 2, // The loading state has changed. |
74 INVALIDATE_PAGE_ACTIONS = 1 << 3, // Page action icons have changed. | 74 INVALIDATE_PAGE_ACTIONS = 1 << 3, // Page action icons have changed. |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 } | 376 } |
377 | 377 |
378 // Returns the currently showing interstitial, NULL if no interstitial is | 378 // Returns the currently showing interstitial, NULL if no interstitial is |
379 // showing. | 379 // showing. |
380 InterstitialPage* interstitial_page() const { | 380 InterstitialPage* interstitial_page() const { |
381 return render_manager_.interstitial_page(); | 381 return render_manager_.interstitial_page(); |
382 } | 382 } |
383 | 383 |
384 // Misc state & callbacks ---------------------------------------------------- | 384 // Misc state & callbacks ---------------------------------------------------- |
385 | 385 |
386 // Set whether the contents should block javascript message boxes or not. | |
387 // Default is not to block any message boxes. | |
388 void set_suppress_javascript_messages(bool suppress_javascript_messages) { | |
389 suppress_javascript_messages_ = suppress_javascript_messages; | |
390 } | |
391 | |
392 // Returns true if the active NavigationEntry's page_id equals page_id. | 386 // Returns true if the active NavigationEntry's page_id equals page_id. |
393 bool IsActiveEntry(int32 page_id); | 387 bool IsActiveEntry(int32 page_id); |
394 | 388 |
395 const std::string& contents_mime_type() const { | 389 const std::string& contents_mime_type() const { |
396 return contents_mime_type_; | 390 return contents_mime_type_; |
397 } | 391 } |
398 | 392 |
399 // Returns true if this TabContents will notify about disconnection. | 393 // Returns true if this TabContents will notify about disconnection. |
400 bool notify_disconnection() const { return notify_disconnection_; } | 394 bool notify_disconnection() const { return notify_disconnection_; } |
401 | 395 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 | 432 |
439 // Indicates if this tab was explicitly closed by the user (control-w, close | 433 // Indicates if this tab was explicitly closed by the user (control-w, close |
440 // tab menu item...). This is false for actions that indirectly close the tab, | 434 // tab menu item...). This is false for actions that indirectly close the tab, |
441 // such as closing the window. The setter is maintained by TabStripModel, and | 435 // such as closing the window. The setter is maintained by TabStripModel, and |
442 // the getter only useful from within TAB_CLOSED notification | 436 // the getter only useful from within TAB_CLOSED notification |
443 void set_closed_by_user_gesture(bool value) { | 437 void set_closed_by_user_gesture(bool value) { |
444 closed_by_user_gesture_ = value; | 438 closed_by_user_gesture_ = value; |
445 } | 439 } |
446 bool closed_by_user_gesture() const { return closed_by_user_gesture_; } | 440 bool closed_by_user_gesture() const { return closed_by_user_gesture_; } |
447 | 441 |
448 // Overridden from JavaScriptAppModalDialogDelegate: | 442 // Overridden from JavaScriptDialogDelegate: |
449 virtual void OnMessageBoxClosed(IPC::Message* reply_msg, | 443 virtual void OnDialogClosed(IPC::Message* reply_msg, |
450 bool success, | 444 bool success, |
451 const std::wstring& user_input); | 445 const string16& user_input) OVERRIDE; |
452 virtual void SetSuppressMessageBoxes(bool suppress_message_boxes); | 446 virtual gfx::NativeWindow GetDialogRootWindow() OVERRIDE; |
453 virtual gfx::NativeWindow GetMessageBoxRootWindow(); | 447 virtual TabContents* AsTabContents() OVERRIDE; |
454 virtual TabContents* AsTabContents(); | 448 virtual ExtensionHost* AsExtensionHost() OVERRIDE; |
455 virtual ExtensionHost* AsExtensionHost(); | |
456 | 449 |
457 // The BookmarkDragDelegate is used to forward bookmark drag and drop events | 450 // The BookmarkDragDelegate is used to forward bookmark drag and drop events |
458 // to extensions. | 451 // to extensions. |
459 virtual RenderViewHostDelegate::BookmarkDrag* GetBookmarkDragDelegate(); | 452 virtual RenderViewHostDelegate::BookmarkDrag* GetBookmarkDragDelegate(); |
460 | 453 |
461 // It is up to callers to call SetBookmarkDragDelegate(NULL) when | 454 // It is up to callers to call SetBookmarkDragDelegate(NULL) when |
462 // |bookmark_drag| is deleted since this class does not take ownership of | 455 // |bookmark_drag| is deleted since this class does not take ownership of |
463 // |bookmark_drag|. | 456 // |bookmark_drag|. |
464 virtual void SetBookmarkDragDelegate( | 457 virtual void SetBookmarkDragDelegate( |
465 RenderViewHostDelegate::BookmarkDrag* bookmark_drag); | 458 RenderViewHostDelegate::BookmarkDrag* bookmark_drag); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 RenderViewHost* render_view_host, | 658 RenderViewHost* render_view_host, |
666 int32 page_id); | 659 int32 page_id); |
667 virtual void RequestOpenURL(const GURL& url, const GURL& referrer, | 660 virtual void RequestOpenURL(const GURL& url, const GURL& referrer, |
668 WindowOpenDisposition disposition); | 661 WindowOpenDisposition disposition); |
669 virtual void RunJavaScriptMessage(const RenderViewHost* rvh, | 662 virtual void RunJavaScriptMessage(const RenderViewHost* rvh, |
670 const string16& message, | 663 const string16& message, |
671 const string16& default_prompt, | 664 const string16& default_prompt, |
672 const GURL& frame_url, | 665 const GURL& frame_url, |
673 const int flags, | 666 const int flags, |
674 IPC::Message* reply_msg, | 667 IPC::Message* reply_msg, |
675 bool* did_suppress_message); | 668 bool* did_suppress_message) OVERRIDE; |
676 virtual void RunBeforeUnloadConfirm(const RenderViewHost* rvh, | 669 virtual void RunBeforeUnloadConfirm(const RenderViewHost* rvh, |
677 const string16& message, | 670 const string16& message, |
678 IPC::Message* reply_msg); | 671 IPC::Message* reply_msg); |
679 virtual RendererPreferences GetRendererPrefs(Profile* profile) const; | 672 virtual RendererPreferences GetRendererPrefs(Profile* profile) const; |
680 virtual WebPreferences GetWebkitPrefs(); | 673 virtual WebPreferences GetWebkitPrefs(); |
681 virtual void OnUserGesture(); | 674 virtual void OnUserGesture(); |
682 virtual void OnIgnoredUIEvent(); | 675 virtual void OnIgnoredUIEvent(); |
683 virtual void OnCrossSiteResponse(int new_render_process_host_id, | 676 virtual void OnCrossSiteResponse(int new_render_process_host_id, |
684 int new_request_id); | 677 int new_request_id); |
685 virtual void RendererUnresponsive(RenderViewHost* render_view_host, | 678 virtual void RendererUnresponsive(RenderViewHost* render_view_host, |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 // once. | 810 // once. |
818 bool notify_disconnection_; | 811 bool notify_disconnection_; |
819 | 812 |
820 #if defined(OS_WIN) | 813 #if defined(OS_WIN) |
821 // Handle to an event that's set when the page is showing a message box (or | 814 // Handle to an event that's set when the page is showing a message box (or |
822 // equivalent constrained window). Plugin processes check this to know if | 815 // equivalent constrained window). Plugin processes check this to know if |
823 // they should pump messages then. | 816 // they should pump messages then. |
824 base::win::ScopedHandle message_box_active_; | 817 base::win::ScopedHandle message_box_active_; |
825 #endif | 818 #endif |
826 | 819 |
827 // The time that the last javascript message was dismissed. | |
828 base::TimeTicks last_javascript_message_dismissal_; | |
829 | |
830 // True if the user has decided to block future javascript messages. This is | |
831 // reset on navigations to false on navigations. | |
832 bool suppress_javascript_messages_; | |
833 | |
834 // Set to true when there is an active "before unload" dialog. When true, | 820 // Set to true when there is an active "before unload" dialog. When true, |
835 // we've forced the throbber to start in Navigate, and we need to remember to | 821 // we've forced the throbber to start in Navigate, and we need to remember to |
836 // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled. | 822 // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled. |
837 bool is_showing_before_unload_dialog_; | 823 bool is_showing_before_unload_dialog_; |
838 | 824 |
839 // Settings that get passed to the renderer process. | 825 // Settings that get passed to the renderer process. |
840 RendererPreferences renderer_preferences_; | 826 RendererPreferences renderer_preferences_; |
841 | 827 |
842 // If this tab was created from a renderer using window.open, this will be | 828 // If this tab was created from a renderer using window.open, this will be |
843 // non-NULL and represent the WebUI of the opening renderer. | 829 // non-NULL and represent the WebUI of the opening renderer. |
(...skipping 23 matching lines...) Expand all Loading... |
867 ObserverList<TabContentsObserver> observers_; | 853 ObserverList<TabContentsObserver> observers_; |
868 | 854 |
869 // Content restrictions, used to disable print/copy etc based on content's | 855 // Content restrictions, used to disable print/copy etc based on content's |
870 // (full-page plugins for now only) permissions. | 856 // (full-page plugins for now only) permissions. |
871 int content_restrictions_; | 857 int content_restrictions_; |
872 | 858 |
873 DISALLOW_COPY_AND_ASSIGN(TabContents); | 859 DISALLOW_COPY_AND_ASSIGN(TabContents); |
874 }; | 860 }; |
875 | 861 |
876 #endif // CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_ | 862 #endif // CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_H_ |
OLD | NEW |