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

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: No this. 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 "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
9 #include "content/public/browser/browser_context.h"
10 #include "content/public/browser/render_view_host.h"
11 #include "content/public/browser/site_instance.h"
12 #include "content/public/browser/web_contents.h"
13 #include "content/public/common/renderer_preferences.h"
14 #include "extensions/common/extension_messages.h"
15
16 namespace apps {
17
18 CustomLauncherPageContents::CustomLauncherPageContents() {
19 }
20
21 CustomLauncherPageContents::~CustomLauncherPageContents() {
22 }
23
24 void CustomLauncherPageContents::Initialize(content::BrowserContext* context,
25 const GURL& url) {
26 extension_function_dispatcher_.reset(
27 new extensions::ExtensionFunctionDispatcher(context, this));
28
29 web_contents_.reset(
30 content::WebContents::Create(content::WebContents::CreateParams(
31 context, content::SiteInstance::CreateForURL(context, url))));
32
33 Observe(web_contents());
34 web_contents_->GetMutableRendererPrefs()
35 ->browser_handles_all_top_level_requests = true;
36 web_contents_->GetRenderViewHost()->SyncRendererPrefs();
37
38 // This observer will activate the extension when it is navigated to, which
39 // allows Dispatcher to give it the proper context and makes it behave like an
40 // extension.
41 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
42 web_contents());
43
44 web_contents_->GetController().LoadURL(url,
45 content::Referrer(),
46 content::PAGE_TRANSITION_AUTO_TOPLEVEL,
47 std::string());
48 }
49
50 bool CustomLauncherPageContents::OnMessageReceived(
51 const IPC::Message& message) {
52 bool handled = true;
53 IPC_BEGIN_MESSAGE_MAP(CustomLauncherPageContents, message)
54 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
55 IPC_MESSAGE_UNHANDLED(handled = false)
56 IPC_END_MESSAGE_MAP()
57 return handled;
58 }
59
60 extensions::WindowController*
61 CustomLauncherPageContents::GetExtensionWindowController() const {
62 return NULL;
63 }
64
65 content::WebContents* CustomLauncherPageContents::GetAssociatedWebContents()
66 const {
67 return web_contents();
68 }
69
70 void CustomLauncherPageContents::OnRequest(
71 const ExtensionHostMsg_Request_Params& params) {
72 extension_function_dispatcher_->Dispatch(params,
73 web_contents_->GetRenderViewHost());
74 }
75
76 } // namespace apps
OLDNEW
« no previous file with comments | « apps/custom_launcher_page_contents.h ('k') | chrome/browser/ui/app_list/app_list_view_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698