Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: chrome/browser/ui/views/extensions/native_app_window_views.cc

Issue 12212207: Support panel titles and Icons for v1 apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge fix, address feedback Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/native_app_window_views.h" 5 #include "chrome/browser/ui/views/extensions/native_app_window_views.h"
6 6
7 #include "chrome/browser/extensions/extension_host.h" 7 #include "chrome/browser/extensions/extension_host.h"
8 #include "chrome/browser/favicon/favicon_tab_helper.h" 8 #include "chrome/browser/favicon/favicon_tab_helper.h"
9 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h" 9 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h"
10 #include "chrome/browser/ui/views/extensions/shell_window_frame_view.h" 10 #include "chrome/browser/ui/views/extensions/shell_window_frame_view.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 web_view_(NULL), 49 web_view_(NULL),
50 window_(NULL), 50 window_(NULL),
51 is_fullscreen_(false), 51 is_fullscreen_(false),
52 frameless_(create_params.frame == ShellWindow::FRAME_NONE), 52 frameless_(create_params.frame == ShellWindow::FRAME_NONE),
53 transparent_background_(create_params.transparent_background) { 53 transparent_background_(create_params.transparent_background) {
54 Observe(shell_window_->web_contents()); 54 Observe(shell_window_->web_contents());
55 minimum_size_ = create_params.minimum_size; 55 minimum_size_ = create_params.minimum_size;
56 maximum_size_ = create_params.maximum_size; 56 maximum_size_ = create_params.maximum_size;
57 57
58 window_ = new views::Widget; 58 window_ = new views::Widget;
59 if (create_params.window_type == ShellWindow::WINDOW_TYPE_PANEL) 59 if (create_params.window_type == ShellWindow::WINDOW_TYPE_PANEL ||
60 create_params.window_type == ShellWindow::WINDOW_TYPE_V1_PANEL) {
60 InitializePanelWindow(create_params); 61 InitializePanelWindow(create_params);
61 else 62 } else {
62 InitializeDefaultWindow(create_params); 63 InitializeDefaultWindow(create_params);
63 64 }
64 extension_keybinding_registry_.reset( 65 extension_keybinding_registry_.reset(
65 new ExtensionKeybindingRegistryViews( 66 new ExtensionKeybindingRegistryViews(
66 profile(), 67 profile(),
67 window_->GetFocusManager(), 68 window_->GetFocusManager(),
68 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, 69 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY,
69 shell_window_)); 70 shell_window_));
70 71
71 OnViewWasResized(); 72 OnViewWasResized();
72 window_->AddObserver(this); 73 window_->AddObserver(this);
73 } 74 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 228
228 void NativeAppWindowViews::SetBounds(const gfx::Rect& bounds) { 229 void NativeAppWindowViews::SetBounds(const gfx::Rect& bounds) {
229 GetWidget()->SetBounds(bounds); 230 GetWidget()->SetBounds(bounds);
230 } 231 }
231 232
232 void NativeAppWindowViews::FlashFrame(bool flash) { 233 void NativeAppWindowViews::FlashFrame(bool flash) {
233 window_->FlashFrame(flash); 234 window_->FlashFrame(flash);
234 } 235 }
235 236
236 bool NativeAppWindowViews::IsAlwaysOnTop() const { 237 bool NativeAppWindowViews::IsAlwaysOnTop() const {
237 return shell_window_->window_type() == ShellWindow::WINDOW_TYPE_PANEL; 238 return shell_window_->window_type_is_panel();
238 } 239 }
239 240
240 gfx::Insets NativeAppWindowViews::GetFrameInsets() const { 241 gfx::Insets NativeAppWindowViews::GetFrameInsets() const {
241 if (frameless()) 242 if (frameless())
242 return gfx::Insets(); 243 return gfx::Insets();
243 244
244 // The pretend client_bounds passed in need to be large enough to ensure that 245 // The pretend client_bounds passed in need to be large enough to ensure that
245 // GetWindowBoundsForClientBounds() doesn't decide that it needs more than 246 // GetWindowBoundsForClientBounds() doesn't decide that it needs more than
246 // the specified amount of space to fit the window controls in, and return a 247 // the specified amount of space to fit the window controls in, and return a
247 // number larger than the real frame insets. Most window controls are smaller 248 // number larger than the real frame insets. Most window controls are smaller
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 324
324 bool NativeAppWindowViews::CanMaximize() const { 325 bool NativeAppWindowViews::CanMaximize() const {
325 return maximum_size_.IsEmpty(); 326 return maximum_size_.IsEmpty();
326 } 327 }
327 328
328 string16 NativeAppWindowViews::GetWindowTitle() const { 329 string16 NativeAppWindowViews::GetWindowTitle() const {
329 return shell_window_->GetTitle(); 330 return shell_window_->GetTitle();
330 } 331 }
331 332
332 bool NativeAppWindowViews::ShouldShowWindowTitle() const { 333 bool NativeAppWindowViews::ShouldShowWindowTitle() const {
333 return false; 334 return shell_window_->window_type() == ShellWindow::WINDOW_TYPE_V1_PANEL;
334 } 335 }
335 336
336 gfx::ImageSkia NativeAppWindowViews::GetWindowAppIcon() { 337 gfx::ImageSkia NativeAppWindowViews::GetWindowAppIcon() {
337 gfx::Image app_icon = shell_window_->app_icon(); 338 gfx::Image app_icon = shell_window_->app_icon();
338 if (app_icon.IsEmpty()) 339 if (app_icon.IsEmpty())
339 return GetWindowIcon(); 340 return GetWindowIcon();
340 else 341 else
341 return *app_icon.ToImageSkia(); 342 return *app_icon.ToImageSkia();
342 } 343 }
343 344
344 gfx::ImageSkia NativeAppWindowViews::GetWindowIcon() { 345 gfx::ImageSkia NativeAppWindowViews::GetWindowIcon() {
345 content::WebContents* web_contents = shell_window_->web_contents(); 346 content::WebContents* web_contents = shell_window_->web_contents();
346 if (web_contents) { 347 if (web_contents) {
347 FaviconTabHelper* favicon_tab_helper = 348 FaviconTabHelper* favicon_tab_helper =
348 FaviconTabHelper::FromWebContents(web_contents); 349 FaviconTabHelper::FromWebContents(web_contents);
349 gfx::Image app_icon = favicon_tab_helper->GetFavicon(); 350 gfx::Image app_icon = favicon_tab_helper->GetFavicon();
350 if (!app_icon.IsEmpty()) 351 if (!app_icon.IsEmpty())
351 return *app_icon.ToImageSkia(); 352 return *app_icon.ToImageSkia();
352 } 353 }
353 return gfx::ImageSkia(); 354 return gfx::ImageSkia();
354 } 355 }
355 356
357 bool NativeAppWindowViews::ShouldShowWindowIcon() const {
358 return shell_window_->window_type() == ShellWindow::WINDOW_TYPE_V1_PANEL;
359 }
360
356 void NativeAppWindowViews::SaveWindowPlacement(const gfx::Rect& bounds, 361 void NativeAppWindowViews::SaveWindowPlacement(const gfx::Rect& bounds,
357 ui::WindowShowState show_state) { 362 ui::WindowShowState show_state) {
358 views::WidgetDelegate::SaveWindowPlacement(bounds, show_state); 363 views::WidgetDelegate::SaveWindowPlacement(bounds, show_state);
359 shell_window_->OnNativeWindowChanged(); 364 shell_window_->OnNativeWindowChanged();
360 } 365 }
361 366
362 void NativeAppWindowViews::DeleteDelegate() { 367 void NativeAppWindowViews::DeleteDelegate() {
363 window_->RemoveObserver(this); 368 window_->RemoveObserver(this);
364 shell_window_->OnNativeClose(); 369 shell_window_->OnNativeClose();
365 } 370 }
366 371
367 views::Widget* NativeAppWindowViews::GetWidget() { 372 views::Widget* NativeAppWindowViews::GetWidget() {
368 return window_; 373 return window_;
369 } 374 }
370 375
371 const views::Widget* NativeAppWindowViews::GetWidget() const { 376 const views::Widget* NativeAppWindowViews::GetWidget() const {
372 return window_; 377 return window_;
373 } 378 }
374 379
375 views::NonClientFrameView* NativeAppWindowViews::CreateNonClientFrameView( 380 views::NonClientFrameView* NativeAppWindowViews::CreateNonClientFrameView(
376 views::Widget* widget) { 381 views::Widget* widget) {
377 #if defined(USE_ASH) 382 #if defined(USE_ASH)
378 if (chrome::IsNativeViewInAsh(widget->GetNativeView())) { 383 if (chrome::IsNativeViewInAsh(widget->GetNativeView())) {
379 if (shell_window_->window_type() == ShellWindow::WINDOW_TYPE_PANEL) { 384 if (shell_window_->window_type_is_panel()) {
380 ash::PanelFrameView::FrameType frame_type = frameless_ ? 385 ash::PanelFrameView::FrameType frame_type = frameless_ ?
381 ash::PanelFrameView::FRAME_NONE : ash::PanelFrameView::FRAME_ASH; 386 ash::PanelFrameView::FRAME_NONE : ash::PanelFrameView::FRAME_ASH;
382 return new ash::PanelFrameView(widget, frame_type); 387 return new ash::PanelFrameView(widget, frame_type);
383 } 388 }
384 if (!frameless_) { 389 if (!frameless_) {
385 ash::CustomFrameViewAsh* frame = new ash::CustomFrameViewAsh(); 390 ash::CustomFrameViewAsh* frame = new ash::CustomFrameViewAsh();
386 frame->Init(widget); 391 frame->Init(widget);
387 return frame; 392 return frame;
388 } 393 }
389 } 394 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 } 474 }
470 475
471 void NativeAppWindowViews::OnFocus() { 476 void NativeAppWindowViews::OnFocus() {
472 web_view_->RequestFocus(); 477 web_view_->RequestFocus();
473 } 478 }
474 479
475 // NativeAppWindow implementation. 480 // NativeAppWindow implementation.
476 481
477 void NativeAppWindowViews::SetFullscreen(bool fullscreen) { 482 void NativeAppWindowViews::SetFullscreen(bool fullscreen) {
478 // Fullscreen not supported by panels. 483 // Fullscreen not supported by panels.
479 if (shell_window_->window_type() == ShellWindow::WINDOW_TYPE_PANEL) 484 if (shell_window_->window_type_is_panel())
480 return; 485 return;
481 is_fullscreen_ = fullscreen; 486 is_fullscreen_ = fullscreen;
482 window_->SetFullscreen(fullscreen); 487 window_->SetFullscreen(fullscreen);
483 // TODO(jeremya) we need to call RenderViewHost::ExitFullscreen() if we 488 // TODO(jeremya) we need to call RenderViewHost::ExitFullscreen() if we
484 // ever drop the window out of fullscreen in response to something that 489 // ever drop the window out of fullscreen in response to something that
485 // wasn't the app calling webkitCancelFullScreen(). 490 // wasn't the app calling webkitCancelFullScreen().
486 } 491 }
487 492
488 bool NativeAppWindowViews::IsFullscreenOrPending() const { 493 bool NativeAppWindowViews::IsFullscreenOrPending() const {
489 return is_fullscreen_; 494 return is_fullscreen_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 } 527 }
523 528
524 //------------------------------------------------------------------------------ 529 //------------------------------------------------------------------------------
525 // NativeAppWindow::Create 530 // NativeAppWindow::Create
526 531
527 // static 532 // static
528 NativeAppWindow* NativeAppWindow::Create( 533 NativeAppWindow* NativeAppWindow::Create(
529 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { 534 ShellWindow* shell_window, const ShellWindow::CreateParams& params) {
530 return new NativeAppWindowViews(shell_window, params); 535 return new NativeAppWindowViews(shell_window, params);
531 } 536 }
OLDNEW
« ash/wm/panel_frame_view.h ('K') | « chrome/browser/ui/views/extensions/native_app_window_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698