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

Side by Side Diff: apps/shell/browser/shell_app_window.cc

Issue 412713002: Move apps/shell to extensions/shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 40% 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
« no previous file with comments | « apps/shell/browser/shell_app_window.h ('k') | apps/shell/browser/shell_app_window_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/shell/browser/shell_app_window.h"
6
7 #include "apps/shell/browser/shell_extension_web_contents_observer.h"
8 #include "content/public/browser/navigation_controller.h"
9 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/web_contents.h"
11 #include "extensions/browser/view_type_utils.h"
12 #include "extensions/common/extension_messages.h"
13 #include "ipc/ipc_message_macros.h"
14
15 using content::BrowserContext;
16 using content::WebContents;
17
18 namespace apps {
19
20 ShellAppWindow::ShellAppWindow() {}
21
22 ShellAppWindow::~ShellAppWindow() {}
23
24 void ShellAppWindow::Init(BrowserContext* context, gfx::Size initial_size) {
25 extension_function_dispatcher_.reset(
26 new extensions::ExtensionFunctionDispatcher(context, this));
27
28 // Create the web contents with an initial size to avoid a resize.
29 WebContents::CreateParams create_params(context);
30 create_params.initial_size = initial_size;
31 web_contents_.reset(WebContents::Create(create_params));
32
33 content::WebContentsObserver::Observe(web_contents_.get());
34
35 // Add support for extension startup.
36 extensions::ShellExtensionWebContentsObserver::CreateForWebContents(
37 web_contents_.get());
38
39 extensions::SetViewType(web_contents_.get(),
40 extensions::VIEW_TYPE_APP_WINDOW);
41 }
42
43 void ShellAppWindow::LoadURL(const GURL& url) {
44 content::NavigationController::LoadURLParams params(url);
45 web_contents_->GetController().LoadURLWithParams(params);
46 web_contents_->Focus();
47 }
48
49 aura::Window* ShellAppWindow::GetNativeWindow() {
50 return web_contents_->GetNativeView();
51 }
52
53 int ShellAppWindow::GetRenderViewRoutingID() {
54 return web_contents_->GetRenderViewHost()->GetRoutingID();
55 }
56
57 bool ShellAppWindow::OnMessageReceived(const IPC::Message& message) {
58 bool handled = true;
59 IPC_BEGIN_MESSAGE_MAP(ShellAppWindow, message)
60 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
61 IPC_MESSAGE_UNHANDLED(handled = false)
62 IPC_END_MESSAGE_MAP()
63 return handled;
64 }
65
66 content::WebContents* ShellAppWindow::GetAssociatedWebContents() const {
67 return web_contents_.get();
68 }
69
70 void ShellAppWindow::OnRequest(const ExtensionHostMsg_Request_Params& params) {
71 extension_function_dispatcher_->Dispatch(params,
72 web_contents_->GetRenderViewHost());
73 }
74
75 } // namespace apps
OLDNEW
« no previous file with comments | « apps/shell/browser/shell_app_window.h ('k') | apps/shell/browser/shell_app_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698