Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(981)

Unified Diff: apps/custom_launcher_page_contents.cc

Issue 365013003: Experimental app list: Custom launcher pages have app APIs and style. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made APIs work by introducing CustomLauncherPageContents. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698