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

Side by Side Diff: chrome/browser/tabs/tab_strip_model.cc

Issue 391036: Forbid reloading the Inspector window (Closed)
Patch Set: Follow codereview Created 11 years 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/tabs/tab_strip_model.h" 5 #include "chrome/browser/tabs/tab_strip_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "chrome/browser/bookmarks/bookmark_model.h" 13 #include "chrome/browser/bookmarks/bookmark_model.h"
14 #include "chrome/browser/browser_shutdown.h" 14 #include "chrome/browser/browser_shutdown.h"
15 #include "chrome/browser/metrics/user_metrics.h" 15 #include "chrome/browser/metrics/user_metrics.h"
16 #include "chrome/browser/profile.h" 16 #include "chrome/browser/profile.h"
17 #include "chrome/browser/renderer_host/render_process_host.h" 17 #include "chrome/browser/renderer_host/render_process_host.h"
18 #include "chrome/browser/sessions/tab_restore_service.h" 18 #include "chrome/browser/sessions/tab_restore_service.h"
19 #include "chrome/browser/tabs/tab_strip_model_order_controller.h" 19 #include "chrome/browser/tabs/tab_strip_model_order_controller.h"
20 #include "chrome/browser/tab_contents/navigation_controller.h" 20 #include "chrome/browser/tab_contents/navigation_controller.h"
21 #include "chrome/browser/tab_contents/tab_contents.h" 21 #include "chrome/browser/tab_contents/tab_contents.h"
22 #include "chrome/browser/tab_contents/tab_contents_delegate.h"
22 #include "chrome/browser/tab_contents/tab_contents_view.h" 23 #include "chrome/browser/tab_contents/tab_contents_view.h"
23 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
24 #include "chrome/common/notification_service.h" 25 #include "chrome/common/notification_service.h"
25 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
26 27
27 namespace { 28 namespace {
28 29
29 // Returns true if the specified transition is one of the types that cause the 30 // Returns true if the specified transition is one of the types that cause the
30 // opener relationships for the tab in which the transition occured to be 31 // opener relationships for the tab in which the transition occured to be
31 // forgotten. This is generally any navigation that isn't a link click (i.e. 32 // forgotten. This is generally any navigation that isn't a link click (i.e.
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 return delegate_->CreateNewStripWithContents(detached_contents, window_bounds, 494 return delegate_->CreateNewStripWithContents(detached_contents, window_bounds,
494 dock_info); 495 dock_info);
495 } 496 }
496 497
497 // Context menu functions. 498 // Context menu functions.
498 bool TabStripModel::IsContextMenuCommandEnabled( 499 bool TabStripModel::IsContextMenuCommandEnabled(
499 int context_index, ContextMenuCommand command_id) const { 500 int context_index, ContextMenuCommand command_id) const {
500 DCHECK(command_id > CommandFirst && command_id < CommandLast); 501 DCHECK(command_id > CommandFirst && command_id < CommandLast);
501 switch (command_id) { 502 switch (command_id) {
502 case CommandNewTab: 503 case CommandNewTab:
503 case CommandReload:
504 case CommandCloseTab: 504 case CommandCloseTab:
505 return true; 505 return true;
506 case CommandReload:
507 if (TabContents* contents = GetTabContentsAt(context_index)) {
pfeldman 2009/12/25 15:22:59 Do not use { } with single line statements.
pfeldman 2009/12/25 15:22:59 No need to check tab contents for being NULL.
508 return contents->delegate()->CanReloadContents(contents);
509 } else {
510 return false;
511 }
506 case CommandCloseOtherTabs: 512 case CommandCloseOtherTabs:
507 return count() > 1; 513 return count() > 1;
508 case CommandCloseTabsToRight: 514 case CommandCloseTabsToRight:
509 return context_index < (count() - 1); 515 return context_index < (count() - 1);
510 case CommandCloseTabsOpenedBy: { 516 case CommandCloseTabsOpenedBy: {
511 int next_index = GetIndexOfNextTabContentsOpenedBy( 517 int next_index = GetIndexOfNextTabContentsOpenedBy(
512 &GetTabContentsAt(context_index)->controller(), context_index, true); 518 &GetTabContentsAt(context_index)->controller(), context_index, true);
513 return next_index != kNoTab; 519 return next_index != kNoTab;
514 } 520 }
515 case CommandDuplicate: 521 case CommandDuplicate:
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 const NavigationController* opener, 780 const NavigationController* opener,
775 bool use_group) { 781 bool use_group) {
776 return data->opener == opener || (use_group && data->group == opener); 782 return data->opener == opener || (use_group && data->group == opener);
777 } 783 }
778 784
779 void TabStripModel::LogEvent(Event type) { 785 void TabStripModel::LogEvent(Event type) {
780 char c = 'a' + (int)type; 786 char c = 'a' + (int)type;
781 tracker_.Append(std::string(&c, 1)); 787 tracker_.Append(std::string(&c, 1));
782 tracker_.Append(IntToString(count())); 788 tracker_.Append(IntToString(count()));
783 } 789 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698