diff options
author | timsteele@google.com <timsteele@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-15 18:46:34 +0000 |
---|---|---|
committer | timsteele@google.com <timsteele@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-15 18:46:34 +0000 |
commit | 3a453fa1f16dfa4168e52790e329148366abb05f (patch) | |
tree | a8bbab89ec883a838600e0b63d92fad4361e5dfb /chrome/renderer | |
parent | 173de1be12780200c62bae5c01965d51ac0eaa31 (diff) | |
download | chromium_src-3a453fa1f16dfa4168e52790e329148366abb05f.zip chromium_src-3a453fa1f16dfa4168e52790e329148366abb05f.tar.gz chromium_src-3a453fa1f16dfa4168e52790e329148366abb05f.tar.bz2 |
Copy from http://chrome-reviews.prom.corp.google.com/1237 (new gcl changelist model).
Description was:
Conditionally include personalization/ code by surrounding
the hooks into this module with #ifdef CHROME_PERSONALIZATION
in various .h/.cc files.
Building with the module requires adding this macro as a preprocessor
definition in build/internal/essential.vsprops, and adding it to the
VCResourceCompiler tool's command line (using /d). We will try and
make this easier in the future.
TBR=darin
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@955 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/dom_ui_bindings.cc | 10 | ||||
-rw-r--r-- | chrome/renderer/dom_ui_bindings.h | 49 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 12 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 7 |
4 files changed, 60 insertions, 18 deletions
diff --git a/chrome/renderer/dom_ui_bindings.cc b/chrome/renderer/dom_ui_bindings.cc index e1574c1..45400f2 100644 --- a/chrome/renderer/dom_ui_bindings.cc +++ b/chrome/renderer/dom_ui_bindings.cc @@ -34,11 +34,11 @@ #include "chrome/common/render_messages.h" #include "chrome/common/stl_util-inl.h" -DOMUIBindings::DOMUIBindings() : routing_id_(0) { +void DOMUIBindings::BindMethods() { BindMethod("send", &DOMUIBindings::send); } -DOMUIBindings::~DOMUIBindings() { +DOMBoundBrowserObject::~DOMBoundBrowserObject() { STLDeleteContainerPointers(properties_.begin(), properties_.end()); } @@ -69,11 +69,11 @@ void DOMUIBindings::send(const CppArgumentList& args, CppVariant* result) { } // Send the message up to the browser. - sender_->Send( - new ViewHostMsg_DOMUISend(routing_id_, message, content)); + sender()->Send( + new ViewHostMsg_DOMUISend(routing_id(), message, content)); } -void DOMUIBindings::SetProperty(const std::string& name, +void DOMBoundBrowserObject::SetProperty(const std::string& name, const std::string& value) { CppVariant* cpp_value = new CppVariant; cpp_value->Set(value); diff --git a/chrome/renderer/dom_ui_bindings.h b/chrome/renderer/dom_ui_bindings.h index a7736e3..b41cfbe 100644 --- a/chrome/renderer/dom_ui_bindings.h +++ b/chrome/renderer/dom_ui_bindings.h @@ -33,21 +33,18 @@ #include "chrome/common/ipc_message.h" #include "webkit/glue/cpp_bound_class.h" -// DOMUIBindings is the class backing the "chrome" object accessible -// from Javascript from privileged pages. -// -// We expose one function, for sending a message to the browser: -// send(String name, Object argument); -// It's plumbed through to the OnDOMUIMessage callback on RenderViewHost -// delegate. -class DOMUIBindings : public CppBoundClass { +// A DOMBoundBrowserObject is a backing for some object bound to the window +// in JS that knows how to dispatch messages to an associated c++ object living +// in the browser process. +class DOMBoundBrowserObject : public CppBoundClass { public: - DOMUIBindings(); - ~DOMUIBindings(); - - // The send() function provided to Javascript. - void send(const CppArgumentList& args, CppVariant* result); + DOMBoundBrowserObject() : routing_id_(0) { } + virtual ~DOMBoundBrowserObject(); + // Different for each subclass; associates the javascript object with any + // number of methods. + virtual void BindMethods() = 0; + // Set the message channel back to the browser. void set_message_sender(IPC::Message::Sender* sender) { sender_ = sender; @@ -58,6 +55,9 @@ class DOMUIBindings : public CppBoundClass { routing_id_ = routing_id; } + IPC::Message::Sender* sender() { return sender_; } + int routing_id() { return routing_id_; } + // Sets a property with the given name and value. void SetProperty(const std::string& name, const std::string& value); @@ -71,6 +71,29 @@ class DOMUIBindings : public CppBoundClass { // can free them on destruction. typedef std::vector<CppVariant*> PropertyList; PropertyList properties_; + + DISALLOW_COPY_AND_ASSIGN(DOMBoundBrowserObject); +}; + +// DOMUIBindings is the class backing the "chrome" object accessible +// from Javascript from privileged pages. +// +// We expose one function, for sending a message to the browser: +// send(String name, Object argument); +// It's plumbed through to the OnDOMUIMessage callback on RenderViewHost +// delegate. +class DOMUIBindings : public DOMBoundBrowserObject { + public: + DOMUIBindings() { BindMethods(); } + virtual ~DOMUIBindings() {} + + // DOMBoundBrowserObject implementation. + virtual void BindMethods(); + + // The send() function provided to Javascript. + void send(const CppArgumentList& args, CppVariant* result); + private: + DISALLOW_COPY_AND_ASSIGN(DOMUIBindings); }; #endif // CHROME_RENDERER_DOM_UI_BINDINGS_H__ diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 0d57727..81e05bb 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -180,6 +180,9 @@ RenderView::RenderView() resource_dispatcher_ = new ResourceDispatcher(this); nav_state_sync_timer_.set_task( method_factory_.NewRunnableMethod(&RenderView::SyncNavigationState)); +#ifdef CHROME_PERSONALIZATION + personalization_ = Personalization::CreateRendererPersonalization(); +#endif } RenderView::~RenderView() { @@ -192,6 +195,11 @@ RenderView::~RenderView() { } RenderThread::current()->RemoveFilter(debug_message_handler_); + +#ifdef CHROME_PERSONALIZATION + Personalization::CleanupRendererPersonalization(personalization_); + personalization_ = NULL; +#endif } /*static*/ @@ -1409,6 +1417,10 @@ void RenderView::WindowObjectCleared(WebFrame* webframe) { dom_ui_bindings_.set_routing_id(routing_id_); dom_ui_bindings_.BindToJavascript(webframe, L"chrome"); } +#ifdef CHROME_PERSONALIZATION + Personalization::ConfigureRendererPersonalization(personalization_, this, + routing_id_, webframe); +#endif } WindowOpenDisposition RenderView::DispositionForNavigationAction( diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index cf3c0d1..635c077 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -41,6 +41,9 @@ #include "base/timer.h" #include "base/values.h" #include "chrome/common/resource_dispatcher.h" +#ifdef CHROME_PERSONALIZATION +#include "chrome/personalization/personalization.h" +#endif #include "chrome/renderer/automation/dom_automation_controller.h" #include "chrome/renderer/dom_ui_bindings.h" #include "chrome/renderer/external_js_object.h" @@ -504,6 +507,10 @@ class RenderView : public RenderWidget, public WebViewDelegate, bool enable_dom_ui_bindings_; DOMUIBindings dom_ui_bindings_; +#ifdef CHROME_PERSONALIZATION + RendererPersonalization personalization_; +#endif + // window.external object for "built-in" JS extensions ExternalJSObject external_js_object_; |