OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/views/extensions/shell_window_views.h" | 5 #include "chrome/browser/ui/views/extensions/shell_window_views.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
9 #include "chrome/common/extensions/draggable_region.h" | 9 #include "chrome/common/extensions/draggable_region.h" |
10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 return max_size; | 297 return max_size; |
298 } | 298 } |
299 | 299 |
300 void ShellWindowFrameView::ButtonPressed(views::Button* sender, | 300 void ShellWindowFrameView::ButtonPressed(views::Button* sender, |
301 const views::Event& event) { | 301 const views::Event& event) { |
302 DCHECK(!window_->frameless()); | 302 DCHECK(!window_->frameless()); |
303 if (sender == close_button_) | 303 if (sender == close_button_) |
304 frame_->Close(); | 304 frame_->Close(); |
305 } | 305 } |
306 | 306 |
307 ShellWindowViews::ShellWindowViews(Profile* profile, | 307 ShellWindowViews::ShellWindowViews(ShellWindow* shell_window, |
308 const extensions::Extension* extension, | |
309 const GURL& url, | |
310 const ShellWindow::CreateParams& win_params) | 308 const ShellWindow::CreateParams& win_params) |
311 : ShellWindow(profile, extension, url), | 309 : shell_window_(shell_window), |
312 web_view_(NULL), | 310 web_view_(NULL), |
313 is_fullscreen_(false), | 311 is_fullscreen_(false), |
314 frameless_(win_params.frame == ShellWindow::CreateParams::FRAME_NONE) { | 312 frameless_(win_params.frame == ShellWindow::CreateParams::FRAME_NONE) { |
315 window_ = new views::Widget; | 313 window_ = new views::Widget; |
316 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 314 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
317 params.delegate = this; | 315 params.delegate = this; |
318 params.remove_standard_frame = true; | 316 params.remove_standard_frame = true; |
319 minimum_size_ = win_params.minimum_size; | 317 minimum_size_ = win_params.minimum_size; |
320 maximum_size_ = win_params.maximum_size; | 318 maximum_size_ = win_params.maximum_size; |
321 window_->Init(params); | 319 window_->Init(params); |
322 gfx::Rect window_bounds = | 320 gfx::Rect window_bounds = |
323 window_->non_client_view()->GetWindowBoundsForClientBounds( | 321 window_->non_client_view()->GetWindowBoundsForClientBounds( |
324 win_params.bounds); | 322 win_params.bounds); |
325 window_->SetBounds(window_bounds); | 323 window_->SetBounds(window_bounds); |
326 #if defined(OS_WIN) && !defined(USE_AURA) | 324 #if defined(OS_WIN) && !defined(USE_AURA) |
327 std::string app_name = web_app::GenerateApplicationNameFromExtensionId( | 325 std::string app_name = web_app::GenerateApplicationNameFromExtensionId( |
328 extension->id()); | 326 extension()->id()); |
329 ui::win::SetAppIdForWindow( | 327 ui::win::SetAppIdForWindow( |
330 ShellIntegration::GetAppModelIdForProfile(UTF8ToWide(app_name), | 328 ShellIntegration::GetAppModelIdForProfile( |
331 profile->GetPath()), | 329 UTF8ToWide(app_name), shell_window_->profile()->GetPath()), |
332 GetWidget()->GetTopLevelWidget()->GetNativeWindow()); | 330 GetWidget()->GetTopLevelWidget()->GetNativeWindow()); |
333 #endif | 331 #endif |
334 OnViewWasResized(); | 332 OnViewWasResized(); |
335 | 333 |
336 window_->Show(); | 334 window_->Show(); |
337 } | 335 } |
338 | 336 |
339 views::View* ShellWindowViews::GetInitiallyFocusedView() { | 337 views::View* ShellWindowViews::GetInitiallyFocusedView() { |
340 return web_view_; | 338 return web_view_; |
341 } | 339 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 | 448 |
451 void ShellWindowViews::FlashFrame(bool flash) { | 449 void ShellWindowViews::FlashFrame(bool flash) { |
452 window_->FlashFrame(flash); | 450 window_->FlashFrame(flash); |
453 } | 451 } |
454 | 452 |
455 bool ShellWindowViews::IsAlwaysOnTop() const { | 453 bool ShellWindowViews::IsAlwaysOnTop() const { |
456 return false; | 454 return false; |
457 } | 455 } |
458 | 456 |
459 void ShellWindowViews::DeleteDelegate() { | 457 void ShellWindowViews::DeleteDelegate() { |
460 OnNativeClose(); | 458 shell_window_->OnNativeClose(); |
461 } | 459 } |
462 | 460 |
463 bool ShellWindowViews::CanResize() const { | 461 bool ShellWindowViews::CanResize() const { |
464 return true; | 462 return true; |
465 } | 463 } |
466 | 464 |
467 bool ShellWindowViews::CanMaximize() const { | 465 bool ShellWindowViews::CanMaximize() const { |
468 return true; | 466 return true; |
469 } | 467 } |
470 | 468 |
471 views::View* ShellWindowViews::GetContentsView() { | 469 views::View* ShellWindowViews::GetContentsView() { |
472 return this; | 470 return this; |
473 } | 471 } |
474 | 472 |
475 views::NonClientFrameView* ShellWindowViews::CreateNonClientFrameView( | 473 views::NonClientFrameView* ShellWindowViews::CreateNonClientFrameView( |
476 views::Widget* widget) { | 474 views::Widget* widget) { |
477 ShellWindowFrameView* frame_view = new ShellWindowFrameView(this); | 475 ShellWindowFrameView* frame_view = new ShellWindowFrameView(this); |
478 frame_view->Init(window_); | 476 frame_view->Init(window_); |
479 return frame_view; | 477 return frame_view; |
480 } | 478 } |
481 | 479 |
482 string16 ShellWindowViews::GetWindowTitle() const { | 480 string16 ShellWindowViews::GetWindowTitle() const { |
483 return GetTitle(); | 481 return shell_window_->GetTitle(); |
484 } | 482 } |
485 | 483 |
486 views::Widget* ShellWindowViews::GetWidget() { | 484 views::Widget* ShellWindowViews::GetWidget() { |
487 return window_; | 485 return window_; |
488 } | 486 } |
489 | 487 |
490 const views::Widget* ShellWindowViews::GetWidget() const { | 488 const views::Widget* ShellWindowViews::GetWidget() const { |
491 return window_; | 489 return window_; |
492 } | 490 } |
493 | 491 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 if (!window_->IsMaximized()) { | 529 if (!window_->IsMaximized()) { |
532 if (frameless_) | 530 if (frameless_) |
533 rgn->op(0, 0, width, kResizeInsideBoundsSize, SkRegion::kUnion_Op); | 531 rgn->op(0, 0, width, kResizeInsideBoundsSize, SkRegion::kUnion_Op); |
534 rgn->op(0, 0, kResizeInsideBoundsSize, height, SkRegion::kUnion_Op); | 532 rgn->op(0, 0, kResizeInsideBoundsSize, height, SkRegion::kUnion_Op); |
535 rgn->op(width - kResizeInsideBoundsSize, 0, width, height, | 533 rgn->op(width - kResizeInsideBoundsSize, 0, width, height, |
536 SkRegion::kUnion_Op); | 534 SkRegion::kUnion_Op); |
537 rgn->op(0, height - kResizeInsideBoundsSize, width, height, | 535 rgn->op(0, height - kResizeInsideBoundsSize, width, height, |
538 SkRegion::kUnion_Op); | 536 SkRegion::kUnion_Op); |
539 } | 537 } |
540 } | 538 } |
541 web_contents()->GetRenderViewHost()->GetView()->SetClickthroughRegion(rgn); | 539 if (web_contents()->GetRenderViewHost()->GetView()) |
| 540 web_contents()->GetRenderViewHost()->GetView()->SetClickthroughRegion(rgn); |
542 #endif | 541 #endif |
543 } | 542 } |
544 | 543 |
545 void ShellWindowViews::Layout() { | 544 void ShellWindowViews::Layout() { |
546 DCHECK(web_view_); | 545 DCHECK(web_view_); |
547 web_view_->SetBounds(0, 0, width(), height()); | 546 web_view_->SetBounds(0, 0, width(), height()); |
548 OnViewWasResized(); | 547 OnViewWasResized(); |
549 } | 548 } |
550 | 549 |
551 void ShellWindowViews::UpdateWindowTitle() { | 550 void ShellWindowViews::UpdateWindowTitle() { |
(...skipping 23 matching lines...) Expand all Loading... |
575 region.bounds.right(), | 574 region.bounds.right(), |
576 region.bounds.bottom(), | 575 region.bounds.bottom(), |
577 SkRegion::kDifference_Op); | 576 SkRegion::kDifference_Op); |
578 } | 577 } |
579 | 578 |
580 draggable_region_.Set(draggable_region); | 579 draggable_region_.Set(draggable_region); |
581 OnViewWasResized(); | 580 OnViewWasResized(); |
582 } | 581 } |
583 | 582 |
584 // static | 583 // static |
585 ShellWindow* ShellWindow::CreateImpl(Profile* profile, | 584 NativeShellWindow* NativeShellWindow::Create( |
586 const extensions::Extension* extension, | 585 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { |
587 const GURL& url, | 586 return new ShellWindowViews(shell_window, params); |
588 const ShellWindow::CreateParams& params) { | |
589 return new ShellWindowViews(profile, extension, url, params); | |
590 } | 587 } |
OLD | NEW |