diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-16 23:54:40 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-16 23:54:40 +0000 |
commit | 15b2c6a9a738c3445d8525075a73f36dd8f2cdbc (patch) | |
tree | 657f19a459e124f71b2e45ab0a931c683706addc /content | |
parent | 1a10a0ccf708a6453d515706390966605b9ce83a (diff) | |
download | chromium_src-15b2c6a9a738c3445d8525075a73f36dd8f2cdbc.zip chromium_src-15b2c6a9a738c3445d8525075a73f36dd8f2cdbc.tar.gz chromium_src-15b2c6a9a738c3445d8525075a73f36dd8f2cdbc.tar.bz2 |
Move view_types.h from chrome to content. Although some of the enum types are Chrome specific, I don't see how we can keep this in chrome given that it's a return type in RenderViewHostDelegate. Also make the two IPCs that are sent with the view type and browser ID be extension messages, since that's the only receiver of the messages (and makes it clear why they're being sent).
Review URL: http://codereview.chromium.org/7034013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85564 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/DEPS | 2 | ||||
-rw-r--r-- | content/browser/renderer_host/render_view_host.cc | 19 | ||||
-rw-r--r-- | content/browser/renderer_host/render_view_host.h | 7 | ||||
-rw-r--r-- | content/browser/renderer_host/render_view_host_delegate.h | 9 | ||||
-rw-r--r-- | content/browser/renderer_host/render_view_host_observer.cc | 3 | ||||
-rw-r--r-- | content/browser/renderer_host/render_view_host_observer.h | 4 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.cc | 7 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.h | 3 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents_delegate.cc | 6 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents_delegate.h | 5 | ||||
-rw-r--r-- | content/common/view_types.cc | 12 | ||||
-rw-r--r-- | content/common/view_types.h | 42 | ||||
-rw-r--r-- | content/content_common.gypi | 2 |
13 files changed, 67 insertions, 54 deletions
diff --git a/content/browser/DEPS b/content/browser/DEPS index 93cce1d..c074355 100644 --- a/content/browser/DEPS +++ b/content/browser/DEPS @@ -123,8 +123,6 @@ include_rules = [ "+chrome/common/security_style.h",
- "+chrome/common/view_types.h",
-
# ONLY USED BY TESTS
"+chrome/browser/chromeos/cros/mock_network_library.h",
"+chrome/browser/net/url_request_failed_dns_job.h",
diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc index bd54a62..0e2f955 100644 --- a/content/browser/renderer_host/render_view_host.cc +++ b/content/browser/renderer_host/render_view_host.cc @@ -18,7 +18,6 @@ #include "chrome/browser/net/predictor_api.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/render_messages.h" #include "content/browser/browser_message_filter.h" #include "content/browser/child_process_security_policy.h" #include "content/browser/content_browser_client.h" @@ -180,12 +179,12 @@ bool RenderViewHost::CreateRenderView(const string16& frame_name) { // If it's enabled, tell the renderer to set up the Javascript bindings for // sending messages back to the browser. Send(new ViewMsg_AllowBindings(routing_id(), enabled_bindings_)); - UpdateBrowserWindowId(delegate_->GetBrowserWindowID()); - Send(new ViewMsg_NotifyRenderViewType(routing_id(), - delegate_->GetRenderViewType())); // Let our delegate know that we created a RenderView. delegate_->RenderViewCreated(this); + FOR_EACH_OBSERVER( + RenderViewHostObserver, observers_, RenderViewHostInitialized()); + return true; } @@ -754,8 +753,6 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_OpenURL, OnMsgOpenURL) IPC_MESSAGE_HANDLER(ViewHostMsg_DidContentsPreferredSizeChange, OnMsgDidContentsPreferredSizeChange) - IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardMessageToExternalHost, - OnMsgForwardMessageToExternalHost) IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage, OnMsgRunJavaScriptMessage) @@ -1061,12 +1058,6 @@ void RenderViewHost::OnMsgDidContentsPreferredSizeChange( view->UpdatePreferredSize(new_size); } -void RenderViewHost::OnMsgForwardMessageToExternalHost( - const std::string& message, const std::string& origin, - const std::string& target) { - delegate_->ProcessExternalHostMessage(message, origin, target); -} - void RenderViewHost::DisassociateFromPopupCount() { Send(new ViewMsg_DisassociateFromPopupCount(routing_id())); } @@ -1318,10 +1309,6 @@ void RenderViewHost::ForwardEditCommandsForNextKeyEvent( Send(new ViewMsg_SetEditCommandsForNextKeyEvent(routing_id(), edit_commands)); } -void RenderViewHost::UpdateBrowserWindowId(int window_id) { - Send(new ViewMsg_UpdateBrowserWindowId(routing_id(), window_id)); -} - void RenderViewHost::PerformCustomContextMenuAction( const webkit_glue::CustomContextMenuContext& custom_context, unsigned action) { diff --git a/content/browser/renderer_host/render_view_host.h b/content/browser/renderer_host/render_view_host.h index 958df19..8df9eaf 100644 --- a/content/browser/renderer_host/render_view_host.h +++ b/content/browser/renderer_host/render_view_host.h @@ -13,7 +13,6 @@ #include "base/observer_list.h" #include "base/process_util.h" #include "chrome/browser/ui/find_bar/find_bar_controller.h" -#include "chrome/common/view_types.h" #include "content/browser/renderer_host/render_widget_host.h" #include "content/common/page_zoom.h" #include "content/common/window_container_type.h" @@ -411,9 +410,6 @@ class RenderViewHost : public RenderWidgetHost { // Creates a full screen RenderWidget. void CreateNewFullscreenWidget(int route_id); - // Tells the renderer which browser window it is being attached to. - void UpdateBrowserWindowId(int window_id); - // Tells the render view that a custom context action has been selected. void PerformCustomContextMenuAction( const webkit_glue::CustomContextMenuContext& custom_context, @@ -497,9 +493,6 @@ class RenderViewHost : public RenderWidgetHost { void OnMsgOpenURL(const GURL& url, const GURL& referrer, WindowOpenDisposition disposition); void OnMsgDidContentsPreferredSizeChange(const gfx::Size& new_size); - void OnMsgForwardMessageToExternalHost(const std::string& message, - const std::string& origin, - const std::string& target); void OnMsgSetTooltipText(const std::wstring& tooltip_text, WebKit::WebTextDirection text_direction_hint); void OnMsgSelectionChanged(const std::string& text, const ui::Range& range); diff --git a/content/browser/renderer_host/render_view_host_delegate.h b/content/browser/renderer_host/render_view_host_delegate.h index f6ff365..365c679 100644 --- a/content/browser/renderer_host/render_view_host_delegate.h +++ b/content/browser/renderer_host/render_view_host_delegate.h @@ -13,7 +13,7 @@ #include "base/memory/ref_counted.h" #include "base/process_util.h" #include "base/string16.h" -#include "chrome/common/view_types.h" +#include "content/common/view_types.h" #include "content/common/window_container_type.h" #include "ipc/ipc_channel.h" #include "net/base/load_states.h" @@ -405,13 +405,6 @@ class RenderViewHostDelegate : public IPC::Channel::Listener { const GURL& referrer, WindowOpenDisposition disposition) {} - // A message for external host. By default we ignore such messages. - // |receiver| can be a receiving script and |message| is any - // arbitrary string that makes sense to the receiver. - virtual void ProcessExternalHostMessage(const std::string& message, - const std::string& origin, - const std::string& target) {} - // A javascript message, confirmation or prompt should be shown. virtual void RunJavaScriptMessage(const RenderViewHost* rvh, const std::wstring& message, diff --git a/content/browser/renderer_host/render_view_host_observer.cc b/content/browser/renderer_host/render_view_host_observer.cc index 5f7872e..15463d4 100644 --- a/content/browser/renderer_host/render_view_host_observer.cc +++ b/content/browser/renderer_host/render_view_host_observer.cc @@ -17,6 +17,9 @@ RenderViewHostObserver::~RenderViewHostObserver() { render_view_host_->RemoveObserver(this); } +void RenderViewHostObserver::RenderViewHostInitialized() { +} + void RenderViewHostObserver::RenderViewHostDestroyed() { delete this; } diff --git a/content/browser/renderer_host/render_view_host_observer.h b/content/browser/renderer_host/render_view_host_observer.h index 2f63935..2727fb3 100644 --- a/content/browser/renderer_host/render_view_host_observer.h +++ b/content/browser/renderer_host/render_view_host_observer.h @@ -20,6 +20,10 @@ class RenderViewHostObserver : public IPC::Channel::Listener, virtual ~RenderViewHostObserver(); + // Invoked after the RenderViewHost is created in the renderer process. After + // this point, messages can be sent to it (or to observers in the renderer). + virtual void RenderViewHostInitialized(); + // Invoked when the RenderViewHost is being destroyed. Gives subclasses a // chance to cleanup. The base implementation will delete the object. virtual void RenderViewHostDestroyed(); diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index d51e63e..bf511cf 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -1857,13 +1857,6 @@ void TabContents::RequestOpenURL(const GURL& url, const GURL& referrer, } } -void TabContents::ProcessExternalHostMessage(const std::string& message, - const std::string& origin, - const std::string& target) { - if (delegate()) - delegate()->ForwardMessageToExternalHost(message, origin, target); -} - void TabContents::RunJavaScriptMessage( const RenderViewHost* rvh, const std::wstring& message, diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index f38ca63..c3e5544 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -748,9 +748,6 @@ class TabContents : public PageNavigator, int32 page_id); virtual void RequestOpenURL(const GURL& url, const GURL& referrer, WindowOpenDisposition disposition); - virtual void ProcessExternalHostMessage(const std::string& message, - const std::string& origin, - const std::string& target); virtual void RunJavaScriptMessage(const RenderViewHost* rvh, const std::wstring& message, const std::wstring& default_prompt, diff --git a/content/browser/tab_contents/tab_contents_delegate.cc b/content/browser/tab_contents/tab_contents_delegate.cc index 378c48e..9eb58df 100644 --- a/content/browser/tab_contents/tab_contents_delegate.cc +++ b/content/browser/tab_contents/tab_contents_delegate.cc @@ -59,12 +59,6 @@ void TabContentsDelegate::BeforeUnloadFired(TabContents* tab, *proceed_to_fire_unload = true; } -void TabContentsDelegate::ForwardMessageToExternalHost( - const std::string& message, - const std::string& origin, - const std::string& target) { -} - bool TabContentsDelegate::IsExternalTabContainer() const { return false; } void TabContentsDelegate::SetFocusToLocationBar(bool select_all) {} diff --git a/content/browser/tab_contents/tab_contents_delegate.h b/content/browser/tab_contents/tab_contents_delegate.h index e0c95ac..c0c0b61 100644 --- a/content/browser/tab_contents/tab_contents_delegate.h +++ b/content/browser/tab_contents/tab_contents_delegate.h @@ -158,11 +158,6 @@ class TabContentsDelegate { bool proceed, bool* proceed_to_fire_unload); - // Send IPC to external host. Default implementation is do nothing. - virtual void ForwardMessageToExternalHost(const std::string& message, - const std::string& origin, - const std::string& target); - // If the delegate is hosting tabs externally. virtual bool IsExternalTabContainer() const; diff --git a/content/common/view_types.cc b/content/common/view_types.cc new file mode 100644 index 0000000..97c9828 --- /dev/null +++ b/content/common/view_types.cc @@ -0,0 +1,12 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/common/view_types.h" + +const char* ViewType::kTabContents = "TAB"; +const char* ViewType::kBackgroundPage = "BACKGROUND"; +const char* ViewType::kPopup = "POPUP"; +const char* ViewType::kInfobar = "INFOBAR"; +const char* ViewType::kNotification = "NOTIFICATION"; +const char* ViewType::kAll = "ALL"; diff --git a/content/common/view_types.h b/content/common/view_types.h new file mode 100644 index 0000000..d41ed27 --- /dev/null +++ b/content/common/view_types.h @@ -0,0 +1,42 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_COMMON_VIEW_TYPES_H_ +#define CONTENT_COMMON_VIEW_TYPES_H_ +#pragma once + +#include "base/basictypes.h" + +// Indicates different types of views +class ViewType { + public: + enum Type { + INVALID, + BACKGROUND_CONTENTS, + TAB_CONTENTS, + EXTENSION_BACKGROUND_PAGE, + EXTENSION_POPUP, + EXTENSION_INFOBAR, + DEV_TOOLS_UI, + INTERSTITIAL_PAGE, + NOTIFICATION, + }; + + // Constant strings corresponding to the Type enumeration values. Used + // when converting JS arguments. + static const char* kTabContents; + static const char* kBackgroundPage; + static const char* kPopup; + static const char* kInfobar; + static const char* kNotification; + static const char* kAll; + + private: + // This class is for scoping only, so you shouldn't create an instance of it. + ViewType() {} + + DISALLOW_COPY_AND_ASSIGN(ViewType); +}; + +#endif // CONTENT_COMMON_VIEW_TYPES_H_ diff --git a/content/content_common.gypi b/content/content_common.gypi index 95c481d..e22ee0c 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -219,6 +219,8 @@ 'common/url_constants.h', 'common/video_capture_messages.h', 'common/view_messages.h', + 'common/view_types.cc', + 'common/view_types.h', 'common/web_database_observer_impl.cc', 'common/web_database_observer_impl.h', 'common/webblobregistry_impl.cc', |