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