#include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h"
#include "base/auto_reset.h"
-#include "base/command_line.h"
#include "base/prefs/pref_service.h"
#include "base/task_runner_util.h"
#include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/autocomplete/autocomplete_classifier.h"
#include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
-#include "chrome/browser/autocomplete/autocomplete_input.h"
-#include "chrome/browser/autocomplete/autocomplete_match.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/ui/views/tabs/tab.h"
#include "chrome/browser/ui/views/tabs/tab_renderer_data.h"
#include "chrome/browser/ui/views/tabs/tab_strip.h"
-#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
+#include "components/metrics/proto/omnibox_event.pb.h"
+#include "components/omnibox/autocomplete_match.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/plugin_service.h"
TabRendererData::NetworkState TabContentsNetworkState(
WebContents* contents) {
- if (!contents || !contents->IsLoading())
+ if (!contents || !contents->IsLoadingToDifferentDocument())
return TabRendererData::NETWORK_STATE_NONE;
if (contents->IsWaitingForResponse())
return TabRendererData::NETWORK_STATE_WAITING;
return TabRendererData::NETWORK_STATE_LOADING;
}
-TabStripLayoutType DetermineTabStripLayout(
+bool DetermineTabStripLayoutStacked(
PrefService* prefs,
chrome::HostDesktopType host_desktop_type,
bool* adjust_layout) {
*adjust_layout = false;
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableStackedTabStrip)) {
- return TAB_STRIP_LAYOUT_STACKED;
- }
// For ash, always allow entering stacked mode.
if (host_desktop_type != chrome::HOST_DESKTOP_TYPE_ASH)
- return TAB_STRIP_LAYOUT_SHRINK;
+ return false;
*adjust_layout = true;
- switch (prefs->GetInteger(prefs::kTabStripLayoutType)) {
- case TAB_STRIP_LAYOUT_STACKED:
- return TAB_STRIP_LAYOUT_STACKED;
- default:
- return TAB_STRIP_LAYOUT_SHRINK;
- }
+ return prefs->GetBoolean(prefs::kTabStripStackedLayout);
}
// Get the MIME type of the file pointed to by the url, based on the file's
model_.reset(new TabMenuModel(
this, controller->model_,
controller->tabstrip_->GetModelIndexOfTab(tab)));
- menu_runner_.reset(new views::MenuRunner(model_.get()));
+ menu_runner_.reset(new views::MenuRunner(
+ model_.get(),
+ views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU));
}
virtual ~TabContextMenuContents() {
NULL,
gfx::Rect(point, gfx::Size()),
views::MENU_ANCHOR_TOPLEFT,
- source_type,
- views::MenuRunner::HAS_MNEMONICS |
- views::MenuRunner::CONTEXT_MENU) ==
+ source_type) ==
views::MenuRunner::MENU_DELETED) {
return;
}
local_pref_registrar_.Init(g_browser_process->local_state());
local_pref_registrar_.Add(
- prefs::kTabStripLayoutType,
- base::Bind(&BrowserTabStripController::UpdateLayoutType,
+ prefs::kTabStripStackedLayout,
+ base::Bind(&BrowserTabStripController::UpdateStackedLayout,
base::Unretained(this)));
}
void BrowserTabStripController::InitFromModel(TabStrip* tabstrip) {
tabstrip_ = tabstrip;
- UpdateLayoutType();
+ UpdateStackedLayout();
// Walk the model, calling our insertion observer method for each item within
// it.
// a search query if necessary.
AutocompleteMatch match;
AutocompleteClassifierFactory::GetForProfile(profile())->Classify(
- location, false, false, AutocompleteInput::BLANK, &match, NULL);
+ location, false, false, metrics::OmniboxEventProto::BLANK, &match, NULL);
if (match.destination_url.is_valid())
model_->delegate()->AddTabAt(match.destination_url, -1, true);
}
return browser_->profile()->IsOffTheRecord();
}
-void BrowserTabStripController::LayoutTypeMaybeChanged() {
+void BrowserTabStripController::StackedLayoutMaybeChanged() {
bool adjust_layout = false;
- TabStripLayoutType layout_type =
- DetermineTabStripLayout(g_browser_process->local_state(),
- browser_->host_desktop_type(), &adjust_layout);
- if (!adjust_layout || layout_type == tabstrip_->layout_type())
+ bool stacked_layout =
+ DetermineTabStripLayoutStacked(g_browser_process->local_state(),
+ browser_->host_desktop_type(),
+ &adjust_layout);
+ if (!adjust_layout || stacked_layout == tabstrip_->stacked_layout())
return;
- g_browser_process->local_state()->SetInteger(
- prefs::kTabStripLayoutType,
- static_cast<int>(tabstrip_->layout_type()));
+ g_browser_process->local_state()->SetBoolean(prefs::kTabStripStackedLayout,
+ tabstrip_->stacked_layout());
}
void BrowserTabStripController::OnStartedDraggingTabs() {
tabstrip_->AddTabAt(index, data, is_active);
}
-void BrowserTabStripController::UpdateLayoutType() {
+void BrowserTabStripController::UpdateStackedLayout() {
bool adjust_layout = false;
- TabStripLayoutType layout_type =
- DetermineTabStripLayout(g_browser_process->local_state(),
- browser_->host_desktop_type(), &adjust_layout);
- tabstrip_->SetLayoutType(layout_type, adjust_layout);
+ bool stacked_layout =
+ DetermineTabStripLayoutStacked(g_browser_process->local_state(),
+ browser_->host_desktop_type(),
+ &adjust_layout);
+ tabstrip_->set_adjust_layout(adjust_layout);
+ tabstrip_->SetStackedLayout(stacked_layout);
}
void BrowserTabStripController::OnFindURLMimeTypeCompleted(