| OLD | NEW |
| 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/tabs/browser_tab_strip_controller.h" | 5 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/task_runner_util.h" | 9 #include "base/task_runner_util.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 NULL, | 115 NULL, |
| 116 gfx::Rect(point, gfx::Size()), | 116 gfx::Rect(point, gfx::Size()), |
| 117 views::MENU_ANCHOR_TOPLEFT, | 117 views::MENU_ANCHOR_TOPLEFT, |
| 118 source_type) == | 118 source_type) == |
| 119 views::MenuRunner::MENU_DELETED) { | 119 views::MenuRunner::MENU_DELETED) { |
| 120 return; | 120 return; |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 // Overridden from ui::SimpleMenuModel::Delegate: | 124 // Overridden from ui::SimpleMenuModel::Delegate: |
| 125 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE { | 125 virtual bool IsCommandIdChecked(int command_id) const override { |
| 126 return false; | 126 return false; |
| 127 } | 127 } |
| 128 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE { | 128 virtual bool IsCommandIdEnabled(int command_id) const override { |
| 129 return controller_->IsCommandEnabledForTab( | 129 return controller_->IsCommandEnabledForTab( |
| 130 static_cast<TabStripModel::ContextMenuCommand>(command_id), | 130 static_cast<TabStripModel::ContextMenuCommand>(command_id), |
| 131 tab_); | 131 tab_); |
| 132 } | 132 } |
| 133 virtual bool GetAcceleratorForCommandId( | 133 virtual bool GetAcceleratorForCommandId( |
| 134 int command_id, | 134 int command_id, |
| 135 ui::Accelerator* accelerator) OVERRIDE { | 135 ui::Accelerator* accelerator) override { |
| 136 int browser_cmd; | 136 int browser_cmd; |
| 137 return TabStripModel::ContextMenuCommandToBrowserCommand(command_id, | 137 return TabStripModel::ContextMenuCommandToBrowserCommand(command_id, |
| 138 &browser_cmd) ? | 138 &browser_cmd) ? |
| 139 controller_->tabstrip_->GetWidget()->GetAccelerator(browser_cmd, | 139 controller_->tabstrip_->GetWidget()->GetAccelerator(browser_cmd, |
| 140 accelerator) : | 140 accelerator) : |
| 141 false; | 141 false; |
| 142 } | 142 } |
| 143 virtual void CommandIdHighlighted(int command_id) OVERRIDE { | 143 virtual void CommandIdHighlighted(int command_id) override { |
| 144 controller_->StopHighlightTabsForCommand(last_command_, tab_); | 144 controller_->StopHighlightTabsForCommand(last_command_, tab_); |
| 145 last_command_ = static_cast<TabStripModel::ContextMenuCommand>(command_id); | 145 last_command_ = static_cast<TabStripModel::ContextMenuCommand>(command_id); |
| 146 controller_->StartHighlightTabsForCommand(last_command_, tab_); | 146 controller_->StartHighlightTabsForCommand(last_command_, tab_); |
| 147 } | 147 } |
| 148 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE { | 148 virtual void ExecuteCommand(int command_id, int event_flags) override { |
| 149 // Executing the command destroys |this|, and can also end up destroying | 149 // Executing the command destroys |this|, and can also end up destroying |
| 150 // |controller_|. So stop the highlights before executing the command. | 150 // |controller_|. So stop the highlights before executing the command. |
| 151 controller_->tabstrip_->StopAllHighlighting(); | 151 controller_->tabstrip_->StopAllHighlighting(); |
| 152 controller_->ExecuteCommandForTab( | 152 controller_->ExecuteCommandForTab( |
| 153 static_cast<TabStripModel::ContextMenuCommand>(command_id), | 153 static_cast<TabStripModel::ContextMenuCommand>(command_id), |
| 154 tab_); | 154 tab_); |
| 155 } | 155 } |
| 156 | 156 |
| 157 virtual void MenuClosed(ui::SimpleMenuModel* /*source*/) OVERRIDE { | 157 virtual void MenuClosed(ui::SimpleMenuModel* /*source*/) override { |
| 158 if (controller_) | 158 if (controller_) |
| 159 controller_->tabstrip_->StopAllHighlighting(); | 159 controller_->tabstrip_->StopAllHighlighting(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 private: | 162 private: |
| 163 scoped_ptr<TabMenuModel> model_; | 163 scoped_ptr<TabMenuModel> model_; |
| 164 scoped_ptr<views::MenuRunner> menu_runner_; | 164 scoped_ptr<views::MenuRunner> menu_runner_; |
| 165 | 165 |
| 166 // The tab we're showing a menu for. | 166 // The tab we're showing a menu for. |
| 167 Tab* tab_; | 167 Tab* tab_; |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 url, | 584 url, |
| 585 mime_type.empty() || | 585 mime_type.empty() || |
| 586 net::IsSupportedMimeType(mime_type) || | 586 net::IsSupportedMimeType(mime_type) || |
| 587 content::PluginService::GetInstance()->GetPluginInfo( | 587 content::PluginService::GetInstance()->GetPluginInfo( |
| 588 -1, // process ID | 588 -1, // process ID |
| 589 MSG_ROUTING_NONE, // routing ID | 589 MSG_ROUTING_NONE, // routing ID |
| 590 model_->profile()->GetResourceContext(), | 590 model_->profile()->GetResourceContext(), |
| 591 url, GURL(), mime_type, false, | 591 url, GURL(), mime_type, false, |
| 592 NULL, &plugin, NULL)); | 592 NULL, &plugin, NULL)); |
| 593 } | 593 } |
| OLD | NEW |