OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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.h" | 5 #include "extensions/browser/app_window/app_window.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "apps/app_window_registry.h" | |
12 #include "apps/ui/apps_client.h" | |
13 #include "base/command_line.h" | 11 #include "base/command_line.h" |
14 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
16 #include "base/values.h" | 14 #include "base/values.h" |
17 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 15 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
18 #include "content/public/browser/browser_context.h" | 16 #include "content/public/browser/browser_context.h" |
19 #include "content/public/browser/invalidate_type.h" | 17 #include "content/public/browser/invalidate_type.h" |
20 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
21 #include "content/public/browser/notification_details.h" | 19 #include "content/public/browser/notification_details.h" |
22 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
23 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
24 #include "content/public/browser/notification_types.h" | 22 #include "content/public/browser/notification_types.h" |
25 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
26 #include "content/public/browser/resource_dispatcher_host.h" | 24 #include "content/public/browser/resource_dispatcher_host.h" |
27 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
28 #include "content/public/common/content_switches.h" | 26 #include "content/public/common/content_switches.h" |
29 #include "content/public/common/media_stream_request.h" | 27 #include "content/public/common/media_stream_request.h" |
30 #include "extensions/browser/app_window/app_delegate.h" | 28 #include "extensions/browser/app_window/app_delegate.h" |
31 #include "extensions/browser/app_window/app_web_contents_helper.h" | 29 #include "extensions/browser/app_window/app_web_contents_helper.h" |
32 #include "extensions/browser/app_window/app_window_geometry_cache.h" | 30 #include "extensions/browser/app_window/app_window_geometry_cache.h" |
| 31 #include "extensions/browser/app_window/app_window_registry.h" |
| 32 #include "extensions/browser/app_window/apps_client.h" |
33 #include "extensions/browser/app_window/native_app_window.h" | 33 #include "extensions/browser/app_window/native_app_window.h" |
34 #include "extensions/browser/app_window/size_constraints.h" | 34 #include "extensions/browser/app_window/size_constraints.h" |
35 #include "extensions/browser/extension_registry.h" | 35 #include "extensions/browser/extension_registry.h" |
36 #include "extensions/browser/extension_system.h" | 36 #include "extensions/browser/extension_system.h" |
37 #include "extensions/browser/extensions_browser_client.h" | 37 #include "extensions/browser/extensions_browser_client.h" |
38 #include "extensions/browser/notification_types.h" | 38 #include "extensions/browser/notification_types.h" |
39 #include "extensions/browser/process_manager.h" | 39 #include "extensions/browser/process_manager.h" |
40 #include "extensions/browser/suggest_permission_util.h" | 40 #include "extensions/browser/suggest_permission_util.h" |
41 #include "extensions/browser/view_type_utils.h" | 41 #include "extensions/browser/view_type_utils.h" |
42 #include "extensions/common/draggable_region.h" | 42 #include "extensions/common/draggable_region.h" |
43 #include "extensions/common/extension.h" | 43 #include "extensions/common/extension.h" |
44 #include "extensions/common/manifest_handlers/icons_handler.h" | 44 #include "extensions/common/manifest_handlers/icons_handler.h" |
45 #include "extensions/common/permissions/permissions_data.h" | 45 #include "extensions/common/permissions/permissions_data.h" |
46 #include "extensions/common/switches.h" | 46 #include "extensions/common/switches.h" |
47 #include "third_party/skia/include/core/SkRegion.h" | 47 #include "third_party/skia/include/core/SkRegion.h" |
48 #include "ui/gfx/screen.h" | 48 #include "ui/gfx/screen.h" |
49 | 49 |
50 #if !defined(OS_MACOSX) | 50 #if !defined(OS_MACOSX) |
51 #include "base/prefs/pref_service.h" | 51 #include "base/prefs/pref_service.h" |
52 #include "extensions/browser/pref_names.h" | 52 #include "extensions/browser/pref_names.h" |
53 #endif | 53 #endif |
54 | 54 |
55 using content::BrowserContext; | 55 using content::BrowserContext; |
56 using content::ConsoleMessageLevel; | 56 using content::ConsoleMessageLevel; |
57 using content::WebContents; | 57 using content::WebContents; |
58 using extensions::APIPermission; | |
59 using extensions::NativeAppWindow; | |
60 using web_modal::WebContentsModalDialogHost; | 58 using web_modal::WebContentsModalDialogHost; |
61 using web_modal::WebContentsModalDialogManager; | 59 using web_modal::WebContentsModalDialogManager; |
62 | 60 |
63 namespace apps { | 61 namespace extensions { |
64 | 62 |
65 namespace { | 63 namespace { |
66 | 64 |
67 const int kDefaultWidth = 512; | 65 const int kDefaultWidth = 512; |
68 const int kDefaultHeight = 384; | 66 const int kDefaultHeight = 384; |
69 | 67 |
70 void SetConstraintProperty(const std::string& name, | 68 void SetConstraintProperty(const std::string& name, |
71 int value, | 69 int value, |
72 base::DictionaryValue* bounds_properties) { | 70 base::DictionaryValue* bounds_properties) { |
73 if (value != extensions::SizeConstraints::kUnboundedSize) | 71 if (value != SizeConstraints::kUnboundedSize) |
74 bounds_properties->SetInteger(name, value); | 72 bounds_properties->SetInteger(name, value); |
75 else | 73 else |
76 bounds_properties->Set(name, base::Value::CreateNullValue()); | 74 bounds_properties->Set(name, base::Value::CreateNullValue()); |
77 } | 75 } |
78 | 76 |
79 void SetBoundsProperties(const gfx::Rect& bounds, | 77 void SetBoundsProperties(const gfx::Rect& bounds, |
80 const gfx::Size& min_size, | 78 const gfx::Size& min_size, |
81 const gfx::Size& max_size, | 79 const gfx::Size& max_size, |
82 const std::string& bounds_name, | 80 const std::string& bounds_name, |
83 base::DictionaryValue* window_properties) { | 81 base::DictionaryValue* window_properties) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 if (content_spec.bounds.width() > 0) { | 176 if (content_spec.bounds.width() > 0) { |
179 combined_bounds.set_width( | 177 combined_bounds.set_width( |
180 content_spec.bounds.width() + frame_insets.width()); | 178 content_spec.bounds.width() + frame_insets.width()); |
181 } | 179 } |
182 if (content_spec.bounds.height() > 0) { | 180 if (content_spec.bounds.height() > 0) { |
183 combined_bounds.set_height( | 181 combined_bounds.set_height( |
184 content_spec.bounds.height() + frame_insets.height()); | 182 content_spec.bounds.height() + frame_insets.height()); |
185 } | 183 } |
186 | 184 |
187 // Constrain the bounds. | 185 // Constrain the bounds. |
188 extensions::SizeConstraints constraints( | 186 SizeConstraints constraints( |
189 GetCombinedWindowConstraints( | 187 GetCombinedWindowConstraints( |
190 window_spec.minimum_size, content_spec.minimum_size, frame_insets), | 188 window_spec.minimum_size, content_spec.minimum_size, frame_insets), |
191 GetCombinedWindowConstraints( | 189 GetCombinedWindowConstraints( |
192 window_spec.maximum_size, content_spec.maximum_size, frame_insets)); | 190 window_spec.maximum_size, content_spec.maximum_size, frame_insets)); |
193 combined_bounds.set_size(constraints.ClampSize(combined_bounds.size())); | 191 combined_bounds.set_size(constraints.ClampSize(combined_bounds.size())); |
194 | 192 |
195 return combined_bounds; | 193 return combined_bounds; |
196 } | 194 } |
197 | 195 |
198 gfx::Size AppWindow::CreateParams::GetContentMinimumSize( | 196 gfx::Size AppWindow::CreateParams::GetContentMinimumSize( |
(...skipping 20 matching lines...) Expand all Loading... |
219 gfx::Size AppWindow::CreateParams::GetWindowMaximumSize( | 217 gfx::Size AppWindow::CreateParams::GetWindowMaximumSize( |
220 const gfx::Insets& frame_insets) const { | 218 const gfx::Insets& frame_insets) const { |
221 return GetCombinedWindowConstraints(window_spec.maximum_size, | 219 return GetCombinedWindowConstraints(window_spec.maximum_size, |
222 content_spec.maximum_size, | 220 content_spec.maximum_size, |
223 frame_insets); | 221 frame_insets); |
224 } | 222 } |
225 | 223 |
226 // AppWindow | 224 // AppWindow |
227 | 225 |
228 AppWindow::AppWindow(BrowserContext* context, | 226 AppWindow::AppWindow(BrowserContext* context, |
229 extensions::AppDelegate* app_delegate, | 227 AppDelegate* app_delegate, |
230 const extensions::Extension* extension) | 228 const Extension* extension) |
231 : browser_context_(context), | 229 : browser_context_(context), |
232 extension_id_(extension->id()), | 230 extension_id_(extension->id()), |
233 window_type_(WINDOW_TYPE_DEFAULT), | 231 window_type_(WINDOW_TYPE_DEFAULT), |
234 app_delegate_(app_delegate), | 232 app_delegate_(app_delegate), |
235 image_loader_ptr_factory_(this), | 233 image_loader_ptr_factory_(this), |
236 fullscreen_types_(FULLSCREEN_TYPE_NONE), | 234 fullscreen_types_(FULLSCREEN_TYPE_NONE), |
237 show_on_first_paint_(false), | 235 show_on_first_paint_(false), |
238 first_paint_complete_(false), | 236 first_paint_complete_(false), |
239 has_been_shown_(false), | 237 has_been_shown_(false), |
240 can_send_events_(false), | 238 can_send_events_(false), |
241 is_hidden_(false), | 239 is_hidden_(false), |
242 cached_always_on_top_(false), | 240 cached_always_on_top_(false), |
243 requested_alpha_enabled_(false) { | 241 requested_alpha_enabled_(false) { |
244 extensions::ExtensionsBrowserClient* client = | 242 ExtensionsBrowserClient* client = ExtensionsBrowserClient::Get(); |
245 extensions::ExtensionsBrowserClient::Get(); | |
246 CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord()) | 243 CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord()) |
247 << "Only off the record window may be opened in the guest mode."; | 244 << "Only off the record window may be opened in the guest mode."; |
248 } | 245 } |
249 | 246 |
250 void AppWindow::Init(const GURL& url, | 247 void AppWindow::Init(const GURL& url, |
251 AppWindowContents* app_window_contents, | 248 AppWindowContents* app_window_contents, |
252 const CreateParams& params) { | 249 const CreateParams& params) { |
253 // Initialize the render interface and web contents | 250 // Initialize the render interface and web contents |
254 app_window_contents_.reset(app_window_contents); | 251 app_window_contents_.reset(app_window_contents); |
255 app_window_contents_->Initialize(browser_context(), url); | 252 app_window_contents_->Initialize(browser_context(), url); |
256 WebContents* web_contents = app_window_contents_->GetWebContents(); | 253 WebContents* web_contents = app_window_contents_->GetWebContents(); |
257 if (CommandLine::ForCurrentProcess()->HasSwitch( | 254 if (CommandLine::ForCurrentProcess()->HasSwitch( |
258 extensions::switches::kEnableAppsShowOnFirstPaint)) { | 255 switches::kEnableAppsShowOnFirstPaint)) { |
259 content::WebContentsObserver::Observe(web_contents); | 256 content::WebContentsObserver::Observe(web_contents); |
260 } | 257 } |
261 app_delegate_->InitWebContents(web_contents); | 258 app_delegate_->InitWebContents(web_contents); |
262 | 259 |
263 WebContentsModalDialogManager::CreateForWebContents(web_contents); | 260 WebContentsModalDialogManager::CreateForWebContents(web_contents); |
264 | 261 |
265 web_contents->SetDelegate(this); | 262 web_contents->SetDelegate(this); |
266 WebContentsModalDialogManager::FromWebContents(web_contents) | 263 WebContentsModalDialogManager::FromWebContents(web_contents) |
267 ->SetDelegate(this); | 264 ->SetDelegate(this); |
268 extensions::SetViewType(web_contents, extensions::VIEW_TYPE_APP_WINDOW); | 265 SetViewType(web_contents, VIEW_TYPE_APP_WINDOW); |
269 | 266 |
270 // Initialize the window | 267 // Initialize the window |
271 CreateParams new_params = LoadDefaults(params); | 268 CreateParams new_params = LoadDefaults(params); |
272 window_type_ = new_params.window_type; | 269 window_type_ = new_params.window_type; |
273 window_key_ = new_params.window_key; | 270 window_key_ = new_params.window_key; |
274 | 271 |
275 // Windows cannot be always-on-top in fullscreen mode for security reasons. | 272 // Windows cannot be always-on-top in fullscreen mode for security reasons. |
276 cached_always_on_top_ = new_params.always_on_top; | 273 cached_always_on_top_ = new_params.always_on_top; |
277 if (new_params.state == ui::SHOW_STATE_FULLSCREEN) | 274 if (new_params.state == ui::SHOW_STATE_FULLSCREEN) |
278 new_params.always_on_top = false; | 275 new_params.always_on_top = false; |
279 | 276 |
280 requested_alpha_enabled_ = new_params.alpha_enabled; | 277 requested_alpha_enabled_ = new_params.alpha_enabled; |
281 | 278 |
282 AppsClient* apps_client = AppsClient::Get(); | 279 AppsClient* apps_client = AppsClient::Get(); |
283 native_app_window_.reset( | 280 native_app_window_.reset( |
284 apps_client->CreateNativeAppWindow(this, new_params)); | 281 apps_client->CreateNativeAppWindow(this, new_params)); |
285 | 282 |
286 helper_.reset(new extensions::AppWebContentsHelper( | 283 helper_.reset(new AppWebContentsHelper( |
287 browser_context_, extension_id_, web_contents, app_delegate_.get())); | 284 browser_context_, extension_id_, web_contents, app_delegate_.get())); |
288 | 285 |
289 popup_manager_.reset( | 286 popup_manager_.reset( |
290 new web_modal::PopupManager(GetWebContentsModalDialogHost())); | 287 new web_modal::PopupManager(GetWebContentsModalDialogHost())); |
291 popup_manager_->RegisterWith(web_contents); | 288 popup_manager_->RegisterWith(web_contents); |
292 | 289 |
293 // Prevent the browser process from shutting down while this window exists. | 290 // Prevent the browser process from shutting down while this window exists. |
294 apps_client->IncrementKeepAliveCount(); | 291 apps_client->IncrementKeepAliveCount(); |
295 UpdateExtensionAppIcon(); | 292 UpdateExtensionAppIcon(); |
296 AppWindowRegistry::Get(browser_context_)->AddAppWindow(this); | 293 AppWindowRegistry::Get(browser_context_)->AddAppWindow(this); |
(...skipping 14 matching lines...) Expand all Loading... |
311 Maximize(); | 308 Maximize(); |
312 else if (new_params.state == ui::SHOW_STATE_MINIMIZED) | 309 else if (new_params.state == ui::SHOW_STATE_MINIMIZED) |
313 Minimize(); | 310 Minimize(); |
314 | 311 |
315 OnNativeWindowChanged(); | 312 OnNativeWindowChanged(); |
316 | 313 |
317 // When the render view host is changed, the native window needs to know | 314 // When the render view host is changed, the native window needs to know |
318 // about it in case it has any setup to do to make the renderer appear | 315 // about it in case it has any setup to do to make the renderer appear |
319 // properly. In particular, on Windows, the view's clickthrough region needs | 316 // properly. In particular, on Windows, the view's clickthrough region needs |
320 // to be set. | 317 // to be set. |
321 extensions::ExtensionsBrowserClient* client = | 318 ExtensionsBrowserClient* client = ExtensionsBrowserClient::Get(); |
322 extensions::ExtensionsBrowserClient::Get(); | |
323 registrar_.Add(this, | 319 registrar_.Add(this, |
324 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 320 NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
325 content::Source<content::BrowserContext>( | 321 content::Source<content::BrowserContext>( |
326 client->GetOriginalContext(browser_context_))); | 322 client->GetOriginalContext(browser_context_))); |
327 // Update the app menu if an ephemeral app becomes installed. | 323 // Update the app menu if an ephemeral app becomes installed. |
328 registrar_.Add( | 324 registrar_.Add( |
329 this, | 325 this, |
330 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, | 326 NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, |
331 content::Source<content::BrowserContext>( | 327 content::Source<content::BrowserContext>( |
332 client->GetOriginalContext(browser_context_))); | 328 client->GetOriginalContext(browser_context_))); |
333 | 329 |
334 // Close when the browser process is exiting. | 330 // Close when the browser process is exiting. |
335 app_delegate_->SetTerminatingCallback( | 331 app_delegate_->SetTerminatingCallback( |
336 base::Bind(&NativeAppWindow::Close, | 332 base::Bind(&NativeAppWindow::Close, |
337 base::Unretained(native_app_window_.get()))); | 333 base::Unretained(native_app_window_.get()))); |
338 | 334 |
339 app_window_contents_->LoadContents(new_params.creator_process_id); | 335 app_window_contents_->LoadContents(new_params.creator_process_id); |
340 | 336 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 disposition, | 380 disposition, |
385 initial_pos, | 381 initial_pos, |
386 user_gesture, | 382 user_gesture, |
387 was_blocked); | 383 was_blocked); |
388 } | 384 } |
389 | 385 |
390 bool AppWindow::PreHandleKeyboardEvent( | 386 bool AppWindow::PreHandleKeyboardEvent( |
391 content::WebContents* source, | 387 content::WebContents* source, |
392 const content::NativeWebKeyboardEvent& event, | 388 const content::NativeWebKeyboardEvent& event, |
393 bool* is_keyboard_shortcut) { | 389 bool* is_keyboard_shortcut) { |
394 const extensions::Extension* extension = GetExtension(); | 390 const Extension* extension = GetExtension(); |
395 if (!extension) | 391 if (!extension) |
396 return false; | 392 return false; |
397 | 393 |
398 // Here, we can handle a key event before the content gets it. When we are | 394 // Here, we can handle a key event before the content gets it. When we are |
399 // fullscreen and it is not forced, we want to allow the user to leave | 395 // fullscreen and it is not forced, we want to allow the user to leave |
400 // when ESC is pressed. | 396 // when ESC is pressed. |
401 // However, if the application has the "overrideEscFullscreen" permission, we | 397 // However, if the application has the "overrideEscFullscreen" permission, we |
402 // should let it override that behavior. | 398 // should let it override that behavior. |
403 // ::HandleKeyboardEvent() will only be called if the KeyEvent's default | 399 // ::HandleKeyboardEvent() will only be called if the KeyEvent's default |
404 // action is not prevented. | 400 // action is not prevented. |
(...skipping 26 matching lines...) Expand all Loading... |
431 | 427 |
432 void AppWindow::RequestToLockMouse(WebContents* web_contents, | 428 void AppWindow::RequestToLockMouse(WebContents* web_contents, |
433 bool user_gesture, | 429 bool user_gesture, |
434 bool last_unlocked_by_target) { | 430 bool last_unlocked_by_target) { |
435 DCHECK_EQ(AppWindow::web_contents(), web_contents); | 431 DCHECK_EQ(AppWindow::web_contents(), web_contents); |
436 helper_->RequestToLockMouse(); | 432 helper_->RequestToLockMouse(); |
437 } | 433 } |
438 | 434 |
439 bool AppWindow::PreHandleGestureEvent(WebContents* source, | 435 bool AppWindow::PreHandleGestureEvent(WebContents* source, |
440 const blink::WebGestureEvent& event) { | 436 const blink::WebGestureEvent& event) { |
441 return extensions::AppWebContentsHelper::ShouldSuppressGestureEvent(event); | 437 return AppWebContentsHelper::ShouldSuppressGestureEvent(event); |
442 } | 438 } |
443 | 439 |
444 void AppWindow::DidFirstVisuallyNonEmptyPaint() { | 440 void AppWindow::DidFirstVisuallyNonEmptyPaint() { |
445 first_paint_complete_ = true; | 441 first_paint_complete_ = true; |
446 if (show_on_first_paint_) { | 442 if (show_on_first_paint_) { |
447 DCHECK(delayed_show_type_ == SHOW_ACTIVE || | 443 DCHECK(delayed_show_type_ == SHOW_ACTIVE || |
448 delayed_show_type_ == SHOW_INACTIVE); | 444 delayed_show_type_ == SHOW_INACTIVE); |
449 Show(delayed_show_type_); | 445 Show(delayed_show_type_); |
450 } | 446 } |
451 } | 447 } |
(...skipping 25 matching lines...) Expand all Loading... |
477 } | 473 } |
478 | 474 |
479 void AppWindow::OnNativeWindowActivated() { | 475 void AppWindow::OnNativeWindowActivated() { |
480 AppWindowRegistry::Get(browser_context_)->AppWindowActivated(this); | 476 AppWindowRegistry::Get(browser_context_)->AppWindowActivated(this); |
481 } | 477 } |
482 | 478 |
483 content::WebContents* AppWindow::web_contents() const { | 479 content::WebContents* AppWindow::web_contents() const { |
484 return app_window_contents_->GetWebContents(); | 480 return app_window_contents_->GetWebContents(); |
485 } | 481 } |
486 | 482 |
487 const extensions::Extension* AppWindow::GetExtension() const { | 483 const Extension* AppWindow::GetExtension() const { |
488 return extensions::ExtensionRegistry::Get(browser_context_) | 484 return ExtensionRegistry::Get(browser_context_) |
489 ->enabled_extensions() | 485 ->enabled_extensions() |
490 .GetByID(extension_id_); | 486 .GetByID(extension_id_); |
491 } | 487 } |
492 | 488 |
493 NativeAppWindow* AppWindow::GetBaseWindow() { return native_app_window_.get(); } | 489 NativeAppWindow* AppWindow::GetBaseWindow() { return native_app_window_.get(); } |
494 | 490 |
495 gfx::NativeWindow AppWindow::GetNativeWindow() { | 491 gfx::NativeWindow AppWindow::GetNativeWindow() { |
496 return GetBaseWindow()->GetNativeWindow(); | 492 return GetBaseWindow()->GetNativeWindow(); |
497 } | 493 } |
498 | 494 |
499 gfx::Rect AppWindow::GetClientBounds() const { | 495 gfx::Rect AppWindow::GetClientBounds() const { |
500 gfx::Rect bounds = native_app_window_->GetBounds(); | 496 gfx::Rect bounds = native_app_window_->GetBounds(); |
501 bounds.Inset(native_app_window_->GetFrameInsets()); | 497 bounds.Inset(native_app_window_->GetFrameInsets()); |
502 return bounds; | 498 return bounds; |
503 } | 499 } |
504 | 500 |
505 base::string16 AppWindow::GetTitle() const { | 501 base::string16 AppWindow::GetTitle() const { |
506 const extensions::Extension* extension = GetExtension(); | 502 const Extension* extension = GetExtension(); |
507 if (!extension) | 503 if (!extension) |
508 return base::string16(); | 504 return base::string16(); |
509 | 505 |
510 // WebContents::GetTitle() will return the page's URL if there's no <title> | 506 // WebContents::GetTitle() will return the page's URL if there's no <title> |
511 // specified. However, we'd prefer to show the name of the extension in that | 507 // specified. However, we'd prefer to show the name of the extension in that |
512 // case, so we directly inspect the NavigationEntry's title. | 508 // case, so we directly inspect the NavigationEntry's title. |
513 base::string16 title; | 509 base::string16 title; |
514 if (!web_contents() || !web_contents()->GetController().GetActiveEntry() || | 510 if (!web_contents() || !web_contents()->GetController().GetActiveEntry() || |
515 web_contents()->GetController().GetActiveEntry()->GetTitle().empty()) { | 511 web_contents()->GetController().GetActiveEntry()->GetTitle().empty()) { |
516 title = base::UTF8ToUTF16(extension->name()); | 512 title = base::UTF8ToUTF16(extension->name()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 badge_icon_image_.reset(); | 557 badge_icon_image_.reset(); |
562 badge_icon_url_ = GURL(); | 558 badge_icon_url_ = GURL(); |
563 UpdateBadgeIcon(gfx::Image()); | 559 UpdateBadgeIcon(gfx::Image()); |
564 } | 560 } |
565 | 561 |
566 void AppWindow::UpdateShape(scoped_ptr<SkRegion> region) { | 562 void AppWindow::UpdateShape(scoped_ptr<SkRegion> region) { |
567 native_app_window_->UpdateShape(region.Pass()); | 563 native_app_window_->UpdateShape(region.Pass()); |
568 } | 564 } |
569 | 565 |
570 void AppWindow::UpdateDraggableRegions( | 566 void AppWindow::UpdateDraggableRegions( |
571 const std::vector<extensions::DraggableRegion>& regions) { | 567 const std::vector<DraggableRegion>& regions) { |
572 native_app_window_->UpdateDraggableRegions(regions); | 568 native_app_window_->UpdateDraggableRegions(regions); |
573 } | 569 } |
574 | 570 |
575 void AppWindow::UpdateAppIcon(const gfx::Image& image) { | 571 void AppWindow::UpdateAppIcon(const gfx::Image& image) { |
576 if (image.IsEmpty()) | 572 if (image.IsEmpty()) |
577 return; | 573 return; |
578 app_icon_ = image; | 574 app_icon_ = image; |
579 native_app_window_->UpdateWindowIcon(); | 575 native_app_window_->UpdateWindowIcon(); |
580 AppWindowRegistry::Get(browser_context_)->AppWindowIconChanged(this); | 576 AppWindowRegistry::Get(browser_context_)->AppWindowIconChanged(this); |
581 } | 577 } |
582 | 578 |
583 void AppWindow::SetFullscreen(FullscreenType type, bool enable) { | 579 void AppWindow::SetFullscreen(FullscreenType type, bool enable) { |
584 DCHECK_NE(FULLSCREEN_TYPE_NONE, type); | 580 DCHECK_NE(FULLSCREEN_TYPE_NONE, type); |
585 | 581 |
586 if (enable) { | 582 if (enable) { |
587 #if !defined(OS_MACOSX) | 583 #if !defined(OS_MACOSX) |
588 // Do not enter fullscreen mode if disallowed by pref. | 584 // Do not enter fullscreen mode if disallowed by pref. |
589 // TODO(bartfab): Add a test once it becomes possible to simulate a user | 585 // TODO(bartfab): Add a test once it becomes possible to simulate a user |
590 // gesture. http://crbug.com/174178 | 586 // gesture. http://crbug.com/174178 |
591 if (type != FULLSCREEN_TYPE_FORCED) { | 587 if (type != FULLSCREEN_TYPE_FORCED) { |
592 PrefService* prefs = | 588 PrefService* prefs = |
593 extensions::ExtensionsBrowserClient::Get()->GetPrefServiceForContext( | 589 ExtensionsBrowserClient::Get()->GetPrefServiceForContext( |
594 browser_context()); | 590 browser_context()); |
595 if (!prefs->GetBoolean(extensions::pref_names::kAppFullscreenAllowed)) | 591 if (!prefs->GetBoolean(pref_names::kAppFullscreenAllowed)) |
596 return; | 592 return; |
597 } | 593 } |
598 #endif | 594 #endif |
599 fullscreen_types_ |= type; | 595 fullscreen_types_ |= type; |
600 } else { | 596 } else { |
601 fullscreen_types_ &= ~type; | 597 fullscreen_types_ &= ~type; |
602 } | 598 } |
603 SetNativeWindowFullscreen(); | 599 SetNativeWindowFullscreen(); |
604 } | 600 } |
605 | 601 |
(...skipping 29 matching lines...) Expand all Loading... |
635 void AppWindow::OSFullscreen() { | 631 void AppWindow::OSFullscreen() { |
636 SetFullscreen(FULLSCREEN_TYPE_OS, true); | 632 SetFullscreen(FULLSCREEN_TYPE_OS, true); |
637 } | 633 } |
638 | 634 |
639 void AppWindow::ForcedFullscreen() { | 635 void AppWindow::ForcedFullscreen() { |
640 SetFullscreen(FULLSCREEN_TYPE_FORCED, true); | 636 SetFullscreen(FULLSCREEN_TYPE_FORCED, true); |
641 } | 637 } |
642 | 638 |
643 void AppWindow::SetContentSizeConstraints(const gfx::Size& min_size, | 639 void AppWindow::SetContentSizeConstraints(const gfx::Size& min_size, |
644 const gfx::Size& max_size) { | 640 const gfx::Size& max_size) { |
645 extensions::SizeConstraints constraints(min_size, max_size); | 641 SizeConstraints constraints(min_size, max_size); |
646 native_app_window_->SetContentSizeConstraints(constraints.GetMinimumSize(), | 642 native_app_window_->SetContentSizeConstraints(constraints.GetMinimumSize(), |
647 constraints.GetMaximumSize()); | 643 constraints.GetMaximumSize()); |
648 | 644 |
649 gfx::Rect bounds = GetClientBounds(); | 645 gfx::Rect bounds = GetClientBounds(); |
650 gfx::Size constrained_size = constraints.ClampSize(bounds.size()); | 646 gfx::Size constrained_size = constraints.ClampSize(bounds.size()); |
651 if (bounds.size() != constrained_size) { | 647 if (bounds.size() != constrained_size) { |
652 bounds.set_size(constrained_size); | 648 bounds.set_size(constrained_size); |
653 bounds.Inset(-native_app_window_->GetFrameInsets()); | 649 bounds.Inset(-native_app_window_->GetFrameInsets()); |
654 native_app_window_->SetBounds(bounds); | 650 native_app_window_->SetBounds(bounds); |
655 } | 651 } |
656 OnNativeWindowChanged(); | 652 OnNativeWindowChanged(); |
657 } | 653 } |
658 | 654 |
659 void AppWindow::Show(ShowType show_type) { | 655 void AppWindow::Show(ShowType show_type) { |
660 is_hidden_ = false; | 656 is_hidden_ = false; |
661 | 657 |
662 if (CommandLine::ForCurrentProcess()->HasSwitch( | 658 if (CommandLine::ForCurrentProcess()->HasSwitch( |
663 extensions::switches::kEnableAppsShowOnFirstPaint)) { | 659 switches::kEnableAppsShowOnFirstPaint)) { |
664 show_on_first_paint_ = true; | 660 show_on_first_paint_ = true; |
665 | 661 |
666 if (!first_paint_complete_) { | 662 if (!first_paint_complete_) { |
667 delayed_show_type_ = show_type; | 663 delayed_show_type_ = show_type; |
668 return; | 664 return; |
669 } | 665 } |
670 } | 666 } |
671 | 667 |
672 switch (show_type) { | 668 switch (show_type) { |
673 case SHOW_ACTIVE: | 669 case SHOW_ACTIVE: |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 gfx::Size content_min_size = native_app_window_->GetContentMinimumSize(); | 740 gfx::Size content_min_size = native_app_window_->GetContentMinimumSize(); |
745 gfx::Size content_max_size = native_app_window_->GetContentMaximumSize(); | 741 gfx::Size content_max_size = native_app_window_->GetContentMaximumSize(); |
746 SetBoundsProperties(content_bounds, | 742 SetBoundsProperties(content_bounds, |
747 content_min_size, | 743 content_min_size, |
748 content_max_size, | 744 content_max_size, |
749 "innerBounds", | 745 "innerBounds", |
750 properties); | 746 properties); |
751 | 747 |
752 gfx::Insets frame_insets = native_app_window_->GetFrameInsets(); | 748 gfx::Insets frame_insets = native_app_window_->GetFrameInsets(); |
753 gfx::Rect frame_bounds = native_app_window_->GetBounds(); | 749 gfx::Rect frame_bounds = native_app_window_->GetBounds(); |
754 gfx::Size frame_min_size = extensions::SizeConstraints::AddFrameToConstraints( | 750 gfx::Size frame_min_size = SizeConstraints::AddFrameToConstraints( |
755 content_min_size, frame_insets); | 751 content_min_size, frame_insets); |
756 gfx::Size frame_max_size = extensions::SizeConstraints::AddFrameToConstraints( | 752 gfx::Size frame_max_size = SizeConstraints::AddFrameToConstraints( |
757 content_max_size, frame_insets); | 753 content_max_size, frame_insets); |
758 SetBoundsProperties(frame_bounds, | 754 SetBoundsProperties(frame_bounds, |
759 frame_min_size, | 755 frame_min_size, |
760 frame_max_size, | 756 frame_max_size, |
761 "outerBounds", | 757 "outerBounds", |
762 properties); | 758 properties); |
763 } | 759 } |
764 | 760 |
765 //------------------------------------------------------------------------------ | 761 //------------------------------------------------------------------------------ |
766 // Private methods | 762 // Private methods |
(...skipping 24 matching lines...) Expand all Loading... |
791 } | 787 } |
792 const SkBitmap& largest = bitmaps[largest_index]; | 788 const SkBitmap& largest = bitmaps[largest_index]; |
793 if (image_url == app_icon_url_) { | 789 if (image_url == app_icon_url_) { |
794 UpdateAppIcon(gfx::Image::CreateFrom1xBitmap(largest)); | 790 UpdateAppIcon(gfx::Image::CreateFrom1xBitmap(largest)); |
795 return; | 791 return; |
796 } | 792 } |
797 | 793 |
798 UpdateBadgeIcon(gfx::Image::CreateFrom1xBitmap(largest)); | 794 UpdateBadgeIcon(gfx::Image::CreateFrom1xBitmap(largest)); |
799 } | 795 } |
800 | 796 |
801 void AppWindow::OnExtensionIconImageChanged(extensions::IconImage* image) { | 797 void AppWindow::OnExtensionIconImageChanged(IconImage* image) { |
802 DCHECK_EQ(app_icon_image_.get(), image); | 798 DCHECK_EQ(app_icon_image_.get(), image); |
803 | 799 |
804 UpdateAppIcon(gfx::Image(app_icon_image_->image_skia())); | 800 UpdateAppIcon(gfx::Image(app_icon_image_->image_skia())); |
805 } | 801 } |
806 | 802 |
807 void AppWindow::UpdateExtensionAppIcon() { | 803 void AppWindow::UpdateExtensionAppIcon() { |
808 // Avoid using any previous app icons were being downloaded. | 804 // Avoid using any previous app icons were being downloaded. |
809 image_loader_ptr_factory_.InvalidateWeakPtrs(); | 805 image_loader_ptr_factory_.InvalidateWeakPtrs(); |
810 | 806 |
811 const extensions::Extension* extension = GetExtension(); | 807 const Extension* extension = GetExtension(); |
812 if (!extension) | 808 if (!extension) |
813 return; | 809 return; |
814 | 810 |
815 app_icon_image_.reset( | 811 app_icon_image_.reset(new IconImage(browser_context(), |
816 new extensions::IconImage(browser_context(), | 812 extension, |
817 extension, | 813 IconsInfo::GetIcons(extension), |
818 extensions::IconsInfo::GetIcons(extension), | 814 app_delegate_->PreferredIconSize(), |
819 app_delegate_->PreferredIconSize(), | 815 app_delegate_->GetAppDefaultIcon(), |
820 app_delegate_->GetAppDefaultIcon(), | 816 this)); |
821 this)); | |
822 | 817 |
823 // Triggers actual image loading with 1x resources. The 2x resource will | 818 // Triggers actual image loading with 1x resources. The 2x resource will |
824 // be handled by IconImage class when requested. | 819 // be handled by IconImage class when requested. |
825 app_icon_image_->image_skia().GetRepresentation(1.0f); | 820 app_icon_image_->image_skia().GetRepresentation(1.0f); |
826 } | 821 } |
827 | 822 |
828 void AppWindow::SetNativeWindowFullscreen() { | 823 void AppWindow::SetNativeWindowFullscreen() { |
829 native_app_window_->SetFullscreen(fullscreen_types_); | 824 native_app_window_->SetFullscreen(fullscreen_types_); |
830 | 825 |
831 if (cached_always_on_top_) | 826 if (cached_always_on_top_) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 // When exiting fullscreen and moving away from the taskbar, reinstate | 863 // When exiting fullscreen and moving away from the taskbar, reinstate |
869 // always-on-top. | 864 // always-on-top. |
870 native_app_window_->SetAlwaysOnTop(true); | 865 native_app_window_->SetAlwaysOnTop(true); |
871 } | 866 } |
872 } | 867 } |
873 | 868 |
874 void AppWindow::SendOnWindowShownIfShown() { | 869 void AppWindow::SendOnWindowShownIfShown() { |
875 if (!can_send_events_ || !has_been_shown_) | 870 if (!can_send_events_ || !has_been_shown_) |
876 return; | 871 return; |
877 | 872 |
878 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { | 873 if (CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestType)) { |
879 app_window_contents_->DispatchWindowShownForTests(); | 874 app_window_contents_->DispatchWindowShownForTests(); |
880 } | 875 } |
881 } | 876 } |
882 | 877 |
883 void AppWindow::CloseContents(WebContents* contents) { | 878 void AppWindow::CloseContents(WebContents* contents) { |
884 native_app_window_->Close(); | 879 native_app_window_->Close(); |
885 } | 880 } |
886 | 881 |
887 bool AppWindow::ShouldSuppressDialogs() { return true; } | 882 bool AppWindow::ShouldSuppressDialogs() { return true; } |
888 | 883 |
(...skipping 26 matching lines...) Expand all Loading... |
915 void AppWindow::NavigationStateChanged(const content::WebContents* source, | 910 void AppWindow::NavigationStateChanged(const content::WebContents* source, |
916 content::InvalidateTypes changed_flags) { | 911 content::InvalidateTypes changed_flags) { |
917 if (changed_flags & content::INVALIDATE_TYPE_TITLE) | 912 if (changed_flags & content::INVALIDATE_TYPE_TITLE) |
918 native_app_window_->UpdateWindowTitle(); | 913 native_app_window_->UpdateWindowTitle(); |
919 else if (changed_flags & content::INVALIDATE_TYPE_TAB) | 914 else if (changed_flags & content::INVALIDATE_TYPE_TAB) |
920 native_app_window_->UpdateWindowIcon(); | 915 native_app_window_->UpdateWindowIcon(); |
921 } | 916 } |
922 | 917 |
923 void AppWindow::ToggleFullscreenModeForTab(content::WebContents* source, | 918 void AppWindow::ToggleFullscreenModeForTab(content::WebContents* source, |
924 bool enter_fullscreen) { | 919 bool enter_fullscreen) { |
925 const extensions::Extension* extension = GetExtension(); | 920 const Extension* extension = GetExtension(); |
926 if (!extension) | 921 if (!extension) |
927 return; | 922 return; |
928 | 923 |
929 if (!IsExtensionWithPermissionOrSuggestInConsole( | 924 if (!IsExtensionWithPermissionOrSuggestInConsole( |
930 APIPermission::kFullscreen, extension, source->GetRenderViewHost())) { | 925 APIPermission::kFullscreen, extension, source->GetRenderViewHost())) { |
931 return; | 926 return; |
932 } | 927 } |
933 | 928 |
934 SetFullscreen(FULLSCREEN_TYPE_HTML_API, enter_fullscreen); | 929 SetFullscreen(FULLSCREEN_TYPE_HTML_API, enter_fullscreen); |
935 } | 930 } |
936 | 931 |
937 bool AppWindow::IsFullscreenForTabOrPending(const content::WebContents* source) | 932 bool AppWindow::IsFullscreenForTabOrPending(const content::WebContents* source) |
938 const { | 933 const { |
939 return IsHtmlApiFullscreen(); | 934 return IsHtmlApiFullscreen(); |
940 } | 935 } |
941 | 936 |
942 void AppWindow::Observe(int type, | 937 void AppWindow::Observe(int type, |
943 const content::NotificationSource& source, | 938 const content::NotificationSource& source, |
944 const content::NotificationDetails& details) { | 939 const content::NotificationDetails& details) { |
945 switch (type) { | 940 switch (type) { |
946 case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { | 941 case NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { |
947 const extensions::Extension* unloaded_extension = | 942 const Extension* unloaded_extension = |
948 content::Details<extensions::UnloadedExtensionInfo>(details) | 943 content::Details<UnloadedExtensionInfo>(details)->extension; |
949 ->extension; | |
950 if (extension_id_ == unloaded_extension->id()) | 944 if (extension_id_ == unloaded_extension->id()) |
951 native_app_window_->Close(); | 945 native_app_window_->Close(); |
952 break; | 946 break; |
953 } | 947 } |
954 case extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED: { | 948 case NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED: { |
955 const extensions::Extension* installed_extension = | 949 const Extension* installed_extension = |
956 content::Details<const extensions::InstalledExtensionInfo>(details) | 950 content::Details<const InstalledExtensionInfo>(details)->extension; |
957 ->extension; | |
958 DCHECK(installed_extension); | 951 DCHECK(installed_extension); |
959 if (installed_extension->id() == extension_id()) | 952 if (installed_extension->id() == extension_id()) |
960 native_app_window_->UpdateShelfMenu(); | 953 native_app_window_->UpdateShelfMenu(); |
961 break; | 954 break; |
962 } | 955 } |
963 default: | 956 default: |
964 NOTREACHED() << "Received unexpected notification"; | 957 NOTREACHED() << "Received unexpected notification"; |
965 } | 958 } |
966 } | 959 } |
967 | 960 |
968 void AppWindow::SetWebContentsBlocked(content::WebContents* web_contents, | 961 void AppWindow::SetWebContentsBlocked(content::WebContents* web_contents, |
969 bool blocked) { | 962 bool blocked) { |
970 app_delegate_->SetWebContentsBlocked(web_contents, blocked); | 963 app_delegate_->SetWebContentsBlocked(web_contents, blocked); |
971 } | 964 } |
972 | 965 |
973 bool AppWindow::IsWebContentsVisible(content::WebContents* web_contents) { | 966 bool AppWindow::IsWebContentsVisible(content::WebContents* web_contents) { |
974 return app_delegate_->IsWebContentsVisible(web_contents); | 967 return app_delegate_->IsWebContentsVisible(web_contents); |
975 } | 968 } |
976 | 969 |
977 WebContentsModalDialogHost* AppWindow::GetWebContentsModalDialogHost() { | 970 WebContentsModalDialogHost* AppWindow::GetWebContentsModalDialogHost() { |
978 return native_app_window_.get(); | 971 return native_app_window_.get(); |
979 } | 972 } |
980 | 973 |
981 void AppWindow::SaveWindowPosition() { | 974 void AppWindow::SaveWindowPosition() { |
982 if (window_key_.empty()) | 975 if (window_key_.empty()) |
983 return; | 976 return; |
984 if (!native_app_window_) | 977 if (!native_app_window_) |
985 return; | 978 return; |
986 | 979 |
987 extensions::AppWindowGeometryCache* cache = | 980 AppWindowGeometryCache* cache = |
988 extensions::AppWindowGeometryCache::Get(browser_context()); | 981 AppWindowGeometryCache::Get(browser_context()); |
989 | 982 |
990 gfx::Rect bounds = native_app_window_->GetRestoredBounds(); | 983 gfx::Rect bounds = native_app_window_->GetRestoredBounds(); |
991 gfx::Rect screen_bounds = | 984 gfx::Rect screen_bounds = |
992 gfx::Screen::GetNativeScreen()->GetDisplayMatching(bounds).work_area(); | 985 gfx::Screen::GetNativeScreen()->GetDisplayMatching(bounds).work_area(); |
993 ui::WindowShowState window_state = native_app_window_->GetRestoredState(); | 986 ui::WindowShowState window_state = native_app_window_->GetRestoredState(); |
994 cache->SaveGeometry( | 987 cache->SaveGeometry( |
995 extension_id(), window_key_, bounds, screen_bounds, window_state); | 988 extension_id(), window_key_, bounds, screen_bounds, window_state); |
996 } | 989 } |
997 | 990 |
998 void AppWindow::AdjustBoundsToBeVisibleOnScreen( | 991 void AppWindow::AdjustBoundsToBeVisibleOnScreen( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 if (params.content_spec.bounds.height() == 0 && | 1028 if (params.content_spec.bounds.height() == 0 && |
1036 params.window_spec.bounds.height() == 0) { | 1029 params.window_spec.bounds.height() == 0) { |
1037 params.content_spec.bounds.set_height(kDefaultHeight); | 1030 params.content_spec.bounds.set_height(kDefaultHeight); |
1038 } | 1031 } |
1039 | 1032 |
1040 // If left and top are left undefined, the native app window will center | 1033 // If left and top are left undefined, the native app window will center |
1041 // the window on the main screen in a platform-defined manner. | 1034 // the window on the main screen in a platform-defined manner. |
1042 | 1035 |
1043 // Load cached state if it exists. | 1036 // Load cached state if it exists. |
1044 if (!params.window_key.empty()) { | 1037 if (!params.window_key.empty()) { |
1045 extensions::AppWindowGeometryCache* cache = | 1038 AppWindowGeometryCache* cache = |
1046 extensions::AppWindowGeometryCache::Get(browser_context()); | 1039 AppWindowGeometryCache::Get(browser_context()); |
1047 | 1040 |
1048 gfx::Rect cached_bounds; | 1041 gfx::Rect cached_bounds; |
1049 gfx::Rect cached_screen_bounds; | 1042 gfx::Rect cached_screen_bounds; |
1050 ui::WindowShowState cached_state = ui::SHOW_STATE_DEFAULT; | 1043 ui::WindowShowState cached_state = ui::SHOW_STATE_DEFAULT; |
1051 if (cache->GetGeometry(extension_id(), | 1044 if (cache->GetGeometry(extension_id(), |
1052 params.window_key, | 1045 params.window_key, |
1053 &cached_bounds, | 1046 &cached_bounds, |
1054 &cached_screen_bounds, | 1047 &cached_screen_bounds, |
1055 &cached_state)) { | 1048 &cached_state)) { |
1056 // App window has cached screen bounds, make sure it fits on screen in | 1049 // App window has cached screen bounds, make sure it fits on screen in |
1057 // case the screen resolution changed. | 1050 // case the screen resolution changed. |
1058 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); | 1051 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); |
1059 gfx::Display display = screen->GetDisplayMatching(cached_bounds); | 1052 gfx::Display display = screen->GetDisplayMatching(cached_bounds); |
1060 gfx::Rect current_screen_bounds = display.work_area(); | 1053 gfx::Rect current_screen_bounds = display.work_area(); |
1061 extensions::SizeConstraints constraints( | 1054 SizeConstraints constraints(params.GetWindowMinimumSize(gfx::Insets()), |
1062 params.GetWindowMinimumSize(gfx::Insets()), | 1055 params.GetWindowMaximumSize(gfx::Insets())); |
1063 params.GetWindowMaximumSize(gfx::Insets())); | |
1064 AdjustBoundsToBeVisibleOnScreen(cached_bounds, | 1056 AdjustBoundsToBeVisibleOnScreen(cached_bounds, |
1065 cached_screen_bounds, | 1057 cached_screen_bounds, |
1066 current_screen_bounds, | 1058 current_screen_bounds, |
1067 constraints.GetMinimumSize(), | 1059 constraints.GetMinimumSize(), |
1068 ¶ms.window_spec.bounds); | 1060 ¶ms.window_spec.bounds); |
1069 params.state = cached_state; | 1061 params.state = cached_state; |
1070 | 1062 |
1071 // Since we are restoring a cached state, reset the content bounds spec to | 1063 // Since we are restoring a cached state, reset the content bounds spec to |
1072 // ensure it is not used. | 1064 // ensure it is not used. |
1073 params.content_spec.ResetBounds(); | 1065 params.content_spec.ResetBounds(); |
1074 } | 1066 } |
1075 } | 1067 } |
1076 | 1068 |
1077 return params; | 1069 return params; |
1078 } | 1070 } |
1079 | 1071 |
1080 // static | 1072 // static |
1081 SkRegion* AppWindow::RawDraggableRegionsToSkRegion( | 1073 SkRegion* AppWindow::RawDraggableRegionsToSkRegion( |
1082 const std::vector<extensions::DraggableRegion>& regions) { | 1074 const std::vector<DraggableRegion>& regions) { |
1083 SkRegion* sk_region = new SkRegion; | 1075 SkRegion* sk_region = new SkRegion; |
1084 for (std::vector<extensions::DraggableRegion>::const_iterator iter = | 1076 for (std::vector<DraggableRegion>::const_iterator iter = regions.begin(); |
1085 regions.begin(); | |
1086 iter != regions.end(); | 1077 iter != regions.end(); |
1087 ++iter) { | 1078 ++iter) { |
1088 const extensions::DraggableRegion& region = *iter; | 1079 const DraggableRegion& region = *iter; |
1089 sk_region->op( | 1080 sk_region->op( |
1090 region.bounds.x(), | 1081 region.bounds.x(), |
1091 region.bounds.y(), | 1082 region.bounds.y(), |
1092 region.bounds.right(), | 1083 region.bounds.right(), |
1093 region.bounds.bottom(), | 1084 region.bounds.bottom(), |
1094 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 1085 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
1095 } | 1086 } |
1096 return sk_region; | 1087 return sk_region; |
1097 } | 1088 } |
1098 | 1089 |
1099 } // namespace apps | 1090 } // namespace extensions |
OLD | NEW |