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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "apps/custom_launcher_page_contents.h"
6
7 #include "chrome/browser/chrome_notification_types.h"
8 #include "content/public/browser/browser_context.h"
9 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/site_instance.h"
11 #include "content/public/browser/web_contents.h"
12 #include "content/public/common/renderer_preferences.h"
13 #include "extensions/common/extension_messages.h"
14
15 namespace apps {
16
17 CustomLauncherPageContents::CustomLauncherPageContents() {
18 }
19
20 CustomLauncherPageContents::~CustomLauncherPageContents() {
21 }
22
23 void CustomLauncherPageContents::Initialize(content::BrowserContext* context,
24 const GURL& url) {
25 url_ = url;
26
27 extension_function_dispatcher_.reset(
28 new extensions::ExtensionFunctionDispatcher(context, this));
29
30 web_contents_.reset(
31 content::WebContents::Create(content::WebContents::CreateParams(
32 context, content::SiteInstance::CreateForURL(context, url_))));
33
34 content::WebContentsObserver::Observe(web_contents_.get());
35 web_contents_->GetMutableRendererPrefs()
36 ->browser_handles_all_top_level_requests = true;
37 web_contents_->GetRenderViewHost()->SyncRendererPrefs();
38 }
39
40 void CustomLauncherPageContents::LoadContents() {
41 web_contents_->GetController().LoadURL(
42 url_, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string());
43 }
44
45 content::WebContents* CustomLauncherPageContents::GetWebContents() const {
46 return web_contents_.get();
47 }
48
49 bool CustomLauncherPageContents::OnMessageReceived(
50 const IPC::Message& message) {
51 bool handled = true;
52 IPC_BEGIN_MESSAGE_MAP(CustomLauncherPageContents, message)
53 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
54 IPC_MESSAGE_UNHANDLED(handled = false)
55 IPC_END_MESSAGE_MAP()
56 return handled;
57 }
58
59 extensions::WindowController*
60 CustomLauncherPageContents::GetExtensionWindowController() const {
61 return NULL;
62 }
63
64 content::WebContents* CustomLauncherPageContents::GetAssociatedWebContents()
65 const {
66 return web_contents_.get();
67 }
68
69 void CustomLauncherPageContents::OnRequest(
70 const ExtensionHostMsg_Request_Params& params) {
71 extension_function_dispatcher_->Dispatch(params,
72 web_contents_->GetRenderViewHost());
73 }
74
75 } // namespace apps
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698