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

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

Issue 10736037: Enable keyboard shortcuts and some menu commands for browserless Panels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced Created 8 years, 5 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
« no previous file with comments | « chrome/browser/ui/panels/panel.h ('k') | chrome/browser/ui/panels/panel_cocoa.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/panels/panel.h" 5 #include "chrome/browser/ui/panels/panel.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
11 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 11 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
12 #include "chrome/browser/extensions/extension_window_controller.h" 12 #include "chrome/browser/extensions/extension_window_controller.h"
13 #include "chrome/browser/lifetime/application_lifetime.h" 13 #include "chrome/browser/lifetime/application_lifetime.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/panels/native_panel.h" 15 #include "chrome/browser/ui/panels/native_panel.h"
16 #include "chrome/browser/ui/panels/panel_host.h" 16 #include "chrome/browser/ui/panels/panel_host.h"
17 #include "chrome/browser/ui/panels/panel_manager.h" 17 #include "chrome/browser/ui/panels/panel_manager.h"
18 #include "chrome/browser/ui/panels/panel_strip.h" 18 #include "chrome/browser/ui/panels/panel_strip.h"
19 #include "chrome/browser/web_applications/web_app.h" 19 #include "chrome/browser/web_applications/web_app.h"
20 #include "chrome/common/chrome_notification_types.h" 20 #include "chrome/common/chrome_notification_types.h"
21 #include "chrome/common/extensions/extension.h" 21 #include "chrome/common/extensions/extension.h"
22 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
23 #include "content/public/browser/notification_source.h" 23 #include "content/public/browser/notification_source.h"
24 #include "content/public/browser/notification_types.h" 24 #include "content/public/browser/notification_types.h"
25 #include "content/public/browser/render_view_host.h" 25 #include "content/public/browser/render_view_host.h"
26 #include "content/public/browser/user_metrics.h"
26 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
27 #include "third_party/skia/include/core/SkBitmap.h" 28 #include "third_party/skia/include/core/SkBitmap.h"
28 #include "ui/gfx/rect.h" 29 #include "ui/gfx/rect.h"
29 30
30 using content::RenderViewHost; 31 using content::RenderViewHost;
32 using content::UserMetricsAction;
31 33
32 namespace panel_internal { 34 namespace panel_internal {
33 35
34 class PanelExtensionWindowController : public ExtensionWindowController { 36 class PanelExtensionWindowController : public ExtensionWindowController {
35 public: 37 public:
36 PanelExtensionWindowController(Panel* panel, Profile* profile); 38 PanelExtensionWindowController(Panel* panel, Profile* profile);
37 39
38 // Overridden from ExtensionWindowController. 40 // Overridden from ExtensionWindowController.
39 virtual int GetWindowId() const OVERRIDE; 41 virtual int GetWindowId() const OVERRIDE;
40 virtual std::string GetWindowTypeText() const OVERRIDE; 42 virtual std::string GetWindowTypeText() const OVERRIDE;
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 // * cannot grow or shrink to go beyond [min_height, max_height] 312 // * cannot grow or shrink to go beyond [min_height, max_height]
311 int new_height = size.height(); 313 int new_height = size.height();
312 if (new_height > max_size_.height()) 314 if (new_height > max_size_.height())
313 new_height = max_size_.height(); 315 new_height = max_size_.height();
314 if (new_height < min_size_.height()) 316 if (new_height < min_size_.height())
315 new_height = min_size_.height(); 317 new_height = min_size_.height();
316 318
317 return gfx::Size(new_width, new_height); 319 return gfx::Size(new_width, new_height);
318 } 320 }
319 321
322 void Panel::HandleKeyboardEvent(const content::NativeWebKeyboardEvent& event) {
323 native_panel_->HandlePanelKeyboardEvent(event);
324 }
325
320 void Panel::SetAlwaysOnTop(bool on_top) { 326 void Panel::SetAlwaysOnTop(bool on_top) {
321 if (always_on_top_ == on_top) 327 if (always_on_top_ == on_top)
322 return; 328 return;
323 always_on_top_ = on_top; 329 always_on_top_ = on_top;
324 native_panel_->SetPanelAlwaysOnTop(on_top); 330 native_panel_->SetPanelAlwaysOnTop(on_top);
325 } 331 }
326 332
327 void Panel::EnableResizeByMouse(bool enable) { 333 void Panel::EnableResizeByMouse(bool enable) {
328 DCHECK(native_panel_); 334 DCHECK(native_panel_);
329 native_panel_->EnableResizeByMouse(enable); 335 native_panel_->EnableResizeByMouse(enable);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 } 519 }
514 520
515 void Panel::ExecuteCommandWithDisposition(int id, 521 void Panel::ExecuteCommandWithDisposition(int id,
516 WindowOpenDisposition disposition) { 522 WindowOpenDisposition disposition) {
517 if (!GetWebContents()) 523 if (!GetWebContents())
518 return; 524 return;
519 525
520 DCHECK(command_updater_.IsCommandEnabled(id)) << "Invalid/disabled command " 526 DCHECK(command_updater_.IsCommandEnabled(id)) << "Invalid/disabled command "
521 << id; 527 << id;
522 switch (id) { 528 switch (id) {
523 case IDC_RELOAD: // etc 529 // Navigation
524 // TODO(jennb): implement. 530 case IDC_RELOAD:
531 panel_host_->Reload();
532 break;
533 case IDC_RELOAD_IGNORING_CACHE:
534 panel_host_->ReloadIgnoringCache();
535 break;
536 case IDC_STOP:
537 panel_host_->StopLoading();
538 break;
539
540 // Clipboard
541 case IDC_COPY:
542 content::RecordAction(UserMetricsAction("Copy"));
543 native_panel_->PanelCopy();
544 break;
545 case IDC_CUT:
546 content::RecordAction(UserMetricsAction("Cut"));
547 native_panel_->PanelCut();
548 break;
549 case IDC_PASTE:
550 content::RecordAction(UserMetricsAction("Paste"));
551 native_panel_->PanelPaste();
552 break;
553
554 // Zoom
555 case IDC_ZOOM_PLUS:
556 panel_host_->Zoom(content::PAGE_ZOOM_IN);
557 break;
558 case IDC_ZOOM_NORMAL:
559 panel_host_->Zoom(content::PAGE_ZOOM_RESET);
560 break;
561 case IDC_ZOOM_MINUS:
562 panel_host_->Zoom(content::PAGE_ZOOM_OUT);
563 break;
564
525 default: 565 default:
526 LOG(WARNING) << "Received unimplemented command: " << id; 566 LOG(WARNING) << "Received unimplemented command: " << id;
527 break; 567 break;
528 } 568 }
529 } 569 }
530 570
531 bool Panel::ExecuteCommandIfEnabled(int id) { 571 bool Panel::ExecuteCommandIfEnabled(int id) {
532 if (command_updater()->SupportsCommand(id) && 572 if (command_updater()->SupportsCommand(id) &&
533 command_updater()->IsCommandEnabled(id)) { 573 command_updater()->IsCommandEnabled(id)) {
534 ExecuteCommandWithDisposition(id, CURRENT_TAB); 574 ExecuteCommandWithDisposition(id, CURRENT_TAB);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 714
675 SkBitmap Panel::GetCurrentPageIcon() const { 715 SkBitmap Panel::GetCurrentPageIcon() const {
676 return panel_host_->GetPageIcon(); 716 return panel_host_->GetPageIcon();
677 } 717 }
678 718
679 void Panel::UpdateTitleBar() { 719 void Panel::UpdateTitleBar() {
680 native_panel_->UpdatePanelTitleBar(); 720 native_panel_->UpdatePanelTitleBar();
681 } 721 }
682 722
683 void Panel::LoadingStateChanged(bool is_loading) { 723 void Panel::LoadingStateChanged(bool is_loading) {
724 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading);
684 native_panel_->UpdatePanelLoadingAnimations(is_loading); 725 native_panel_->UpdatePanelLoadingAnimations(is_loading);
685 UpdateTitleBar(); 726 UpdateTitleBar();
686 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading);
687 } 727 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel.h ('k') | chrome/browser/ui/panels/panel_cocoa.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698