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/tab_contents/tab_contents.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 DCHECK(!window_->frameless()); | 312 DCHECK(!window_->frameless()); |
313 if (sender == close_button_) | 313 if (sender == close_button_) |
314 frame_->Close(); | 314 frame_->Close(); |
315 } | 315 } |
316 | 316 |
317 ShellWindowViews::ShellWindowViews(ShellWindow* shell_window, | 317 ShellWindowViews::ShellWindowViews(ShellWindow* shell_window, |
318 const ShellWindow::CreateParams& win_params) | 318 const ShellWindow::CreateParams& win_params) |
319 : shell_window_(shell_window), | 319 : shell_window_(shell_window), |
320 web_view_(NULL), | 320 web_view_(NULL), |
321 is_fullscreen_(false), | 321 is_fullscreen_(false), |
322 frameless_(win_params.frame == ShellWindow::CreateParams::FRAME_NONE) { | 322 frameless_(win_params.frame == ShellWindow::CreateParams::FRAME_NONE), |
323 transparent_background_(win_params.transparent_background) { | |
324 Observe(shell_window_->web_contents()); | |
323 window_ = new views::Widget; | 325 window_ = new views::Widget; |
324 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 326 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
325 params.delegate = this; | 327 params.delegate = this; |
326 params.remove_standard_frame = true; | 328 params.remove_standard_frame = true; |
sky
2012/09/28 22:29:13
Don't you need to set params.transparent here?
We
reveman
2012/09/28 22:50:38
It works with Ash independent of the platform. I'm
Bernie
2012/10/10 21:05:01
I tried on Linux: setting the transparent backgrou
| |
327 params.use_system_default_icon = true; | 329 params.use_system_default_icon = true; |
328 minimum_size_ = win_params.minimum_size; | 330 minimum_size_ = win_params.minimum_size; |
329 maximum_size_ = win_params.maximum_size; | 331 maximum_size_ = win_params.maximum_size; |
330 window_->Init(params); | 332 window_->Init(params); |
331 gfx::Rect window_bounds = | 333 gfx::Rect window_bounds = |
332 window_->non_client_view()->GetWindowBoundsForClientBounds( | 334 window_->non_client_view()->GetWindowBoundsForClientBounds( |
333 win_params.bounds); | 335 win_params.bounds); |
334 window_->SetBounds(window_bounds); | 336 window_->SetBounds(window_bounds); |
335 // Center window if no position was specified. | 337 // Center window if no position was specified. |
336 if (win_params.bounds.x() < 0 || win_params.bounds.y() < 0) | 338 if (win_params.bounds.x() < 0 || win_params.bounds.y() < 0) |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
598 if (!app_icon.IsEmpty()) | 600 if (!app_icon.IsEmpty()) |
599 return *app_icon.ToImageSkia(); | 601 return *app_icon.ToImageSkia(); |
600 } | 602 } |
601 return gfx::ImageSkia(); | 603 return gfx::ImageSkia(); |
602 } | 604 } |
603 | 605 |
604 bool ShellWindowViews::ShouldShowWindowTitle() const { | 606 bool ShellWindowViews::ShouldShowWindowTitle() const { |
605 return false; | 607 return false; |
606 } | 608 } |
607 | 609 |
610 void ShellWindowViews::RenderViewCreated( | |
611 content::RenderViewHost* render_view_host) { | |
612 if (transparent_background_) { | |
sky
2012/09/28 22:29:13
Does this result in flicker? Might it be possible
Bernie
2012/10/10 21:05:01
The window opens with a white background, then it
reveman
2012/10/11 17:25:58
We'll need to fix this. But I think it's OK to add
| |
613 // Use a background with transparency to trigger transparency in Webkit. | |
614 SkBitmap background; | |
615 background.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); | |
616 background.allocPixels(); | |
617 background.eraseARGB(0x00, 0x00, 0x00, 0x00); | |
618 | |
619 content::RenderWidgetHostView* view = render_view_host->GetView(); | |
620 DCHECK(view); | |
621 view->SetBackground(background); | |
622 } | |
623 } | |
624 | |
608 void ShellWindowViews::Layout() { | 625 void ShellWindowViews::Layout() { |
609 DCHECK(web_view_); | 626 DCHECK(web_view_); |
610 web_view_->SetBounds(0, 0, width(), height()); | 627 web_view_->SetBounds(0, 0, width(), height()); |
611 OnViewWasResized(); | 628 OnViewWasResized(); |
612 } | 629 } |
613 | 630 |
614 void ShellWindowViews::UpdateWindowIcon() { | 631 void ShellWindowViews::UpdateWindowIcon() { |
615 window_->UpdateWindowIcon(); | 632 window_->UpdateWindowIcon(); |
616 } | 633 } |
617 | 634 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
684 ui::WindowShowState show_state) { | 701 ui::WindowShowState show_state) { |
685 views::WidgetDelegate::SaveWindowPlacement(bounds, show_state); | 702 views::WidgetDelegate::SaveWindowPlacement(bounds, show_state); |
686 shell_window_->SaveWindowPosition(); | 703 shell_window_->SaveWindowPosition(); |
687 } | 704 } |
688 | 705 |
689 // static | 706 // static |
690 NativeShellWindow* NativeShellWindow::Create( | 707 NativeShellWindow* NativeShellWindow::Create( |
691 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { | 708 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { |
692 return new ShellWindowViews(shell_window, params); | 709 return new ShellWindowViews(shell_window, params); |
693 } | 710 } |
OLD | NEW |