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

Side by Side Diff: extensions/browser/app_window/app_window_contents.cc

Issue 527693002: Move AppWindowContentsImpl to extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 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
« no previous file with comments | « extensions/browser/app_window/app_window_contents.h ('k') | extensions/extensions.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "apps/app_window_contents.h" 5 #include "extensions/browser/app_window/app_window_contents.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/common/extensions/api/app_window.h"
12 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
13 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/render_process_host.h" 12 #include "content/public/browser/render_process_host.h"
15 #include "content/public/browser/render_view_host.h" 13 #include "content/public/browser/render_view_host.h"
16 #include "content/public/browser/resource_dispatcher_host.h" 14 #include "content/public/browser/resource_dispatcher_host.h"
17 #include "content/public/browser/site_instance.h" 15 #include "content/public/browser/site_instance.h"
18 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
19 #include "content/public/common/renderer_preferences.h" 17 #include "content/public/common/renderer_preferences.h"
20 #include "extensions/browser/app_window/native_app_window.h" 18 #include "extensions/browser/app_window/native_app_window.h"
21 #include "extensions/common/extension_messages.h" 19 #include "extensions/common/extension_messages.h"
22 20
23 namespace app_window = extensions::api::app_window; 21 namespace extensions {
24 using extensions::AppWindow;
25
26 namespace apps {
27 22
28 AppWindowContentsImpl::AppWindowContentsImpl(AppWindow* host) : host_(host) {} 23 AppWindowContentsImpl::AppWindowContentsImpl(AppWindow* host) : host_(host) {}
29 24
30 AppWindowContentsImpl::~AppWindowContentsImpl() {} 25 AppWindowContentsImpl::~AppWindowContentsImpl() {}
31 26
32 void AppWindowContentsImpl::Initialize(content::BrowserContext* context, 27 void AppWindowContentsImpl::Initialize(content::BrowserContext* context,
33 const GURL& url) { 28 const GURL& url) {
34 url_ = url; 29 url_ = url;
35 30
36 extension_function_dispatcher_.reset( 31 extension_function_dispatcher_.reset(
37 new extensions::ExtensionFunctionDispatcher(context, this)); 32 new ExtensionFunctionDispatcher(context, this));
38 33
39 web_contents_.reset( 34 web_contents_.reset(
40 content::WebContents::Create(content::WebContents::CreateParams( 35 content::WebContents::Create(content::WebContents::CreateParams(
41 context, content::SiteInstance::CreateForURL(context, url_)))); 36 context, content::SiteInstance::CreateForURL(context, url_))));
42 37
43 Observe(web_contents_.get()); 38 Observe(web_contents_.get());
44 web_contents_->GetMutableRendererPrefs()-> 39 web_contents_->GetMutableRendererPrefs()->
45 browser_handles_all_top_level_requests = true; 40 browser_handles_all_top_level_requests = true;
46 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); 41 web_contents_->GetRenderViewHost()->SyncRendererPrefs();
47 } 42 }
(...skipping 11 matching lines...) Expand all
59 << web_contents_->GetRenderViewHost()->GetProcess()->GetID() 54 << web_contents_->GetRenderViewHost()->GetProcess()->GetID()
60 << ") != creator (" << creator_process_id << "). Routing disabled."; 55 << ") != creator (" << creator_process_id << "). Routing disabled.";
61 } 56 }
62 57
63 web_contents_->GetController().LoadURL( 58 web_contents_->GetController().LoadURL(
64 url_, content::Referrer(), content::PAGE_TRANSITION_LINK, 59 url_, content::Referrer(), content::PAGE_TRANSITION_LINK,
65 std::string()); 60 std::string());
66 } 61 }
67 62
68 void AppWindowContentsImpl::NativeWindowChanged( 63 void AppWindowContentsImpl::NativeWindowChanged(
69 extensions::NativeAppWindow* native_app_window) { 64 NativeAppWindow* native_app_window) {
70 base::ListValue args; 65 base::ListValue args;
71 base::DictionaryValue* dictionary = new base::DictionaryValue(); 66 base::DictionaryValue* dictionary = new base::DictionaryValue();
72 args.Append(dictionary); 67 args.Append(dictionary);
73 host_->GetSerializedState(dictionary); 68 host_->GetSerializedState(dictionary);
74 69
75 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); 70 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost();
76 rvh->Send(new ExtensionMsg_MessageInvoke(rvh->GetRoutingID(), 71 rvh->Send(new ExtensionMsg_MessageInvoke(rvh->GetRoutingID(),
77 host_->extension_id(), 72 host_->extension_id(),
78 "app.window", 73 "app.window",
79 "updateAppWindowProperties", 74 "updateAppWindowProperties",
(...skipping 25 matching lines...) Expand all
105 bool handled = true; 100 bool handled = true;
106 IPC_BEGIN_MESSAGE_MAP(AppWindowContentsImpl, message) 101 IPC_BEGIN_MESSAGE_MAP(AppWindowContentsImpl, message)
107 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) 102 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
108 IPC_MESSAGE_HANDLER(ExtensionHostMsg_UpdateDraggableRegions, 103 IPC_MESSAGE_HANDLER(ExtensionHostMsg_UpdateDraggableRegions,
109 UpdateDraggableRegions) 104 UpdateDraggableRegions)
110 IPC_MESSAGE_UNHANDLED(handled = false) 105 IPC_MESSAGE_UNHANDLED(handled = false)
111 IPC_END_MESSAGE_MAP() 106 IPC_END_MESSAGE_MAP()
112 return handled; 107 return handled;
113 } 108 }
114 109
115 extensions::WindowController* 110 WindowController* AppWindowContentsImpl::GetExtensionWindowController() const {
116 AppWindowContentsImpl::GetExtensionWindowController() const {
117 return NULL; 111 return NULL;
118 } 112 }
119 113
120 content::WebContents* AppWindowContentsImpl::GetAssociatedWebContents() const { 114 content::WebContents* AppWindowContentsImpl::GetAssociatedWebContents() const {
121 return web_contents_.get(); 115 return web_contents_.get();
122 } 116 }
123 117
124 void AppWindowContentsImpl::OnRequest( 118 void AppWindowContentsImpl::OnRequest(
125 const ExtensionHostMsg_Request_Params& params) { 119 const ExtensionHostMsg_Request_Params& params) {
126 extension_function_dispatcher_->Dispatch( 120 extension_function_dispatcher_->Dispatch(
127 params, web_contents_->GetRenderViewHost()); 121 params, web_contents_->GetRenderViewHost());
128 } 122 }
129 123
130 void AppWindowContentsImpl::UpdateDraggableRegions( 124 void AppWindowContentsImpl::UpdateDraggableRegions(
131 const std::vector<extensions::DraggableRegion>& regions) { 125 const std::vector<DraggableRegion>& regions) {
132 host_->UpdateDraggableRegions(regions); 126 host_->UpdateDraggableRegions(regions);
133 } 127 }
134 128
135 void AppWindowContentsImpl::SuspendRenderViewHost( 129 void AppWindowContentsImpl::SuspendRenderViewHost(
136 content::RenderViewHost* rvh) { 130 content::RenderViewHost* rvh) {
137 DCHECK(rvh); 131 DCHECK(rvh);
138 content::BrowserThread::PostTask( 132 content::BrowserThread::PostTask(
139 content::BrowserThread::IO, FROM_HERE, 133 content::BrowserThread::IO, FROM_HERE,
140 base::Bind(&content::ResourceDispatcherHost::BlockRequestsForRoute, 134 base::Bind(&content::ResourceDispatcherHost::BlockRequestsForRoute,
141 base::Unretained(content::ResourceDispatcherHost::Get()), 135 base::Unretained(content::ResourceDispatcherHost::Get()),
142 rvh->GetProcess()->GetID(), rvh->GetRoutingID())); 136 rvh->GetProcess()->GetID(), rvh->GetRoutingID()));
143 } 137 }
144 138
145 } // namespace apps 139 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/app_window/app_window_contents.h ('k') | extensions/extensions.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698