| OLD | NEW |
| 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 "apps/app_window_contents.h" |
| 6 | 6 |
| 7 #include "apps/ui/native_app_window.h" | 7 #include "apps/ui/native_app_window.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/extensions/api/app_window.h" | 10 #include "chrome/common/extensions/api/app_window.h" |
| 11 #include "chrome/common/extensions/extension_messages.h" | 11 #include "chrome/common/extensions/extension_messages.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "content/public/browser/render_process_host.h" | 13 #include "content/public/browser/render_process_host.h" |
| 14 #include "content/public/browser/render_view_host.h" | 14 #include "content/public/browser/render_view_host.h" |
| 15 #include "content/public/browser/resource_dispatcher_host.h" | 15 #include "content/public/browser/resource_dispatcher_host.h" |
| 16 #include "content/public/browser/site_instance.h" | 16 #include "content/public/browser/site_instance.h" |
| 17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "content/public/common/renderer_preferences.h" | 18 #include "content/public/common/renderer_preferences.h" |
| 19 | 19 |
| 20 namespace app_window = extensions::api::app_window; | 20 namespace app_window = extensions::api::app_window; |
| 21 | 21 |
| 22 namespace { |
| 23 |
| 24 const int kUnboundedSize = apps::ShellWindow::SizeConstraints::kUnboundedSize; |
| 25 |
| 26 } |
| 27 |
| 22 namespace apps { | 28 namespace apps { |
| 23 | 29 |
| 24 AppWindowContents::AppWindowContents(ShellWindow* host) | 30 AppWindowContents::AppWindowContents(ShellWindow* host) |
| 25 : host_(host) { | 31 : host_(host) { |
| 26 } | 32 } |
| 27 | 33 |
| 28 AppWindowContents::~AppWindowContents() { | 34 AppWindowContents::~AppWindowContents() { |
| 29 } | 35 } |
| 30 | 36 |
| 31 void AppWindowContents::Initialize(Profile* profile, const GURL& url) { | 37 void AppWindowContents::Initialize(Profile* profile, const GURL& url) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 update.top.reset(new int(bounds.y())); | 93 update.top.reset(new int(bounds.y())); |
| 88 update.width.reset(new int(bounds.width())); | 94 update.width.reset(new int(bounds.width())); |
| 89 update.height.reset(new int(bounds.height())); | 95 update.height.reset(new int(bounds.height())); |
| 90 dictionary->Set("bounds", update.ToValue().release()); | 96 dictionary->Set("bounds", update.ToValue().release()); |
| 91 dictionary->SetBoolean("fullscreen", | 97 dictionary->SetBoolean("fullscreen", |
| 92 native_app_window->IsFullscreenOrPending()); | 98 native_app_window->IsFullscreenOrPending()); |
| 93 dictionary->SetBoolean("minimized", native_app_window->IsMinimized()); | 99 dictionary->SetBoolean("minimized", native_app_window->IsMinimized()); |
| 94 dictionary->SetBoolean("maximized", native_app_window->IsMaximized()); | 100 dictionary->SetBoolean("maximized", native_app_window->IsMaximized()); |
| 95 dictionary->SetBoolean("alwaysOnTop", native_app_window->IsAlwaysOnTop()); | 101 dictionary->SetBoolean("alwaysOnTop", native_app_window->IsAlwaysOnTop()); |
| 96 | 102 |
| 103 const ShellWindow::SizeConstraints& size_constraints = |
| 104 host_->size_constraints(); |
| 105 gfx::Size min_size = size_constraints.GetMinimumSize(); |
| 106 gfx::Size max_size = size_constraints.GetMaximumSize(); |
| 107 if (min_size.width() != kUnboundedSize) |
| 108 dictionary->SetInteger("minWidth", min_size.width()); |
| 109 if (min_size.height() != kUnboundedSize) |
| 110 dictionary->SetInteger("minHeight", min_size.height()); |
| 111 if (max_size.width() != kUnboundedSize) |
| 112 dictionary->SetInteger("maxWidth", max_size.width()); |
| 113 if (max_size.height() != kUnboundedSize) |
| 114 dictionary->SetInteger("maxHeight", max_size.height()); |
| 115 |
| 97 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); | 116 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); |
| 98 rvh->Send(new ExtensionMsg_MessageInvoke(rvh->GetRoutingID(), | 117 rvh->Send(new ExtensionMsg_MessageInvoke(rvh->GetRoutingID(), |
| 99 host_->extension_id(), | 118 host_->extension_id(), |
| 100 "app.window", | 119 "app.window", |
| 101 "updateAppWindowProperties", | 120 "updateAppWindowProperties", |
| 102 args, | 121 args, |
| 103 false)); | 122 false)); |
| 104 } | 123 } |
| 105 | 124 |
| 106 void AppWindowContents::NativeWindowClosed() { | 125 void AppWindowContents::NativeWindowClosed() { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 content::RenderViewHost* rvh) { | 187 content::RenderViewHost* rvh) { |
| 169 DCHECK(rvh); | 188 DCHECK(rvh); |
| 170 content::BrowserThread::PostTask( | 189 content::BrowserThread::PostTask( |
| 171 content::BrowserThread::IO, FROM_HERE, | 190 content::BrowserThread::IO, FROM_HERE, |
| 172 base::Bind(&content::ResourceDispatcherHost::BlockRequestsForRoute, | 191 base::Bind(&content::ResourceDispatcherHost::BlockRequestsForRoute, |
| 173 base::Unretained(content::ResourceDispatcherHost::Get()), | 192 base::Unretained(content::ResourceDispatcherHost::Get()), |
| 174 rvh->GetProcess()->GetID(), rvh->GetRoutingID())); | 193 rvh->GetProcess()->GetID(), rvh->GetRoutingID())); |
| 175 } | 194 } |
| 176 | 195 |
| 177 } // namespace apps | 196 } // namespace apps |
| OLD | NEW |