Index: apps/custom_launcher_page_contents.cc |
diff --git a/apps/custom_launcher_page_contents.cc b/apps/custom_launcher_page_contents.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6e0bd413fd3f61981a9c9f39839464138b27a87e |
--- /dev/null |
+++ b/apps/custom_launcher_page_contents.cc |
@@ -0,0 +1,75 @@ |
+// Copyright 2014 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 "apps/custom_launcher_page_contents.h" |
+ |
+#include "chrome/browser/chrome_notification_types.h" |
+#include "content/public/browser/browser_context.h" |
+#include "content/public/browser/render_view_host.h" |
+#include "content/public/browser/site_instance.h" |
+#include "content/public/browser/web_contents.h" |
+#include "content/public/common/renderer_preferences.h" |
+#include "extensions/common/extension_messages.h" |
+ |
+namespace apps { |
+ |
+CustomLauncherPageContents::CustomLauncherPageContents() { |
+} |
+ |
+CustomLauncherPageContents::~CustomLauncherPageContents() { |
+} |
+ |
+void CustomLauncherPageContents::Initialize(content::BrowserContext* context, |
+ const GURL& url) { |
+ url_ = url; |
+ |
+ extension_function_dispatcher_.reset( |
+ new extensions::ExtensionFunctionDispatcher(context, this)); |
+ |
+ web_contents_.reset( |
+ content::WebContents::Create(content::WebContents::CreateParams( |
+ context, content::SiteInstance::CreateForURL(context, url_)))); |
+ |
+ content::WebContentsObserver::Observe(web_contents_.get()); |
+ web_contents_->GetMutableRendererPrefs() |
+ ->browser_handles_all_top_level_requests = true; |
+ web_contents_->GetRenderViewHost()->SyncRendererPrefs(); |
+} |
+ |
+void CustomLauncherPageContents::LoadContents() { |
+ web_contents_->GetController().LoadURL( |
+ url_, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); |
+} |
+ |
+content::WebContents* CustomLauncherPageContents::GetWebContents() const { |
+ return web_contents_.get(); |
+} |
+ |
+bool CustomLauncherPageContents::OnMessageReceived( |
+ const IPC::Message& message) { |
+ bool handled = true; |
+ IPC_BEGIN_MESSAGE_MAP(CustomLauncherPageContents, message) |
+ IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) |
+ IPC_MESSAGE_UNHANDLED(handled = false) |
+ IPC_END_MESSAGE_MAP() |
+ return handled; |
+} |
+ |
+extensions::WindowController* |
+CustomLauncherPageContents::GetExtensionWindowController() const { |
+ return NULL; |
+} |
+ |
+content::WebContents* CustomLauncherPageContents::GetAssociatedWebContents() |
+ const { |
+ return web_contents_.get(); |
+} |
+ |
+void CustomLauncherPageContents::OnRequest( |
+ const ExtensionHostMsg_Request_Params& params) { |
+ extension_function_dispatcher_->Dispatch(params, |
+ web_contents_->GetRenderViewHost()); |
+} |
+ |
+} // namespace apps |