Chromium Code Reviews| Index: chrome/browser/ui/panels/panel.cc |
| diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc |
| index 6505b0b1a639862b47144a29eb337131121775d1..ae33e109d55417f0cf0a54e4aefc994977fd20f3 100644 |
| --- a/chrome/browser/ui/panels/panel.cc |
| +++ b/chrome/browser/ui/panels/panel.cc |
| @@ -12,6 +12,7 @@ |
| #include "chrome/browser/extensions/extension_window_controller.h" |
| #include "chrome/browser/lifetime/application_lifetime.h" |
| #include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/ui/browser_commands.h" |
| #include "chrome/browser/ui/panels/native_panel.h" |
| #include "chrome/browser/ui/panels/panel_host.h" |
| #include "chrome/browser/ui/panels/panel_manager.h" |
| @@ -23,11 +24,13 @@ |
| #include "content/public/browser/notification_source.h" |
| #include "content/public/browser/notification_types.h" |
| #include "content/public/browser/render_view_host.h" |
| +#include "content/public/browser/user_metrics.h" |
| #include "content/public/browser/web_contents.h" |
| #include "third_party/skia/include/core/SkBitmap.h" |
| #include "ui/gfx/rect.h" |
| using content::RenderViewHost; |
| +using content::UserMetricsAction; |
| namespace panel_internal { |
| @@ -161,6 +164,8 @@ void Panel::InitCommandState() { |
| command_updater_.UpdateCommandEnabled(IDC_RELOAD_IGNORING_CACHE, true); |
| // Window management commands |
| + command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW, true); |
|
Dmitry Titov
2012/07/11 21:27:18
It'd be nice to have a comment explaining why a pa
|
| + command_updater_.UpdateCommandEnabled(IDC_NEW_INCOGNITO_WINDOW, true); |
| command_updater_.UpdateCommandEnabled(IDC_CLOSE_WINDOW, true); |
| command_updater_.UpdateCommandEnabled(IDC_EXIT, true); |
| @@ -317,6 +322,14 @@ gfx::Size Panel::ClampSize(const gfx::Size& size) const { |
| return gfx::Size(new_width, new_height); |
| } |
| +void Panel::ContentsZoomChange(bool zoom_in) { |
| + command_updater()->ExecuteCommand(zoom_in ? IDC_ZOOM_PLUS : IDC_ZOOM_MINUS); |
| +} |
| + |
| +void Panel::HandleKeyboardEvent(const content::NativeWebKeyboardEvent& event) { |
| + native_panel_->HandlePanelKeyboardEvent(event); |
| +} |
| + |
| void Panel::SetAlwaysOnTop(bool on_top) { |
| if (always_on_top_ == on_top) |
| return; |
| @@ -520,8 +533,53 @@ void Panel::ExecuteCommandWithDisposition(int id, |
| DCHECK(command_updater_.IsCommandEnabled(id)) << "Invalid/disabled command " |
| << id; |
| switch (id) { |
| - case IDC_RELOAD: // etc |
| - // TODO(jennb): implement. |
| + // Navigation |
| + case IDC_RELOAD: |
| + content::RecordAction(UserMetricsAction("Reload")); |
| + GetWebContents()->GetController().Reload(true); |
| + break; |
| + case IDC_RELOAD_IGNORING_CACHE: |
| + content::RecordAction(UserMetricsAction("ReloadIgnoringCache")); |
| + GetWebContents()->GetController().ReloadIgnoringCache(true); |
| + break; |
| + case IDC_STOP: |
| + content::RecordAction(UserMetricsAction("Stop")); |
| + GetWebContents()->Stop(); |
| + break; |
| + |
| + // Window management |
| + case IDC_NEW_WINDOW: |
| + chrome::NewEmptyWindow(profile()); |
| + break; |
| + case IDC_NEW_INCOGNITO_WINDOW: |
| + chrome::NewEmptyWindow(profile()->GetOffTheRecordProfile()); |
| + break; |
| + |
| + // Clipboard |
| + case IDC_COPY: |
| + content::RecordAction(UserMetricsAction("Copy")); |
| + native_panel_->PanelCopy(); |
| + break; |
| + case IDC_CUT: |
| + content::RecordAction(UserMetricsAction("Cut")); |
| + native_panel_->PanelCut(); |
| + break; |
| + case IDC_PASTE: |
| + content::RecordAction(UserMetricsAction("Paste")); |
| + native_panel_->PanelPaste(); |
| + break; |
| + |
| + // Zoom |
| + case IDC_ZOOM_PLUS: |
| + chrome::Zoom(GetWebContents(), profile(), content::PAGE_ZOOM_IN); |
| + break; |
| + case IDC_ZOOM_NORMAL: |
| + chrome::Zoom(GetWebContents(), profile(), content::PAGE_ZOOM_RESET); |
| + break; |
| + case IDC_ZOOM_MINUS: |
| + chrome::Zoom(GetWebContents(), profile(), content::PAGE_ZOOM_OUT); |
| + break; |
| + |
| default: |
| LOG(WARNING) << "Received unimplemented command: " << id; |
| break; |
| @@ -681,7 +739,7 @@ void Panel::UpdateTitleBar() { |
| } |
| void Panel::LoadingStateChanged(bool is_loading) { |
| + command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); |
| native_panel_->UpdatePanelLoadingAnimations(is_loading); |
| UpdateTitleBar(); |
| - command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); |
| } |