OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/panels/panel_browser_frame_view.h" | 5 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" |
6 | 6 |
7 #include "chrome/browser/themes/theme_service.h" | 7 #include "chrome/browser/themes/theme_service.h" |
8 #include "chrome/browser/ui/panels/panel.h" | 8 #include "chrome/browser/ui/panels/panel.h" |
9 #include "chrome/browser/ui/panels/panel_browser_view.h" | 9 #include "chrome/browser/ui/panels/panel_browser_view.h" |
10 #include "chrome/browser/ui/panels/panel_manager.h" | 10 #include "chrome/browser/ui/panels/panel_manager.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 217 |
218 bool PanelBrowserFrameView::AlwaysUseNativeFrame() const { | 218 bool PanelBrowserFrameView::AlwaysUseNativeFrame() const { |
219 return frame_->AlwaysUseNativeFrame(); | 219 return frame_->AlwaysUseNativeFrame(); |
220 } | 220 } |
221 | 221 |
222 int PanelBrowserFrameView::NonClientHitTest(const gfx::Point& point) { | 222 int PanelBrowserFrameView::NonClientHitTest(const gfx::Point& point) { |
223 if (!bounds().Contains(point)) | 223 if (!bounds().Contains(point)) |
224 return HTNOWHERE; | 224 return HTNOWHERE; |
225 | 225 |
226 int frame_component = | 226 int frame_component = |
227 frame_->GetWindow()->client_view()->NonClientHitTest(point); | 227 frame_->client_view()->NonClientHitTest(point); |
228 if (frame_component != HTNOWHERE) | 228 if (frame_component != HTNOWHERE) |
229 return frame_component; | 229 return frame_component; |
230 | 230 |
231 if (close_button_->IsVisible() && | 231 if (close_button_->IsVisible() && |
232 close_button_->GetMirroredBounds().Contains(point)) | 232 close_button_->GetMirroredBounds().Contains(point)) |
233 return HTCLOSE; | 233 return HTCLOSE; |
234 | 234 |
235 int window_component = GetHTComponentForFrame(point, | 235 int window_component = GetHTComponentForFrame(point, |
236 NonClientBorderThickness(), NonClientBorderThickness(), | 236 NonClientBorderThickness(), NonClientBorderThickness(), |
237 0, 0, | 237 0, 0, |
238 frame_->GetWindow()->window_delegate()->CanResize()); | 238 frame_->window_delegate()->CanResize()); |
239 // Fall back to the caption if no other component matches. | 239 // Fall back to the caption if no other component matches. |
240 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; | 240 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; |
241 } | 241 } |
242 | 242 |
243 void PanelBrowserFrameView::GetWindowMask(const gfx::Size& size, | 243 void PanelBrowserFrameView::GetWindowMask(const gfx::Size& size, |
244 gfx::Path* window_mask) { | 244 gfx::Path* window_mask) { |
245 views::GetDefaultWindowMask(size, window_mask); | 245 views::GetDefaultWindowMask(size, window_mask); |
246 } | 246 } |
247 | 247 |
248 void PanelBrowserFrameView::EnableClose(bool enable) { | 248 void PanelBrowserFrameView::EnableClose(bool enable) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 | 333 |
334 void PanelBrowserFrameView::OnMouseReleased(const views::MouseEvent& event) { | 334 void PanelBrowserFrameView::OnMouseReleased(const views::MouseEvent& event) { |
335 if (browser_view_->OnTitleBarMouseReleased(event)) | 335 if (browser_view_->OnTitleBarMouseReleased(event)) |
336 return; | 336 return; |
337 BrowserNonClientFrameView::OnMouseReleased(event); | 337 BrowserNonClientFrameView::OnMouseReleased(event); |
338 } | 338 } |
339 | 339 |
340 void PanelBrowserFrameView::ButtonPressed(views::Button* sender, | 340 void PanelBrowserFrameView::ButtonPressed(views::Button* sender, |
341 const views::Event& event) { | 341 const views::Event& event) { |
342 if (sender == close_button_) | 342 if (sender == close_button_) |
343 frame_->GetWindow()->CloseWindow(); | 343 frame_->Close(); |
344 } | 344 } |
345 | 345 |
346 void PanelBrowserFrameView::RunMenu(View* source, const gfx::Point& pt) { | 346 void PanelBrowserFrameView::RunMenu(View* source, const gfx::Point& pt) { |
347 CreateOrUpdateOptionsMenu(); | 347 CreateOrUpdateOptionsMenu(); |
348 options_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); | 348 options_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); |
349 } | 349 } |
350 | 350 |
351 bool PanelBrowserFrameView::IsCommandIdChecked(int command_id) const { | 351 bool PanelBrowserFrameView::IsCommandIdChecked(int command_id) const { |
352 // Nothing in the menu is checked. | 352 // Nothing in the menu is checked. |
353 return false; | 353 return false; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 | 385 |
386 bool PanelBrowserFrameView::ShouldTabIconViewAnimate() const { | 386 bool PanelBrowserFrameView::ShouldTabIconViewAnimate() const { |
387 // This function is queried during the creation of the window as the | 387 // This function is queried during the creation of the window as the |
388 // TabIconView we host is initialized, so we need to NULL check the selected | 388 // TabIconView we host is initialized, so we need to NULL check the selected |
389 // TabContents because in this condition there is not yet a selected tab. | 389 // TabContents because in this condition there is not yet a selected tab. |
390 TabContents* current_tab = browser_view_->GetSelectedTabContents(); | 390 TabContents* current_tab = browser_view_->GetSelectedTabContents(); |
391 return current_tab ? current_tab->is_loading() : false; | 391 return current_tab ? current_tab->is_loading() : false; |
392 } | 392 } |
393 | 393 |
394 SkBitmap PanelBrowserFrameView::GetFaviconForTabIconView() { | 394 SkBitmap PanelBrowserFrameView::GetFaviconForTabIconView() { |
395 return frame_->GetWindow()->window_delegate()->GetWindowIcon(); | 395 return frame_->window_delegate()->GetWindowIcon(); |
396 } | 396 } |
397 | 397 |
398 int PanelBrowserFrameView::NonClientBorderThickness() const { | 398 int PanelBrowserFrameView::NonClientBorderThickness() const { |
399 return kFrameBorderThickness + kClientEdgeThickness; | 399 return kFrameBorderThickness + kClientEdgeThickness; |
400 } | 400 } |
401 | 401 |
402 int PanelBrowserFrameView::NonClientTopBorderHeight() const { | 402 int PanelBrowserFrameView::NonClientTopBorderHeight() const { |
403 return kFrameBorderThickness + kTitleBarHeight + kClientEdgeThickness; | 403 return kFrameBorderThickness + kTitleBarHeight + kClientEdgeThickness; |
404 } | 404 } |
405 | 405 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 | 507 |
508 // Draw the left edge. | 508 // Draw the left edge. |
509 canvas->TileImageInt( | 509 canvas->TileImageInt( |
510 *(client_edges.left), | 510 *(client_edges.left), |
511 client_view_bounds_.x() - client_edges.left->width(), | 511 client_view_bounds_.x() - client_edges.left->width(), |
512 client_area_top, client_edges.left->width(), client_area_height); | 512 client_area_top, client_edges.left->width(), client_area_height); |
513 } | 513 } |
514 | 514 |
515 void PanelBrowserFrameView::UpdateTitleBar() { | 515 void PanelBrowserFrameView::UpdateTitleBar() { |
516 title_label_->SetText( | 516 title_label_->SetText( |
517 frame_->GetWindow()->window_delegate()->GetWindowTitle()); | 517 frame_->window_delegate()->GetWindowTitle()); |
518 } | 518 } |
519 | 519 |
520 void PanelBrowserFrameView::OnActivationChanged(bool active) { | 520 void PanelBrowserFrameView::OnActivationChanged(bool active) { |
521 SchedulePaint(); | 521 SchedulePaint(); |
522 } | 522 } |
523 | 523 |
524 void PanelBrowserFrameView::CreateOrUpdateOptionsMenu() { | 524 void PanelBrowserFrameView::CreateOrUpdateOptionsMenu() { |
525 bool rebuild_menu = CreateOrUpdateOptionsMenuItems(); | 525 bool rebuild_menu = CreateOrUpdateOptionsMenuItems(); |
526 if (options_menu_.get()) { | 526 if (options_menu_.get()) { |
527 if (rebuild_menu) | 527 if (rebuild_menu) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 COMMAND_CLOSE_ALL, | 573 COMMAND_CLOSE_ALL, |
574 l10n_util::GetStringUTF16(IDS_PANEL_OPTIONS_MENU_CLOSE_ALL)); | 574 l10n_util::GetStringUTF16(IDS_PANEL_OPTIONS_MENU_CLOSE_ALL)); |
575 options_menu_contents_->AddSeparator(); | 575 options_menu_contents_->AddSeparator(); |
576 } | 576 } |
577 | 577 |
578 options_menu_contents_->AddItem( | 578 options_menu_contents_->AddItem( |
579 COMMAND_ABOUT, l10n_util::GetStringUTF16(IDS_PANEL_OPTIONS_MENU_ABOUT)); | 579 COMMAND_ABOUT, l10n_util::GetStringUTF16(IDS_PANEL_OPTIONS_MENU_ABOUT)); |
580 | 580 |
581 return rebuild_menu; | 581 return rebuild_menu; |
582 } | 582 } |
OLD | NEW |