Always show SSL error code at bottom of interstitial
[chromium-blink-merge.git] / apps / custom_launcher_page_contents.cc
blobfbcfe33be90c9d1ec9442f6e965691fa647ff879
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.
5 #include "apps/custom_launcher_page_contents.h"
7 #include <string>
9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
11 #include "content/public/browser/browser_context.h"
12 #include "content/public/browser/render_view_host.h"
13 #include "content/public/browser/site_instance.h"
14 #include "content/public/browser/web_contents.h"
15 #include "content/public/common/renderer_preferences.h"
16 #include "extensions/common/extension_messages.h"
18 namespace apps {
20 CustomLauncherPageContents::CustomLauncherPageContents() {
23 CustomLauncherPageContents::~CustomLauncherPageContents() {
26 void CustomLauncherPageContents::Initialize(content::BrowserContext* context,
27 const GURL& url) {
28 extension_function_dispatcher_.reset(
29 new extensions::ExtensionFunctionDispatcher(context, this));
31 web_contents_.reset(
32 content::WebContents::Create(content::WebContents::CreateParams(
33 context, content::SiteInstance::CreateForURL(context, url))));
35 Observe(web_contents());
36 web_contents_->GetMutableRendererPrefs()
37 ->browser_handles_all_top_level_requests = true;
38 web_contents_->GetRenderViewHost()->SyncRendererPrefs();
40 // This observer will activate the extension when it is navigated to, which
41 // allows Dispatcher to give it the proper context and makes it behave like an
42 // extension.
43 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
44 web_contents());
46 web_contents_->GetController().LoadURL(url,
47 content::Referrer(),
48 content::PAGE_TRANSITION_AUTO_TOPLEVEL,
49 std::string());
52 bool CustomLauncherPageContents::OnMessageReceived(
53 const IPC::Message& message) {
54 bool handled = true;
55 IPC_BEGIN_MESSAGE_MAP(CustomLauncherPageContents, message)
56 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
57 IPC_MESSAGE_UNHANDLED(handled = false)
58 IPC_END_MESSAGE_MAP()
59 return handled;
62 extensions::WindowController*
63 CustomLauncherPageContents::GetExtensionWindowController() const {
64 return NULL;
67 content::WebContents* CustomLauncherPageContents::GetAssociatedWebContents()
68 const {
69 return web_contents();
72 void CustomLauncherPageContents::OnRequest(
73 const ExtensionHostMsg_Request_Params& params) {
74 extension_function_dispatcher_->Dispatch(params,
75 web_contents_->GetRenderViewHost());
78 } // namespace apps