| 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/macros.h" | 8 #include "base/macros.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 16 matching lines...) Expand all Loading... |
| 27 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h" | 27 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h" |
| 28 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 28 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 30 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 31 #include "components/metrics/proto/omnibox_event.pb.h" | 31 #include "components/metrics/proto/omnibox_event.pb.h" |
| 32 #include "components/mime_util/mime_util.h" | 32 #include "components/mime_util/mime_util.h" |
| 33 #include "components/omnibox/browser/autocomplete_classifier.h" | 33 #include "components/omnibox/browser/autocomplete_classifier.h" |
| 34 #include "components/omnibox/browser/autocomplete_match.h" | 34 #include "components/omnibox/browser/autocomplete_match.h" |
| 35 #include "components/prefs/pref_service.h" | 35 #include "components/prefs/pref_service.h" |
| 36 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
| 37 #include "content/public/browser/navigation_controller.h" | |
| 38 #include "content/public/browser/navigation_entry.h" | |
| 39 #include "content/public/browser/navigation_handle.h" | |
| 40 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
| 41 #include "content/public/browser/plugin_service.h" | 38 #include "content/public/browser/plugin_service.h" |
| 42 #include "content/public/browser/user_metrics.h" | 39 #include "content/public/browser/user_metrics.h" |
| 43 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
| 44 #include "content/public/common/webplugininfo.h" | 41 #include "content/public/common/webplugininfo.h" |
| 45 #include "ipc/ipc_message.h" | 42 #include "ipc/ipc_message.h" |
| 46 #include "net/base/filename_util.h" | 43 #include "net/base/filename_util.h" |
| 47 #include "ui/base/models/list_selection_model.h" | 44 #include "ui/base/models/list_selection_model.h" |
| 48 #include "ui/gfx/image/image.h" | 45 #include "ui/gfx/image/image.h" |
| 49 #include "ui/views/controls/menu/menu_runner.h" | 46 #include "ui/views/controls/menu/menu_runner.h" |
| 50 #include "ui/views/widget/widget.h" | 47 #include "ui/views/widget/widget.h" |
| 51 #include "url/origin.h" | 48 #include "url/origin.h" |
| 52 | 49 |
| 53 using base::UserMetricsAction; | 50 using base::UserMetricsAction; |
| 54 using content::WebContents; | 51 using content::WebContents; |
| 55 | 52 |
| 56 namespace { | 53 namespace { |
| 57 | 54 |
| 58 TabRendererData::NetworkState TabContentsNetworkState( | 55 TabRendererData::NetworkState TabContentsNetworkState( |
| 59 WebContents* contents) { | 56 WebContents* contents) { |
| 60 if (!contents) | 57 if (!contents || !contents->IsLoadingToDifferentDocument()) |
| 61 return TabRendererData::NETWORK_STATE_NONE; | 58 return TabRendererData::NETWORK_STATE_NONE; |
| 62 | |
| 63 if (!contents->IsLoadingToDifferentDocument()) { | |
| 64 content::NavigationEntry* entry = | |
| 65 contents->GetController().GetLastCommittedEntry(); | |
| 66 if (entry && (entry->GetPageType() == content::PAGE_TYPE_ERROR)) | |
| 67 return TabRendererData::NETWORK_STATE_ERROR; | |
| 68 return TabRendererData::NETWORK_STATE_NONE; | |
| 69 } | |
| 70 | |
| 71 if (contents->IsWaitingForResponse()) | 59 if (contents->IsWaitingForResponse()) |
| 72 return TabRendererData::NETWORK_STATE_WAITING; | 60 return TabRendererData::NETWORK_STATE_WAITING; |
| 73 return TabRendererData::NETWORK_STATE_LOADING; | 61 return TabRendererData::NETWORK_STATE_LOADING; |
| 74 } | 62 } |
| 75 | 63 |
| 76 bool DetermineTabStripLayoutStacked(PrefService* prefs, bool* adjust_layout) { | 64 bool DetermineTabStripLayoutStacked(PrefService* prefs, bool* adjust_layout) { |
| 77 *adjust_layout = false; | 65 *adjust_layout = false; |
| 78 // For ash, always allow entering stacked mode. | 66 // For ash, always allow entering stacked mode. |
| 79 #if defined(USE_ASH) | 67 #if defined(USE_ASH) |
| 80 *adjust_layout = true; | 68 *adjust_layout = true; |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 base::Bind(&BrowserTabStripController::OnFindURLMimeTypeCompleted, | 413 base::Bind(&BrowserTabStripController::OnFindURLMimeTypeCompleted, |
| 426 weak_ptr_factory_.GetWeakPtr(), | 414 weak_ptr_factory_.GetWeakPtr(), |
| 427 url)); | 415 url)); |
| 428 } | 416 } |
| 429 | 417 |
| 430 SkColor BrowserTabStripController::GetToolbarTopSeparatorColor() const { | 418 SkColor BrowserTabStripController::GetToolbarTopSeparatorColor() const { |
| 431 return BrowserView::GetBrowserViewForBrowser(browser_)->frame() | 419 return BrowserView::GetBrowserViewForBrowser(browser_)->frame() |
| 432 ->GetFrameView()->GetToolbarTopSeparatorColor(); | 420 ->GetFrameView()->GetToolbarTopSeparatorColor(); |
| 433 } | 421 } |
| 434 | 422 |
| 435 base::string16 BrowserTabStripController::GetAccessibleTabName() const { | |
| 436 return BrowserView::GetBrowserViewForBrowser(browser_) | |
| 437 ->GetAccessibleWindowTitle(); | |
| 438 } | |
| 439 | |
| 440 //////////////////////////////////////////////////////////////////////////////// | 423 //////////////////////////////////////////////////////////////////////////////// |
| 441 // BrowserTabStripController, TabStripModelObserver implementation: | 424 // BrowserTabStripController, TabStripModelObserver implementation: |
| 442 | 425 |
| 443 void BrowserTabStripController::TabInsertedAt(TabStripModel* tab_strip_model, | 426 void BrowserTabStripController::TabInsertedAt(TabStripModel* tab_strip_model, |
| 444 WebContents* contents, | 427 WebContents* contents, |
| 445 int model_index, | 428 int model_index, |
| 446 bool is_active) { | 429 bool is_active) { |
| 447 DCHECK(contents); | 430 DCHECK(contents); |
| 448 DCHECK(model_->ContainsIndex(model_index)); | 431 DCHECK(model_->ContainsIndex(model_index)); |
| 449 AddTab(contents, model_index, is_active); | 432 AddTab(contents, model_index, is_active); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 content::WebPluginInfo plugin; | 571 content::WebPluginInfo plugin; |
| 589 tabstrip_->FileSupported( | 572 tabstrip_->FileSupported( |
| 590 url, | 573 url, |
| 591 mime_type.empty() || mime_util::IsSupportedMimeType(mime_type) || | 574 mime_type.empty() || mime_util::IsSupportedMimeType(mime_type) || |
| 592 content::PluginService::GetInstance()->GetPluginInfo( | 575 content::PluginService::GetInstance()->GetPluginInfo( |
| 593 -1, // process ID | 576 -1, // process ID |
| 594 MSG_ROUTING_NONE, // routing ID | 577 MSG_ROUTING_NONE, // routing ID |
| 595 model_->profile()->GetResourceContext(), url, url::Origin(), | 578 model_->profile()->GetResourceContext(), url, url::Origin(), |
| 596 mime_type, false, NULL, &plugin, NULL)); | 579 mime_type, false, NULL, &plugin, NULL)); |
| 597 } | 580 } |
| OLD | NEW |