summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortimsteele@google.com <timsteele@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-15 18:46:34 +0000
committertimsteele@google.com <timsteele@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-15 18:46:34 +0000
commit3a453fa1f16dfa4168e52790e329148366abb05f (patch)
treea8bbab89ec883a838600e0b63d92fad4361e5dfb
parent173de1be12780200c62bae5c01965d51ac0eaa31 (diff)
downloadchromium_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
-rw-r--r--chrome/browser/browser_resources.rc5
-rw-r--r--chrome/browser/dom_ui/chrome_url_data_manager.cc17
-rw-r--r--chrome/browser/profile.cc22
-rw-r--r--chrome/browser/profile.h14
-rw-r--r--chrome/browser/render_view_host.cc19
-rw-r--r--chrome/browser/render_view_host.h17
-rw-r--r--chrome/browser/renderer_security_policy.cc12
-rw-r--r--chrome/browser/simple_xp_frame.h3
-rw-r--r--chrome/browser/xp_frame.cc31
-rw-r--r--chrome/browser/xp_frame.h18
-rw-r--r--chrome/common/chrome_switches.cc2
-rw-r--r--chrome/common/chrome_switches.h2
-rw-r--r--chrome/common/notification_types.h4
-rw-r--r--chrome/common/render_messages_internal.h5
-rw-r--r--chrome/renderer/dom_ui_bindings.cc10
-rw-r--r--chrome/renderer/dom_ui_bindings.h49
-rw-r--r--chrome/renderer/render_view.cc12
-rw-r--r--chrome/renderer/render_view.h7
-rw-r--r--chrome/test/testing_profile.h5
19 files changed, 232 insertions, 22 deletions
diff --git a/chrome/browser/browser_resources.rc b/chrome/browser/browser_resources.rc
index 46faac8..a445e161 100644
--- a/chrome/browser/browser_resources.rc
+++ b/chrome/browser/browser_resources.rc
@@ -8,6 +8,11 @@
#include "browser\\browser_resources.h"
+#ifdef CHROME_PERSONALIZATION
+#include "chrome\\personalization\\personalization_resources.rc"
+#endif
+
+
/////////////////////////////////////////////////////////////////////////////
//
// data resources
diff --git a/chrome/browser/dom_ui/chrome_url_data_manager.cc b/chrome/browser/dom_ui/chrome_url_data_manager.cc
index b35e049..9da9319 100644
--- a/chrome/browser/dom_ui/chrome_url_data_manager.cc
+++ b/chrome/browser/dom_ui/chrome_url_data_manager.cc
@@ -41,6 +41,12 @@
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_file_job.h"
#include "net/url_request/url_request_job.h"
+#ifdef CHROME_PERSONALIZATION
+// TODO(timsteele): Remove all CHROME_PERSONALIZATION code in this file.
+// It is only temporarily needed to configure some personalization data sources
+// that will go away soon.
+#include "chrome/personalization/personalization.h"
+#endif
// The URL scheme used for internal chrome resources.
// This URL scheme is never needed by code external to this module.
@@ -114,13 +120,24 @@ void RegisterURLRequestChromeJob() {
URLRequest::RegisterProtocolFactory(kChromeURLScheme,
&ChromeURLDataManager::Factory);
+#ifdef CHROME_PERSONALIZATION
+ url_util::AddStandardScheme(kPersonalizationScheme);
+ URLRequest::RegisterProtocolFactory(kPersonalizationScheme,
+ &ChromeURLDataManager::Factory);
+#endif
}
// static
void ChromeURLDataManager::URLToRequest(const GURL& url,
std::string* source_name,
std::string* path) {
+#ifdef CHROME_PERSONALIZATION
+ DCHECK(url.SchemeIs(kChromeURLScheme) ||
+ url.SchemeIs(kPersonalizationScheme));
+#else
DCHECK(url.SchemeIs(kChromeURLScheme));
+#endif
+
if (!url.is_valid()) {
NOTREACHED();
return;
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index 7030785..08d9a0a 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -502,6 +502,12 @@ class OffTheRecordProfileImpl : public Profile,
return profile_->GetBookmarkBarModel();
}
+#ifdef CHROME_PERSONALIZATION
+ virtual ProfilePersonalization GetProfilePersonalization() {
+ return profile_->GetProfilePersonalization();
+ }
+#endif
+
virtual bool IsSameProfile(Profile* profile) {
if (profile == static_cast<Profile*>(this))
return true;
@@ -575,6 +581,9 @@ ProfileImpl::ProfileImpl(const std::wstring& path)
create_session_service_task_(this),
start_time_(Time::Now()),
spellchecker_(NULL),
+#ifdef CHROME_PERSONALIZATION
+ personalization_(NULL),
+#endif
shutdown_session_service_(false) {
DCHECK(!path.empty()) << "Using an empty path will attempt to write " <<
"profile files to the root directory!";
@@ -596,6 +605,11 @@ ProfileImpl::~ProfileImpl() {
// before the history is shutdown so it can properly cancel all requests.
download_manager_ = NULL;
+#ifdef CHROME_PERSONALIZATION
+ Personalization::CleanupProfilePersonalization(personalization_);
+ personalization_ = NULL;
+#endif
+
// Both HistoryService and WebDataService maintain threads for background
// processing. Its possible each thread still has tasks on it that have
// increased the ref count of the service. In such a situation, when we
@@ -921,3 +935,11 @@ void ProfileImpl::StopCreateSessionServiceTimer() {
create_session_service_timer_ = NULL;
}
}
+
+#ifdef CHROME_PERSONALIZATION
+ProfilePersonalization ProfileImpl::GetProfilePersonalization() {
+ if (!personalization_)
+ personalization_ = Personalization::CreateProfilePersonalization(this);
+ return personalization_;
+}
+#endif \ No newline at end of file
diff --git a/chrome/browser/profile.h b/chrome/browser/profile.h
index 631a93c..b353f36 100644
--- a/chrome/browser/profile.h
+++ b/chrome/browser/profile.h
@@ -40,6 +40,9 @@
#include "base/scoped_ptr.h"
#include "base/task.h"
#include "base/time.h"
+#ifdef CHROME_PERSONALIZATION
+#include "chrome/personalization/personalization.h"
+#endif
class BookmarkBarModel;
class DownloadManager;
@@ -219,6 +222,10 @@ class Profile {
// Returns the BookmarkBarModel, creating if not yet created.
virtual BookmarkBarModel* GetBookmarkBarModel() = 0;
+#ifdef CHROME_PERSONALIZATION
+ virtual ProfilePersonalization GetProfilePersonalization() = 0;
+#endif
+
// Return whether 2 profiles are the same. 2 profiles are the same if they
// represent the same profile. This can happen if there is pointer equality
// or if one profile is the off the record version of another profile (or vice
@@ -299,6 +306,9 @@ class ProfileImpl : public Profile {
virtual void ResetTabRestoreService();
virtual SpellChecker* GetSpellChecker();
virtual void MarkAsCleanShutdown();
+#ifdef CHROME_PERSONALIZATION
+ virtual ProfilePersonalization GetProfilePersonalization();
+#endif
private:
class RequestContext;
@@ -337,6 +347,10 @@ class ProfileImpl : public Profile {
scoped_ptr<TemplateURLModel> template_url_model_;
scoped_ptr<BookmarkBarModel> bookmark_bar_model_;
+#ifdef CHROME_PERSONALIZATION
+ ProfilePersonalization personalization_;
+#endif
+
RequestContext* request_context_;
scoped_refptr<DownloadManager> download_manager_;
diff --git a/chrome/browser/render_view_host.cc b/chrome/browser/render_view_host.cc
index 7e9dd5e..0b84911 100644
--- a/chrome/browser/render_view_host.cc
+++ b/chrome/browser/render_view_host.cc
@@ -117,11 +117,19 @@ RenderViewHost::RenderViewHost(SiteInstance* instance,
modal_dialog_event = CreateEvent(NULL, TRUE, FALSE, NULL);
modal_dialog_event_.Set(modal_dialog_event);
+#ifdef CHROME_PERSONALIZATION
+ personalization_ = Personalization::CreateHostPersonalization(this);
+#endif
}
RenderViewHost::~RenderViewHost() {
OnDebugDisconnect();
+#ifdef CHROME_PERSONALIZATION
+ Personalization::CleanupHostPersonalization(personalization_);
+ personalization_ = NULL;
+#endif
+
// Be sure to clean up any leftover state from cross-site requests.
Singleton<CrossSiteRequestManager>()->SetHasPendingCrossSiteRequest(
process()->host_id(), routing_id_, false);
@@ -657,6 +665,10 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
OnMsgDomOperationResponse)
IPC_MESSAGE_HANDLER(ViewHostMsg_DOMUISend,
OnMsgDOMUISend)
+#ifdef CHROME_PERSONALIZATION
+ IPC_MESSAGE_HANDLER(ViewHostMsg_PersonalizationEvent,
+ OnPersonalizationEvent)
+#endif
IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset,
OnMsgGoToEntryAtOffset)
IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText)
@@ -1001,6 +1013,13 @@ void RenderViewHost::OnMsgDOMUISend(
delegate_->ProcessDOMUIMessage(message, content);
}
+#ifdef CHROME_PERSONALIZATION
+void RenderViewHost::OnPersonalizationEvent(const std::string& message,
+ const std::string& content) {
+ Personalization::HandlePersonalizationEvent(this, message, content);
+}
+#endif
+
void RenderViewHost::OnMsgGoToEntryAtOffset(int offset) {
delegate_->GoToEntryAtOffset(offset);
}
diff --git a/chrome/browser/render_view_host.h b/chrome/browser/render_view_host.h
index df158f9..b546331 100644
--- a/chrome/browser/render_view_host.h
+++ b/chrome/browser/render_view_host.h
@@ -36,6 +36,9 @@
#include "base/scoped_handle.h"
#include "chrome/browser/render_view_host_delegate.h"
#include "chrome/browser/render_widget_host.h"
+#ifdef CHROME_PERSONALIZATION
+#include "chrome/personalization/personalization.h"
+#endif
#include "webkit/glue/password_form_dom_manager.h"
enum ConsoleMessageLevel;
@@ -395,6 +398,12 @@ class RenderViewHost : public RenderWidgetHost {
// and we're necessarily leaving the page.
void UnloadListenerHasFired() { has_unload_listener_ = false; }
+#ifdef CHROME_PERSONALIZATION
+ HostPersonalization personalization() {
+ return personalization_;
+ }
+#endif
+
protected:
// Overridden from RenderWidgetHost:
virtual void UnhandledInputEvent(const WebInputEvent& event);
@@ -450,6 +459,10 @@ class RenderViewHost : public RenderWidgetHost {
int automation_id);
void OnMsgDOMUISend(const std::string& message,
const std::string& content);
+#ifdef CHROME_PERSONALIZATION
+ void OnPersonalizationEvent(const std::string& message,
+ const std::string& content);
+#endif
void OnMsgGoToEntryAtOffset(int offset);
void OnMsgSetTooltipText(const std::wstring& tooltip_text);
void OnMsgRunFileChooser(const std::wstring& default_file);
@@ -516,6 +529,10 @@ class RenderViewHost : public RenderWidgetHost {
// Our delegate, which wants to know about changes in the RenderView.
RenderViewHostDelegate* delegate_;
+#ifdef CHROME_PERSONALIZATION
+ HostPersonalization personalization_;
+#endif
+
// true if a renderer has once been valid. We use this flag to display a sad
// tab only when we lose our renderer and not if a paint occurs during
// initialization.
diff --git a/chrome/browser/renderer_security_policy.cc b/chrome/browser/renderer_security_policy.cc
index d4a8d965..91988da 100644
--- a/chrome/browser/renderer_security_policy.cc
+++ b/chrome/browser/renderer_security_policy.cc
@@ -31,6 +31,9 @@
#include "base/logging.h"
#include "base/string_util.h"
+#ifdef CHROME_PERSONALIZATION
+#include "chrome/personalization/personalization.h"
+#endif
#include "googleurl/src/gurl.h"
#include "net/url_request/url_request.h"
@@ -249,8 +252,8 @@ bool RendererSecurityPolicy::CanRequestURL(int renderer_id, const GURL& url) {
// There are a number of special cases for pseudo schemes.
if (url.SchemeIs("view-source")) {
- // A view-source URL is allowed if the renderer is permited to request the
- // embedded URL.
+ // A view-source URL is allowed if the renderer is permitted to request
+ // the embedded URL.
return CanRequestURL(renderer_id, GURL(url.path()));
}
@@ -263,6 +266,11 @@ bool RendererSecurityPolicy::CanRequestURL(int renderer_id, const GURL& url) {
return false;
}
+#ifdef CHROME_PERSONALIZATION
+ if (url.SchemeIs(kPersonalizationScheme))
+ return true;
+#endif
+
if (!URLRequest::IsHandledURL(url))
return true; // This URL request is destined for ShellExecute.
diff --git a/chrome/browser/simple_xp_frame.h b/chrome/browser/simple_xp_frame.h
index 2624fb35..71f6ed6 100644
--- a/chrome/browser/simple_xp_frame.h
+++ b/chrome/browser/simple_xp_frame.h
@@ -66,6 +66,9 @@ class SimpleXPFrame : public XPFrame,
virtual bool IsTabStripVisible() const { return false; }
virtual bool IsToolBarVisible() const { return false; }
virtual bool SupportsBookmarkBar() const { return false; }
+#ifdef CHROME_PERSONALIZATION
+ virtual bool PersonalizationEnabled() const { return false; }
+#endif
virtual LRESULT OnNCHitTest(const CPoint& pt);
virtual void SetWindowTitle(const std::wstring& title);
virtual void ValidateThrobber();
diff --git a/chrome/browser/xp_frame.cc b/chrome/browser/xp_frame.cc
index 6f21f23..bb2aefe 100644
--- a/chrome/browser/xp_frame.cc
+++ b/chrome/browser/xp_frame.cc
@@ -31,6 +31,7 @@
#include <windows.h>
+#include "base/command_line.h"
#include "base/gfx/native_theme.h"
#include "base/gfx/rect.h"
#include "chrome/app/theme/theme_resources.h"
@@ -49,6 +50,7 @@
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/window_clipping_info.h"
#include "chrome/common/chrome_constants.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/gfx/chrome_canvas.h"
#include "chrome/common/l10n_util.h"
#include "chrome/common/pref_names.h"
@@ -333,6 +335,10 @@ XPFrame* XPFrame::CreateFrame(const gfx::Rect& bounds,
l10n_util::GetString(IDS_PRODUCT_NAME).c_str());
instance->InitAfterHWNDCreated();
instance->SetIsOffTheRecord(is_otr);
+#ifdef CHROME_PERSONALIZATION
+ instance->EnablePersonalization(CommandLine().HasSwitch(
+ switches::kEnableP13n));
+#endif
FocusManager::CreateFocusManager(instance->m_hWnd, &(instance->root_view_));
return instance;
}
@@ -363,6 +369,10 @@ XPFrame::XPFrame(Browser* browser)
off_the_record_image_(NULL),
distributor_logo_(NULL),
ignore_ncactivate_(false),
+#ifdef CHROME_PERSONALIZATION
+ personalization_enabled_(false),
+ personalization_(NULL),
+#endif
paint_as_active_(false),
browser_view_(NULL) {
InitializeIfNeeded();
@@ -449,6 +459,13 @@ void XPFrame::Init() {
tab_contents_container_ = new TabContentsContainerView();
frame_view_->AddChildView(tab_contents_container_);
+#ifdef CHROME_PERSONALIZATION
+ if (PersonalizationEnabled()) {
+ personalization_ = Personalization::CreateFramePersonalization(
+ browser_->profile(), frame_view_);
+ }
+#endif
+
if (is_off_the_record_) {
off_the_record_image_ = new ChromeViews::ImageView();
SkBitmap* otr_icon = rb.GetBitmapNamed(IDR_OTR_ICON);
@@ -726,11 +743,17 @@ void XPFrame::Layout() {
off_the_record_image_->SetVisible(false);
}
+ int browser_view_width = width - left_margin - right_margin;
+#ifdef CHROME_PERSONALIZATION
+ if (PersonalizationEnabled())
+ Personalization::AdjustBrowserView(personalization_, &browser_view_width);
+#endif
+
if (IsToolBarVisible()) {
browser_view_->SetVisible(true);
browser_view_->SetBounds(left_margin,
last_y - kToolbarOverlapVertOffset,
- width - left_margin - right_margin,
+ browser_view_width,
bitmaps[CT_TOP_CENTER]->height());
browser_view_->Layout();
title_bar_height_ = browser_view_->GetY();
@@ -824,6 +847,12 @@ void XPFrame::Layout() {
last_y,
width - left_margin - right_margin,
browser_h);
+#ifdef CHROME_PERSONALIZATION
+ if (PersonalizationEnabled()) {
+ Personalization::ConfigureFramePersonalization(personalization_,
+ browser_view_, top_margin);
+ }
+#endif
browser_view_->LayoutStatusBubble(last_y + browser_h);
diff --git a/chrome/browser/xp_frame.h b/chrome/browser/xp_frame.h
index 92a1ef1..aa4eacb 100644
--- a/chrome/browser/xp_frame.h
+++ b/chrome/browser/xp_frame.h
@@ -46,6 +46,9 @@
#include "chrome/views/hwnd_view.h"
#include "chrome/views/root_view.h"
#include "chrome/views/image_view.h"
+#ifdef CHROME_PERSONALIZATION
+#include "chrome/personalization/personalization.h"
+#endif
#define XP_FRAME_CLASSNAME L"Chrome_XPFrame"
@@ -225,6 +228,16 @@ class XPFrame : public BrowserWindow,
// returns true.
virtual bool IsToolBarVisible() const { return true; }
+#ifdef CHROME_PERSONALIZATION
+ virtual bool PersonalizationEnabled() const {
+ return personalization_enabled_;
+ }
+
+ void EnablePersonalization(bool enable_personalization) {
+ personalization_enabled_ = enable_personalization;
+ }
+#endif
+
// Return the frame view.
ChromeViews::View* GetFrameView() { return frame_view_; }
@@ -509,6 +522,11 @@ class XPFrame : public BrowserWindow,
// Whether this frame represents an off the record session.
bool is_off_the_record_;
+#ifdef CHROME_PERSONALIZATION
+ FramePersonalization personalization_;
+ bool personalization_enabled_;
+#endif
+
// Set during layout. Total height of the title bar.
int title_bar_height_;
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index c36d710..b329125 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -339,4 +339,6 @@ const wchar_t kUseNewHttp[] = L"new-http";
// Allow loading of the javascript debugger UI from the filesystem.
const wchar_t kJavaScriptDebuggerPath[] = L"javascript-debugger-path";
+const wchar_t kEnableP13n[] = L"enable-p13n";
+
} // namespace switches
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 11ce1bc..7528fae 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -143,6 +143,8 @@ extern const wchar_t kUseNewHttp[];
extern const wchar_t kJavaScriptDebuggerPath[];
+extern const wchar_t kEnableP13n[];
+
} // namespace switches
#endif // CHROME_COMMON_CHROME_SWITCHES_H__
diff --git a/chrome/common/notification_types.h b/chrome/common/notification_types.h
index 4724c0b..1080ffa 100644
--- a/chrome/common/notification_types.h
+++ b/chrome/common/notification_types.h
@@ -473,8 +473,10 @@ enum NotificationType {
// are all source and no details.
NOTIFY_SESSION_END,
- // Count (must be last) ------------------------------------------------------
+ // Personalization -----------------------------------------------------------
+ NOTIFY_PERSONALIZATION,
+ // Count (must be last) ------------------------------------------------------
// Used to determine the number of notification types. Not valid as
// a type parameter when registering for or posting notifications.
NOTIFICATION_TYPE_COUNT
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 841f661..2257551 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -723,6 +723,11 @@ IPC_BEGIN_MESSAGES(ViewHost, 2)
std::string /* message */,
std::string /* args (as a JSON string) */)
+#ifdef CHROME_PERSONALIZATION
+ IPC_MESSAGE_ROUTED2(ViewHostMsg_PersonalizationEvent,
+ std::string, std::string )
+#endif
+
// A renderer sends this to the browser process when it wants to create a
// plugin. The browser will create the plugin process if necessary, and
// will return the channel name on success. On error an empty string is
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_;
diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h
index 05df5e5..0b30b71 100644
--- a/chrome/test/testing_profile.h
+++ b/chrome/test/testing_profile.h
@@ -168,6 +168,11 @@ class TestingProfile : public Profile {
virtual void MarkAsCleanShutdown() {
}
+#ifdef CHROME_PERSONALIZATION
+ virtual ProfilePersonalization GetProfilePersonalization() {
+ }
+#endif
+
protected:
Time start_time_;
ProfileControllerSet controllers_;