diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-22 20:24:55 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-22 20:24:55 +0000 |
commit | e679429362f5e6b973e6be674026dcc696f9ea77 (patch) | |
tree | f60fce884cf45545dbcfe74a4507b59d0c58e48e | |
parent | 9319c8b537460d193c09ba3687ae776cd28c990e (diff) | |
download | chromium_src-e679429362f5e6b973e6be674026dcc696f9ea77.zip chromium_src-e679429362f5e6b973e6be674026dcc696f9ea77.tar.gz chromium_src-e679429362f5e6b973e6be674026dcc696f9ea77.tar.bz2 |
Move background_contents back to chrome, since that's part of extensions which isn't moving. I incorrectly moved it.
Review URL: http://codereview.chromium.org/6538095
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75624 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/tab_contents/background_contents.cc (renamed from content/browser/tab_contents/background_contents.cc) | 2 | ||||
-rw-r--r-- | chrome/browser/tab_contents/background_contents.h | 178 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 | ||||
-rw-r--r-- | content/content_browser.gypi | 2 |
4 files changed, 179 insertions, 5 deletions
diff --git a/content/browser/tab_contents/background_contents.cc b/chrome/browser/tab_contents/background_contents.cc index d8c11e0..059d393 100644 --- a/content/browser/tab_contents/background_contents.cc +++ b/chrome/browser/tab_contents/background_contents.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/tab_contents/background_contents.h" +#include "chrome/browser/tab_contents/background_contents.h" #include "chrome/browser/background_contents_service.h" #include "chrome/browser/browsing_instance.h" diff --git a/chrome/browser/tab_contents/background_contents.h b/chrome/browser/tab_contents/background_contents.h index ea0d6ab..11aa3e2 100644 --- a/chrome/browser/tab_contents/background_contents.h +++ b/chrome/browser/tab_contents/background_contents.h @@ -6,7 +6,181 @@ #define CHROME_BROWSER_TAB_CONTENTS_BACKGROUND_CONTENTS_H_ #pragma once -// TODO(jam): remove this file when all files have been converted. -#include "content/browser/tab_contents/background_contents.h" +#include <string> +#include <vector> + +#include "chrome/browser/renderer_host/render_view_host_delegate.h" +#include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" +#include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" +#include "chrome/common/notification_registrar.h" +#include "chrome/common/view_types.h" +#include "chrome/common/window_container_type.h" +#include "webkit/glue/window_open_disposition.h" + +class TabContents; +struct WebPreferences; +class DesktopNotificationHandler; + +namespace gfx { +class Rect; +} + +// This class is a peer of TabContents. It can host a renderer, but does not +// have any visible display. Its navigation is not managed by a +// NavigationController because is has no facility for navigating (other than +// programatically view window.location.href) or RenderViewHostManager because +// it is never allowed to navigate across a SiteInstance boundary. +class BackgroundContents : public RenderViewHostDelegate, + public RenderViewHostDelegate::View, + public NotificationObserver, + public JavaScriptAppModalDialogDelegate { + public: + class Delegate { + public: + // Called by ShowCreatedWindow. Asks the delegate to attach the opened + // TabContents to a suitable container (e.g. browser) or to show it if it's + // a popup window. + virtual void AddTabContents(TabContents* new_contents, + WindowOpenDisposition disposition, + const gfx::Rect& initial_pos, + bool user_gesture) = 0; + + protected: + virtual ~Delegate() {} + }; + + BackgroundContents(SiteInstance* site_instance, + int routing_id, + Delegate* delegate); + virtual ~BackgroundContents(); + + // Provide access to the RenderViewHost for the + // RenderViewHostDelegateViewHelper + RenderViewHost* render_view_host() { return render_view_host_; } + + // RenderViewHostDelegate implementation. + virtual BackgroundContents* GetAsBackgroundContents(); + virtual RenderViewHostDelegate::View* GetViewDelegate(); + virtual const GURL& GetURL() const; + virtual ViewType::Type GetRenderViewType() const; + virtual int GetBrowserWindowID() const; + virtual void DidNavigate(RenderViewHost* render_view_host, + const ViewHostMsg_FrameNavigate_Params& params); + virtual WebPreferences GetWebkitPrefs(); + virtual void ProcessWebUIMessage(const ViewHostMsg_DomMessage_Params& params); + virtual void RunJavaScriptMessage(const std::wstring& message, + const std::wstring& default_prompt, + const GURL& frame_url, + const int flags, + IPC::Message* reply_msg, + bool* did_suppress_message); + virtual void Close(RenderViewHost* render_view_host); + virtual RendererPreferences GetRendererPrefs(Profile* profile) const; + virtual void RenderViewGone(RenderViewHost* rvh, + base::TerminationStatus status, + int error_code); + virtual bool OnMessageReceived(const IPC::Message& message); + + // RenderViewHostDelegate::View + virtual void CreateNewWindow( + int route_id, + const ViewHostMsg_CreateWindow_Params& params); + virtual void CreateNewWidget(int route_id, WebKit::WebPopupType popup_type); + virtual void CreateNewFullscreenWidget(int route_id); + virtual void ShowCreatedWindow(int route_id, + WindowOpenDisposition disposition, + const gfx::Rect& initial_pos, + bool user_gesture); + virtual void ShowCreatedWidget(int route_id, + const gfx::Rect& initial_pos); + virtual void ShowCreatedFullscreenWidget(int route_id); + virtual void ShowContextMenu(const ContextMenuParams& params) {} + virtual void ShowPopupMenu(const gfx::Rect& bounds, + int item_height, + double item_font_size, + int selected_item, + const std::vector<WebMenuItem>& items, + bool right_aligned) {} + virtual void StartDragging(const WebDropData& drop_data, + WebKit::WebDragOperationsMask allowed_operations, + const SkBitmap& image, + const gfx::Point& image_offset) {} + virtual void UpdateDragCursor(WebKit::WebDragOperation operation) {} + virtual void GotFocus() {} + virtual void TakeFocus(bool reverse) {} + virtual void LostCapture() {} + virtual void Activate() {} + virtual void Deactivate() {} + virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, + bool* is_keyboard_shortcut); + virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {} + virtual void HandleMouseMove() {} + virtual void HandleMouseDown() {} + virtual void HandleMouseLeave() {} + virtual void HandleMouseUp() {} + virtual void HandleMouseActivate() {} + virtual void UpdatePreferredSize(const gfx::Size& new_size) {} + + // NotificationObserver + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + + // Overridden from JavaScriptAppModalDialogDelegate: + virtual void OnMessageBoxClosed(IPC::Message* reply_msg, + bool success, + const std::wstring& prompt); + virtual void SetSuppressMessageBoxes(bool suppress_message_boxes) {} + virtual gfx::NativeWindow GetMessageBoxRootWindow(); + virtual TabContents* AsTabContents(); + virtual ExtensionHost* AsExtensionHost(); + + virtual void UpdateInspectorSetting(const std::string& key, + const std::string& value); + virtual void ClearInspectorSettings(); + + // Helper to find the BackgroundContents that originated the given request. + // Can be NULL if the page has been closed or some other error occurs. + // Should only be called from the UI thread, since it accesses + // BackgroundContents. + static BackgroundContents* GetBackgroundContentsByID(int render_process_id, + int render_view_id); + + protected: + // Exposed for testing. + BackgroundContents(); + + private: + // The delegate for this BackgroundContents. + Delegate* delegate_; + + // The host for our HTML content. + RenderViewHost* render_view_host_; + + // Common implementations of some RenderViewHostDelegate::View methods. + RenderViewHostDelegateViewHelper delegate_view_helper_; + + // The URL being hosted. + GURL url_; + + NotificationRegistrar registrar_; + + // Handles desktop notification IPCs. + scoped_ptr<DesktopNotificationHandler> desktop_notification_handler_; + + DISALLOW_COPY_AND_ASSIGN(BackgroundContents); +}; + +// This is the data sent out as the details with BACKGROUND_CONTENTS_OPENED. +struct BackgroundContentsOpenedDetails { + // The BackgroundContents object that has just been opened. + BackgroundContents* contents; + + // The name of the parent frame for these contents. + const string16& frame_name; + + // The ID of the parent application (if any). + const string16& application_id; +}; #endif // CHROME_BROWSER_TAB_CONTENTS_BACKGROUND_CONTENTS_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 20fb1c6..77c7c3e 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2127,6 +2127,8 @@ 'browser/sync/token_migrator.h', 'browser/tab_closeable_state_watcher.cc', 'browser/tab_closeable_state_watcher.h', + 'browser/tab_contents/background_contents.cc', + 'browser/tab_contents/background_contents.h', 'browser/tab_contents/infobar_delegate.cc', 'browser/tab_contents/infobar_delegate.h', 'browser/tab_contents/popup_menu_helper_mac.h', diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 8156192..1629d8b 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -106,8 +106,6 @@ 'browser/renderer_host/x509_user_cert_resource_handler.h', 'browser/site_instance.cc', 'browser/site_instance.h', - 'browser/tab_contents/background_contents.cc', - 'browser/tab_contents/background_contents.h', 'browser/tab_contents/constrained_window.h', 'browser/tab_contents/infobar_delegate.cc', 'browser/tab_contents/infobar_delegate.h', |