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

Side by Side Diff: chrome/browser/ui/panels/panel_browser_frame_view.cc

Issue 6975062: Update Panel UI looks on Windows. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 6 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) 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/extensions/extension_prefs.h"
8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/profiles/profile.h"
7 #include "chrome/browser/themes/theme_service.h" 10 #include "chrome/browser/themes/theme_service.h"
8 #include "chrome/browser/ui/panels/about_panel_bubble.h"
9 #include "chrome/browser/ui/panels/panel.h" 11 #include "chrome/browser/ui/panels/panel.h"
10 #include "chrome/browser/ui/panels/panel_browser_view.h" 12 #include "chrome/browser/ui/panels/panel_browser_view.h"
11 #include "chrome/browser/ui/panels/panel_manager.h" 13 #include "chrome/browser/ui/panels/panel_manager.h"
14 #include "chrome/browser/web_applications/web_app.h"
15 #include "chrome/common/extensions/extension.h"
16 #include "chrome/common/url_constants.h"
12 #include "content/browser/tab_contents/tab_contents.h" 17 #include "content/browser/tab_contents/tab_contents.h"
13 #include "grit/app_resources.h" 18 #include "grit/app_resources.h"
14 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
15 #include "grit/theme_resources.h" 20 #include "grit/theme_resources.h"
16 #include "grit/theme_resources_standard.h" 21 #include "grit/theme_resources_standard.h"
17 #include "third_party/skia/include/effects/SkGradientShader.h" 22 #include "third_party/skia/include/effects/SkGradientShader.h"
18 #include "ui/base/accessibility/accessible_view_state.h" 23 #include "ui/base/accessibility/accessible_view_state.h"
19 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/gfx/canvas_skia.h" 26 #include "ui/gfx/canvas_skia.h"
22 #include "views/controls/button/image_button.h" 27 #include "views/controls/button/image_button.h"
28 #include "views/controls/button/menu_button.h"
23 #include "views/controls/label.h" 29 #include "views/controls/label.h"
30 #include "views/controls/menu/menu_2.h"
24 #include "views/painter.h" 31 #include "views/painter.h"
25 #include "views/screen.h" 32 #include "views/screen.h"
26 #include "views/window/window.h" 33 #include "views/window/window.h"
27 #include "views/window/window_shape.h" 34 #include "views/window/window_shape.h"
28 35
29 #if !defined(OS_WIN) 36 #if !defined(OS_WIN)
30 #include "views/window/hit_test.h" 37 #include "views/window/hit_test.h"
31 #endif 38 #endif
32 39
33 namespace { 40 namespace {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 top = rb.GetBitmapNamed(top_id); 88 top = rb.GetBitmapNamed(top_id);
82 top_right = rb.GetBitmapNamed(top_right_id); 89 top_right = rb.GetBitmapNamed(top_right_id);
83 right = rb.GetBitmapNamed(right_id); 90 right = rb.GetBitmapNamed(right_id);
84 bottom_right = rb.GetBitmapNamed(bottom_right_id); 91 bottom_right = rb.GetBitmapNamed(bottom_right_id);
85 bottom = rb.GetBitmapNamed(bottom_id); 92 bottom = rb.GetBitmapNamed(bottom_id);
86 bottom_left = rb.GetBitmapNamed(bottom_left_id); 93 bottom_left = rb.GetBitmapNamed(bottom_left_id);
87 left = rb.GetBitmapNamed(left_id); 94 left = rb.GetBitmapNamed(left_id);
88 } 95 }
89 }; 96 };
90 97
91 ButtonResources info_button_resources; 98 ButtonResources wrench_button_resources;
92 ButtonResources close_button_resources; 99 ButtonResources close_button_resources;
93 EdgeResources frame_edges; 100 EdgeResources frame_edges;
94 EdgeResources client_edges; 101 EdgeResources client_edges;
95 gfx::Font* active_font = NULL; 102 gfx::Font* active_font = NULL;
96 gfx::Font* inactive_font = NULL; 103 gfx::Font* inactive_font = NULL;
97 104
98 void LoadImageResources() { 105 void LoadImageResources() {
99 // TODO(jianli): Use the right icon for the info button. 106 wrench_button_resources.SetResources(
100 info_button_resources.SetResources(
101 IDR_BALLOON_WRENCH, 0, IDR_BALLOON_WRENCH_H, IDR_BALLOON_WRENCH_P); 107 IDR_BALLOON_WRENCH, 0, IDR_BALLOON_WRENCH_H, IDR_BALLOON_WRENCH_P);
102 108
103 close_button_resources.SetResources( 109 close_button_resources.SetResources(
104 IDR_TAB_CLOSE, IDR_TAB_CLOSE_MASK, IDR_TAB_CLOSE_H, IDR_TAB_CLOSE_P); 110 IDR_TAB_CLOSE, IDR_TAB_CLOSE_MASK, IDR_TAB_CLOSE_H, IDR_TAB_CLOSE_P);
105 111
106 frame_edges.SetResources( 112 frame_edges.SetResources(
107 IDR_WINDOW_TOP_LEFT_CORNER, IDR_WINDOW_TOP_CENTER, 113 IDR_WINDOW_TOP_LEFT_CORNER, IDR_WINDOW_TOP_CENTER,
108 IDR_WINDOW_TOP_RIGHT_CORNER, IDR_WINDOW_RIGHT_SIDE, 114 IDR_WINDOW_TOP_RIGHT_CORNER, IDR_WINDOW_RIGHT_SIDE,
109 IDR_WINDOW_BOTTOM_RIGHT_CORNER, IDR_WINDOW_BOTTOM_CENTER, 115 IDR_WINDOW_BOTTOM_RIGHT_CORNER, IDR_WINDOW_BOTTOM_CENTER,
110 IDR_WINDOW_BOTTOM_LEFT_CORNER, IDR_WINDOW_LEFT_SIDE); 116 IDR_WINDOW_BOTTOM_LEFT_CORNER, IDR_WINDOW_LEFT_SIDE);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } 190 }
185 191
186 // PanelBrowserFrameView ------------------------------------------------------- 192 // PanelBrowserFrameView -------------------------------------------------------
187 193
188 PanelBrowserFrameView::PanelBrowserFrameView(BrowserFrame* frame, 194 PanelBrowserFrameView::PanelBrowserFrameView(BrowserFrame* frame,
189 PanelBrowserView* browser_view) 195 PanelBrowserView* browser_view)
190 : BrowserNonClientFrameView(), 196 : BrowserNonClientFrameView(),
191 frame_(frame), 197 frame_(frame),
192 browser_view_(browser_view), 198 browser_view_(browser_view),
193 paint_state_(NOT_PAINTED), 199 paint_state_(NOT_PAINTED),
194 info_button_(NULL), 200 wrench_button_(NULL),
195 close_button_(NULL), 201 close_button_(NULL),
196 title_icon_(NULL), 202 title_icon_(NULL),
197 title_label_(NULL) { 203 title_label_(NULL) {
198 EnsureResourcesInitialized(); 204 EnsureResourcesInitialized();
199 frame_->set_frame_type(views::Window::FRAME_TYPE_FORCE_CUSTOM); 205 frame_->set_frame_type(views::Window::FRAME_TYPE_FORCE_CUSTOM);
200 206
201 info_button_ = new views::ImageButton(this); 207 wrench_button_ = new views::MenuButton(NULL, std::wstring(), this, false);
202 info_button_->SetImage(views::CustomButton::BS_NORMAL, 208 wrench_button_->SetIcon(*(wrench_button_resources.normal_image));
203 info_button_resources.normal_image); 209 wrench_button_->SetHoverIcon(*(wrench_button_resources.hover_image));
204 info_button_->SetImage(views::CustomButton::BS_HOT, 210 wrench_button_->SetPushedIcon(*(wrench_button_resources.pushed_image));
205 info_button_resources.hover_image); 211 wrench_button_->set_alignment(views::TextButton::ALIGN_CENTER);
206 info_button_->SetImage(views::CustomButton::BS_PUSHED, 212 wrench_button_->set_border(NULL);
207 info_button_resources.pushed_image); 213 wrench_button_->SetTooltipText(
208 info_button_->SetTooltipText( 214 UTF16ToWide(l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_SETTINGS)));
209 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_ABOUT_PANEL))); 215 wrench_button_->SetAccessibleName(
210 info_button_->SetAccessibleName( 216 l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_SETTINGS));
211 l10n_util::GetStringUTF16(IDS_ACCNAME_ABOUT_PANEL)); 217 wrench_button_->SetVisible(false);
212 info_button_->SetVisible(false); 218 AddChildView(wrench_button_);
213 AddChildView(info_button_);
214 219
215 close_button_ = new views::ImageButton(this); 220 close_button_ = new views::ImageButton(this);
216 close_button_->SetImage(views::CustomButton::BS_NORMAL, 221 close_button_->SetImage(views::CustomButton::BS_NORMAL,
217 close_button_resources.normal_image); 222 close_button_resources.normal_image);
218 close_button_->SetImage(views::CustomButton::BS_HOT, 223 close_button_->SetImage(views::CustomButton::BS_HOT,
219 close_button_resources.hover_image); 224 close_button_resources.hover_image);
220 close_button_->SetImage(views::CustomButton::BS_PUSHED, 225 close_button_->SetImage(views::CustomButton::BS_PUSHED,
221 close_button_resources.pushed_image); 226 close_button_resources.pushed_image);
222 close_button_->SetTooltipText( 227 close_button_->SetTooltipText(
223 UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_CLOSE_TAB))); 228 UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_CLOSE_TAB)));
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 PAINT_AS_ACTIVE : PAINT_AS_INACTIVE); 322 PAINT_AS_ACTIVE : PAINT_AS_INACTIVE);
318 PaintFrameBorder(canvas); 323 PaintFrameBorder(canvas);
319 PaintClientEdge(canvas); 324 PaintClientEdge(canvas);
320 } 325 }
321 326
322 void PanelBrowserFrameView::OnThemeChanged() { 327 void PanelBrowserFrameView::OnThemeChanged() {
323 LoadImageResources(); 328 LoadImageResources();
324 } 329 }
325 330
326 void PanelBrowserFrameView::Layout() { 331 void PanelBrowserFrameView::Layout() {
327 // Now that we know we have a parent, we can safely set our theme colors.
328 SkColor title_color =
329 GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT);
330 title_label_->SetColor(title_color);
331 close_button_->SetBackground(title_color,
332 close_button_resources.normal_image,
333 close_button_resources.mask_image);
334
335 // Layout the close button. 332 // Layout the close button.
336 gfx::Size close_button_size = close_button_->GetPreferredSize(); 333 gfx::Size close_button_size = close_button_->GetPreferredSize();
337 close_button_->SetBounds( 334 close_button_->SetBounds(
338 width() - kFrameBorderThickness - kButtonSpacing - 335 width() - kFrameBorderThickness - kButtonSpacing -
339 close_button_size.width(), 336 close_button_size.width(),
340 (NonClientTopBorderHeight() - close_button_size.height()) / 2, 337 (NonClientTopBorderHeight() - close_button_size.height()) / 2,
341 close_button_size.width(), 338 close_button_size.width(),
342 close_button_size.height()); 339 close_button_size.height());
343 340
344 // Layout the info button. 341 // Layout the wrench button.
345 gfx::Size info_button_size = info_button_->GetPreferredSize(); 342 gfx::Size wrench_button_size = wrench_button_->GetPreferredSize();
346 info_button_->SetBounds( 343 wrench_button_->SetBounds(
347 close_button_->x() - kButtonSpacing - info_button_size.width(), 344 close_button_->x() - kButtonSpacing - wrench_button_size.width(),
348 (NonClientTopBorderHeight() - info_button_size.height()) / 2, 345 (NonClientTopBorderHeight() - wrench_button_size.height()) / 2,
349 info_button_size.width(), 346 wrench_button_size.width(),
350 info_button_size.height()); 347 wrench_button_size.height());
351 348
352 // Layout the icon. 349 // Layout the icon.
353 int icon_y = (NonClientTopBorderHeight() - kIconSize) / 2; 350 int icon_y = (NonClientTopBorderHeight() - kIconSize) / 2;
354 title_icon_->SetBounds( 351 title_icon_->SetBounds(
355 kFrameBorderThickness + kIconSpacing, 352 kFrameBorderThickness + kIconSpacing,
356 icon_y, 353 icon_y,
357 kIconSize, 354 kIconSize,
358 kIconSize); 355 kIconSize);
359 356
360 // Layout the title. 357 // Layout the title.
361 int title_x = title_icon_->bounds().right() + kIconSpacing; 358 int title_x = title_icon_->bounds().right() + kIconSpacing;
362 int title_height = BrowserFrame::GetTitleFont().GetHeight(); 359 int title_height = BrowserFrame::GetTitleFont().GetHeight();
363 title_label_->SetBounds( 360 title_label_->SetBounds(
364 title_x, 361 title_x,
365 icon_y + ((kIconSize - title_height - 1) / 2), 362 icon_y + ((kIconSize - title_height - 1) / 2),
366 std::max(0, info_button_->x() - kButtonSpacing - title_x), 363 std::max(0, wrench_button_->x() - kButtonSpacing - title_x),
367 title_height); 364 title_height);
368 365
369 // Calculate the client area bounds. 366 // Calculate the client area bounds.
370 int top_height = NonClientTopBorderHeight(); 367 int top_height = NonClientTopBorderHeight();
371 int border_thickness = NonClientBorderThickness(); 368 int border_thickness = NonClientBorderThickness();
372 client_view_bounds_.SetRect( 369 client_view_bounds_.SetRect(
373 border_thickness, 370 border_thickness,
374 top_height, 371 top_height,
375 std::max(0, width() - (2 * border_thickness)), 372 std::max(0, width() - (2 * border_thickness)),
376 std::max(0, height() - top_height - border_thickness)); 373 std::max(0, height() - top_height - border_thickness));
(...skipping 24 matching lines...) Expand all
401 void PanelBrowserFrameView::OnMouseCaptureLost() { 398 void PanelBrowserFrameView::OnMouseCaptureLost() {
402 if (browser_view_->OnTitleBarMouseCaptureLost()) 399 if (browser_view_->OnTitleBarMouseCaptureLost())
403 return; 400 return;
404 BrowserNonClientFrameView::OnMouseCaptureLost(); 401 BrowserNonClientFrameView::OnMouseCaptureLost();
405 } 402 }
406 403
407 void PanelBrowserFrameView::ButtonPressed(views::Button* sender, 404 void PanelBrowserFrameView::ButtonPressed(views::Button* sender,
408 const views::Event& event) { 405 const views::Event& event) {
409 if (sender == close_button_) 406 if (sender == close_button_)
410 frame_->Close(); 407 frame_->Close();
411 else if (sender == info_button_) { 408 }
412 gfx::Point origin(info_button_->bounds().origin()); 409
413 views::View::ConvertPointToScreen(this, &origin); 410 void PanelBrowserFrameView::RunMenu(View* source, const gfx::Point& pt) {
414 AboutPanelBubble::Show( 411 EnsureCreateWrenchMenu();
415 GetWidget(), 412 wrench_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT);
416 gfx::Rect(origin, info_button_->bounds().size()), 413 }
417 BubbleBorder::BOTTOM_RIGHT, 414
418 GetFaviconForTabIconView(), 415 bool PanelBrowserFrameView::IsCommandIdChecked(int command_id) const {
419 browser_view_->browser()); 416 // Nothing in the menu is checked.
417 return false;
418 }
419
420 bool PanelBrowserFrameView::IsCommandIdEnabled(int command_id) const {
421 const Extension* extension = GetExtension();
422 if (!extension)
423 return false;
424
425 if (command_id == COMMAND_NAME) {
426 // The NAME links to the Homepage URL. If the extension doesn't have a
427 // homepage, we just disable this menu item.
428 return extension->GetHomepageURL().is_valid();
429 } else if (command_id == COMMAND_CONFIGURE) {
430 return extension->options_url().spec().length() > 0;
431 } else if (command_id == COMMAND_DISABLE || command_id == COMMAND_UNINSTALL) {
432 // Some extension types can not be disabled or uninstalled.
433 return Extension::UserMayDisable(extension->location());
434 }
435 return true;
436 }
437
438 bool PanelBrowserFrameView::GetAcceleratorForCommandId(
439 int command_id, ui::Accelerator* accelerator) {
440 return false;
441 }
442
443 void PanelBrowserFrameView::ExecuteCommand(int command_id) {
444 const Extension* extension = GetExtension();
445 if (!extension)
446 return;
447
448 Browser* browser = browser_view_->browser();
449 switch (command_id) {
450 case COMMAND_NAME:
451 browser->OpenURL(extension->GetHomepageURL(),
452 GURL(),
453 NEW_FOREGROUND_TAB,
454 PageTransition::LINK);
455 break;
456 case COMMAND_CONFIGURE:
457 DCHECK(!extension->options_url().is_empty());
458 browser->GetProfile()->GetExtensionProcessManager()->OpenOptionsPage(
459 extension, browser);
460 break;
461 case COMMAND_DISABLE:
Dmitry Titov 2011/06/01 20:06:20 Should we also Close the Panel here? Same for Unin
jianli 2011/06/01 20:39:50 It is not needed for both Close and Uninstall. Sin
462 browser->GetProfile()->GetExtensionService()->DisableExtension(
463 extension->id());
464 break;
465 case COMMAND_UNINSTALL:
466 extension_uninstall_dialog_.reset(new ExtensionUninstallDialog(
Dmitry Titov 2011/06/01 20:06:20 Do we need to ensure the panel is not closed (poss
jianli 2011/06/01 20:39:50 The panel can be closed since the uninstall dialog
jianli 2011/06/01 23:23:38 Added a TODO item as discussed.
467 browser->GetProfile()));
468 extension_uninstall_dialog_->ConfirmUninstall(this, extension);
469 break;
470 case COMMAND_MANAGE:
471 browser->OpenURL(GURL(chrome::kChromeUIExtensionsURL),
472 GURL(),
473 SINGLETON_TAB,
474 PageTransition::LINK);
475 break;
476 default:
477 NOTREACHED();
478 break;
420 } 479 }
421 } 480 }
422 481
423 bool PanelBrowserFrameView::ShouldTabIconViewAnimate() const { 482 bool PanelBrowserFrameView::ShouldTabIconViewAnimate() const {
424 // This function is queried during the creation of the window as the 483 // This function is queried during the creation of the window as the
425 // TabIconView we host is initialized, so we need to NULL check the selected 484 // TabIconView we host is initialized, so we need to NULL check the selected
426 // TabContents because in this condition there is not yet a selected tab. 485 // TabContents because in this condition there is not yet a selected tab.
427 TabContents* current_tab = browser_view_->GetSelectedTabContents(); 486 TabContents* current_tab = browser_view_->GetSelectedTabContents();
428 return current_tab ? current_tab->is_loading() : false; 487 return current_tab ? current_tab->is_loading() : false;
429 } 488 }
430 489
431 SkBitmap PanelBrowserFrameView::GetFaviconForTabIconView() { 490 SkBitmap PanelBrowserFrameView::GetFaviconForTabIconView() {
432 return frame_->window_delegate()->GetWindowIcon(); 491 return frame_->window_delegate()->GetWindowIcon();
433 } 492 }
434 493
494 void PanelBrowserFrameView::ExtensionDialogAccepted() {
495 const Extension* extension = GetExtension();
496 if (extension) {
497 browser_view_->browser()->GetProfile()->GetExtensionService()->
498 UninstallExtension(extension->id(), false, NULL);
499 }
500 }
501
502 void PanelBrowserFrameView::ExtensionDialogCanceled() {
503 }
504
435 int PanelBrowserFrameView::NonClientBorderThickness() const { 505 int PanelBrowserFrameView::NonClientBorderThickness() const {
436 return kFrameBorderThickness + kClientEdgeThickness; 506 return kFrameBorderThickness + kClientEdgeThickness;
437 } 507 }
438 508
439 int PanelBrowserFrameView::NonClientTopBorderHeight() const { 509 int PanelBrowserFrameView::NonClientTopBorderHeight() const {
440 return kFrameBorderThickness + kTitleBarHeight + kClientEdgeThickness; 510 return kFrameBorderThickness + kTitleBarHeight + kClientEdgeThickness;
441 } 511 }
442 512
443 void PanelBrowserFrameView::UpdateControlStyles(PaintState paint_state) { 513 void PanelBrowserFrameView::UpdateControlStyles(PaintState paint_state) {
444 DCHECK(paint_state != NOT_PAINTED); 514 DCHECK(paint_state != NOT_PAINTED);
445 515
446 if (paint_state == paint_state_) 516 if (paint_state == paint_state_)
447 return; 517 return;
448 paint_state_ = paint_state; 518 paint_state_ = paint_state;
449 519
450 // For now, the only indication is whether the font is bold or not. 520 SkColor title_color = GetThemeProvider()->
521 GetColor(paint_state == PAINT_AS_ACTIVE ?
522 ThemeService::COLOR_TAB_TEXT :
523 ThemeService::COLOR_BACKGROUND_TAB_TEXT);
524 title_label_->SetColor(title_color);
451 title_label_->SetFont( 525 title_label_->SetFont(
452 paint_state == PAINT_AS_ACTIVE ? *active_font : *inactive_font); 526 paint_state == PAINT_AS_ACTIVE ? *active_font : *inactive_font);
527
528 close_button_->SetBackground(title_color,
529 close_button_resources.normal_image,
530 close_button_resources.mask_image);
453 } 531 }
454 532
455 void PanelBrowserFrameView::PaintFrameBorder(gfx::Canvas* canvas) { 533 void PanelBrowserFrameView::PaintFrameBorder(gfx::Canvas* canvas) {
456 SkBitmap* theme_frame = GetThemeProvider()->GetBitmapNamed(IDR_THEME_TOOLBAR); 534 SkBitmap* theme_frame = GetThemeProvider()->GetBitmapNamed(
535 (paint_state_ == PAINT_AS_ACTIVE) ? IDR_THEME_TOOLBAR
536 : IDR_THEME_TAB_BACKGROUND);
457 537
458 // Draw the theme frame. 538 // Draw the theme frame.
459 canvas->TileImageInt(*theme_frame, 0, 0, width(), height()); 539 canvas->TileImageInt(*theme_frame, 0, 0, width(), height());
460 540
461 // Draw the top border. 541 // Draw the top border.
462 canvas->DrawBitmapInt(*(frame_edges.top_left), 0, 0); 542 canvas->DrawBitmapInt(*(frame_edges.top_left), 0, 0);
463 canvas->TileImageInt( 543 canvas->TileImageInt(
464 *(frame_edges.top), frame_edges.top_left->width(), 0, 544 *(frame_edges.top), frame_edges.top_left->width(), 0,
465 width() - frame_edges.top_right->width(), frame_edges.top->height()); 545 width() - frame_edges.top_right->width(), frame_edges.top->height());
466 canvas->DrawBitmapInt( 546 canvas->DrawBitmapInt(
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 client_view_bounds_.x() - client_edges.left->width(), 618 client_view_bounds_.x() - client_edges.left->width(),
539 client_area_top, client_edges.left->width(), client_area_height); 619 client_area_top, client_edges.left->width(), client_area_height);
540 } 620 }
541 621
542 void PanelBrowserFrameView::UpdateTitleBar() { 622 void PanelBrowserFrameView::UpdateTitleBar() {
543 title_label_->SetText( 623 title_label_->SetText(
544 frame_->window_delegate()->GetWindowTitle()); 624 frame_->window_delegate()->GetWindowTitle());
545 } 625 }
546 626
547 void PanelBrowserFrameView::OnActivationChanged(bool active) { 627 void PanelBrowserFrameView::OnActivationChanged(bool active) {
548 UpdateInfoButtonVisibility(active, mouse_watcher_->IsCursorInViewBounds()); 628 UpdateWrenchButtonVisibility(active, mouse_watcher_->IsCursorInViewBounds());
549 SchedulePaint(); 629 SchedulePaint();
550 } 630 }
551 631
552 void PanelBrowserFrameView::OnMouseEnterOrLeaveWindow(bool mouse_entered) { 632 void PanelBrowserFrameView::OnMouseEnterOrLeaveWindow(bool mouse_entered) {
553 UpdateInfoButtonVisibility(browser_view_->panel()->IsActive(), 633 UpdateWrenchButtonVisibility(browser_view_->panel()->IsActive(),
554 mouse_entered); 634 mouse_entered);
555 } 635 }
556 636
557 void PanelBrowserFrameView::UpdateInfoButtonVisibility(bool active, 637 void PanelBrowserFrameView::UpdateWrenchButtonVisibility(bool active,
558 bool cursor_in_view) { 638 bool cursor_in_view) {
559 info_button_->SetVisible(active || cursor_in_view); 639 wrench_button_->SetVisible(active || cursor_in_view);
560 } 640 }
641
642 const Extension* PanelBrowserFrameView::GetExtension() const {
643 // Find the extension. When we create a panel from an extension, the extension
644 // ID is passed as the app name to the Browser.
645 Browser* browser = browser_view_->browser();
646 ExtensionService* extension_service =
647 browser->GetProfile()->GetExtensionService();
648 return extension_service->GetExtensionById(
649 web_app::GetExtensionIdFromApplicationName(browser->app_name()), false);
650 }
651
652 void PanelBrowserFrameView::EnsureCreateWrenchMenu() {
653 if (wrench_menu_.get())
654 return;
655
656 const Extension* extension = GetExtension();
657 if (!extension)
658 return;
659
660 wrench_menu_contents_.reset(new ui::SimpleMenuModel(this));
661
662 wrench_menu_contents_->AddItem(COMMAND_NAME, UTF8ToUTF16(extension->name()));
Dmitry Titov 2011/06/01 18:37:27 It seems that with this, we don't have any clue wh
Dmitry Titov 2011/06/01 20:06:20 Offline discussion shows we are ok with that, on a
663 wrench_menu_contents_->AddSeparator();
664 wrench_menu_contents_->AddItem(
665 COMMAND_CONFIGURE, l10n_util::GetStringUTF16(IDS_EXTENSIONS_OPTIONS));
666 wrench_menu_contents_->AddItem(
667 COMMAND_DISABLE, l10n_util::GetStringUTF16(IDS_EXTENSIONS_DISABLE));
668 wrench_menu_contents_->AddItem(
669 COMMAND_UNINSTALL, l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL));
670 wrench_menu_contents_->AddSeparator();
671 wrench_menu_contents_->AddItem(
672 COMMAND_MANAGE, l10n_util::GetStringUTF16(IDS_MANAGE_EXTENSIONS));
673
674 wrench_menu_.reset(new views::Menu2(wrench_menu_contents_.get()));
675 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698