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/browser/favicon/favicon_tab_helper.h" | 9 #include "chrome/browser/favicon/favicon_tab_helper.h" |
10 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h" | 10 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h" |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
387 frame_->Restore(); | 387 frame_->Restore(); |
388 else if (sender == minimize_button_) | 388 else if (sender == minimize_button_) |
389 frame_->Minimize(); | 389 frame_->Minimize(); |
390 } | 390 } |
391 | 391 |
392 ShellWindowViews::ShellWindowViews(ShellWindow* shell_window, | 392 ShellWindowViews::ShellWindowViews(ShellWindow* shell_window, |
393 const ShellWindow::CreateParams& win_params) | 393 const ShellWindow::CreateParams& win_params) |
394 : shell_window_(shell_window), | 394 : shell_window_(shell_window), |
395 web_view_(NULL), | 395 web_view_(NULL), |
396 is_fullscreen_(false), | 396 is_fullscreen_(false), |
397 frameless_(win_params.frame == ShellWindow::CreateParams::FRAME_NONE) { | 397 frameless_(win_params.frame == ShellWindow::CreateParams::FRAME_NONE), |
398 transparent_background_(win_params.transparent_background) { | |
399 Observe(shell_window_->web_contents()); | |
398 window_ = new views::Widget; | 400 window_ = new views::Widget; |
399 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 401 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
400 params.delegate = this; | 402 params.delegate = this; |
401 params.remove_standard_frame = true; | 403 params.remove_standard_frame = true; |
402 params.use_system_default_icon = true; | 404 params.use_system_default_icon = true; |
sky
2012/11/08 16:29:10
Don't you also need to set params.transparent? And
Bernie
2012/12/18 21:08:36
The helloworld demo app gets a transparent backgro
| |
403 minimum_size_ = win_params.minimum_size; | 405 minimum_size_ = win_params.minimum_size; |
404 maximum_size_ = win_params.maximum_size; | 406 maximum_size_ = win_params.maximum_size; |
405 window_->Init(params); | 407 window_->Init(params); |
406 gfx::Rect window_bounds = | 408 gfx::Rect window_bounds = |
407 window_->non_client_view()->GetWindowBoundsForClientBounds( | 409 window_->non_client_view()->GetWindowBoundsForClientBounds( |
408 win_params.bounds); | 410 win_params.bounds); |
409 // Center window if no position was specified. | 411 // Center window if no position was specified. |
410 if (win_params.bounds.x() == INT_MIN || win_params.bounds.y() == INT_MIN) { | 412 if (win_params.bounds.x() == INT_MIN || win_params.bounds.y() == INT_MIN) { |
411 window_->CenterWindow(window_bounds.size()); | 413 window_->CenterWindow(window_bounds.size()); |
412 } else { | 414 } else { |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
683 } | 685 } |
684 | 686 |
685 bool ShellWindowViews::ShouldShowWindowTitle() const { | 687 bool ShellWindowViews::ShouldShowWindowTitle() const { |
686 return false; | 688 return false; |
687 } | 689 } |
688 | 690 |
689 void ShellWindowViews::OnWidgetMove() { | 691 void ShellWindowViews::OnWidgetMove() { |
690 shell_window_->SaveWindowPosition(); | 692 shell_window_->SaveWindowPosition(); |
691 } | 693 } |
692 | 694 |
695 void ShellWindowViews::RenderViewCreated( | |
696 content::RenderViewHost* render_view_host) { | |
697 if (transparent_background_) { | |
698 // Use a background with transparency to trigger transparency in Webkit. | |
699 SkBitmap background; | |
700 background.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); | |
701 background.allocPixels(); | |
702 background.eraseARGB(0x00, 0x00, 0x00, 0x00); | |
703 | |
704 content::RenderWidgetHostView* view = render_view_host->GetView(); | |
705 DCHECK(view); | |
706 view->SetBackground(background); | |
707 } | |
708 } | |
709 | |
693 void ShellWindowViews::Layout() { | 710 void ShellWindowViews::Layout() { |
694 DCHECK(web_view_); | 711 DCHECK(web_view_); |
695 web_view_->SetBounds(0, 0, width(), height()); | 712 web_view_->SetBounds(0, 0, width(), height()); |
696 OnViewWasResized(); | 713 OnViewWasResized(); |
697 } | 714 } |
698 | 715 |
699 void ShellWindowViews::UpdateWindowIcon() { | 716 void ShellWindowViews::UpdateWindowIcon() { |
700 window_->UpdateWindowIcon(); | 717 window_->UpdateWindowIcon(); |
701 } | 718 } |
702 | 719 |
(...skipping 25 matching lines...) Expand all Loading... | |
728 ui::WindowShowState show_state) { | 745 ui::WindowShowState show_state) { |
729 views::WidgetDelegate::SaveWindowPlacement(bounds, show_state); | 746 views::WidgetDelegate::SaveWindowPlacement(bounds, show_state); |
730 shell_window_->SaveWindowPosition(); | 747 shell_window_->SaveWindowPosition(); |
731 } | 748 } |
732 | 749 |
733 // static | 750 // static |
734 NativeShellWindow* NativeShellWindow::Create( | 751 NativeShellWindow* NativeShellWindow::Create( |
735 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { | 752 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { |
736 return new ShellWindowViews(shell_window, params); | 753 return new ShellWindowViews(shell_window, params); |
737 } | 754 } |
OLD | NEW |