| 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 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 21 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
| 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 23 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" |
| 24 #include "chrome/browser/ui/tabs/tab_utils.h" | 24 #include "chrome/browser/ui/tabs/tab_utils.h" |
| 25 #include "chrome/browser/ui/views/frame/browser_view.h" | 25 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 26 #include "chrome/browser/ui/views/tabs/tab.h" | 26 #include "chrome/browser/ui/views/tabs/tab.h" |
| 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/favicon/content/content_favicon_driver.h" | |
| 32 #include "components/metrics/proto/omnibox_event.pb.h" | 31 #include "components/metrics/proto/omnibox_event.pb.h" |
| 33 #include "components/mime_util/mime_util.h" | 32 #include "components/mime_util/mime_util.h" |
| 34 #include "components/omnibox/browser/autocomplete_classifier.h" | 33 #include "components/omnibox/browser/autocomplete_classifier.h" |
| 35 #include "components/omnibox/browser/autocomplete_match.h" | 34 #include "components/omnibox/browser/autocomplete_match.h" |
| 36 #include "components/prefs/pref_service.h" | 35 #include "components/prefs/pref_service.h" |
| 37 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
| 38 #include "content/public/browser/navigation_controller.h" | |
| 39 #include "content/public/browser/navigation_entry.h" | |
| 40 #include "content/public/browser/navigation_handle.h" | |
| 41 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
| 42 #include "content/public/browser/plugin_service.h" | 38 #include "content/public/browser/plugin_service.h" |
| 43 #include "content/public/browser/user_metrics.h" | 39 #include "content/public/browser/user_metrics.h" |
| 44 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
| 45 #include "content/public/common/webplugininfo.h" | 41 #include "content/public/common/webplugininfo.h" |
| 46 #include "ipc/ipc_message.h" | 42 #include "ipc/ipc_message.h" |
| 47 #include "net/base/filename_util.h" | 43 #include "net/base/filename_util.h" |
| 48 #include "ui/base/models/list_selection_model.h" | 44 #include "ui/base/models/list_selection_model.h" |
| 49 #include "ui/gfx/image/image.h" | 45 #include "ui/gfx/image/image.h" |
| 50 #include "ui/views/controls/menu/menu_runner.h" | 46 #include "ui/views/controls/menu/menu_runner.h" |
| 51 #include "ui/views/widget/widget.h" | 47 #include "ui/views/widget/widget.h" |
| 52 | 48 |
| 53 using base::UserMetricsAction; | 49 using base::UserMetricsAction; |
| 54 using content::WebContents; | 50 using content::WebContents; |
| 55 | 51 |
| 56 namespace { | 52 namespace { |
| 57 | 53 |
| 58 TabRendererData::NetworkState TabContentsNetworkState( | 54 TabRendererData::NetworkState TabContentsNetworkState( |
| 59 WebContents* contents) { | 55 WebContents* contents) { |
| 60 if (!contents) | 56 if (!contents || !contents->IsLoadingToDifferentDocument()) |
| 61 return TabRendererData::NETWORK_STATE_NONE; | 57 return TabRendererData::NETWORK_STATE_NONE; |
| 62 if (!contents->IsLoadingToDifferentDocument()) { | |
| 63 content::NavigationEntry* entry = | |
| 64 contents->GetController().GetLastCommittedEntry(); | |
| 65 if (entry && (entry->GetPageType() == content::PAGE_TYPE_ERROR)) | |
| 66 return TabRendererData::NETWORK_STATE_ERROR; | |
| 67 return TabRendererData::NETWORK_STATE_NONE; | |
| 68 } | |
| 69 if (contents->IsWaitingForResponse()) | 58 if (contents->IsWaitingForResponse()) |
| 70 return TabRendererData::NETWORK_STATE_WAITING; | 59 return TabRendererData::NETWORK_STATE_WAITING; |
| 71 return TabRendererData::NETWORK_STATE_LOADING; | 60 return TabRendererData::NETWORK_STATE_LOADING; |
| 72 } | 61 } |
| 73 | 62 |
| 74 bool DetermineTabStripLayoutStacked(PrefService* prefs, bool* adjust_layout) { | 63 bool DetermineTabStripLayoutStacked(PrefService* prefs, bool* adjust_layout) { |
| 75 *adjust_layout = false; | 64 *adjust_layout = false; |
| 76 // For ash, always allow entering stacked mode. | 65 // For ash, always allow entering stacked mode. |
| 77 #if defined(USE_ASH) | 66 #if defined(USE_ASH) |
| 78 *adjust_layout = true; | 67 *adjust_layout = true; |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 void BrowserTabStripController::TabBlockedStateChanged(WebContents* contents, | 483 void BrowserTabStripController::TabBlockedStateChanged(WebContents* contents, |
| 495 int model_index) { | 484 int model_index) { |
| 496 SetTabDataAt(contents, model_index); | 485 SetTabDataAt(contents, model_index); |
| 497 } | 486 } |
| 498 | 487 |
| 499 void BrowserTabStripController::SetTabRendererDataFromModel( | 488 void BrowserTabStripController::SetTabRendererDataFromModel( |
| 500 WebContents* contents, | 489 WebContents* contents, |
| 501 int model_index, | 490 int model_index, |
| 502 TabRendererData* data, | 491 TabRendererData* data, |
| 503 TabStatus tab_status) { | 492 TabStatus tab_status) { |
| 504 favicon::FaviconDriver* favicon_driver = | 493 data->favicon = favicon::TabFaviconFromWebContents(contents).AsImageSkia(); |
| 505 favicon::ContentFaviconDriver::FromWebContents(contents); | |
| 506 | |
| 507 data->favicon = favicon_driver->GetFavicon().AsImageSkia(); | |
| 508 data->network_state = TabContentsNetworkState(contents); | 494 data->network_state = TabContentsNetworkState(contents); |
| 509 data->title = contents->GetTitle(); | 495 data->title = contents->GetTitle(); |
| 510 data->url = contents->GetURL(); | 496 data->url = contents->GetURL(); |
| 511 data->loading = contents->IsLoading(); | 497 data->loading = contents->IsLoading(); |
| 512 data->crashed_status = contents->GetCrashedStatus(); | 498 data->crashed_status = contents->GetCrashedStatus(); |
| 513 data->incognito = contents->GetBrowserContext()->IsOffTheRecord(); | 499 data->incognito = contents->GetBrowserContext()->IsOffTheRecord(); |
| 514 data->pinned = model_->IsTabPinned(model_index); | 500 data->pinned = model_->IsTabPinned(model_index); |
| 515 data->show_icon = data->pinned || favicon::ShouldDisplayFavicon(contents); | 501 data->show_icon = data->pinned || favicon::ShouldDisplayFavicon(contents); |
| 516 data->blocked = model_->IsTabBlocked(model_index); | 502 data->blocked = model_->IsTabBlocked(model_index); |
| 517 data->app = extensions::TabHelper::FromWebContents(contents)->is_app(); | 503 data->app = extensions::TabHelper::FromWebContents(contents)->is_app(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 content::WebPluginInfo plugin; | 567 content::WebPluginInfo plugin; |
| 582 tabstrip_->FileSupported( | 568 tabstrip_->FileSupported( |
| 583 url, | 569 url, |
| 584 mime_type.empty() || mime_util::IsSupportedMimeType(mime_type) || | 570 mime_type.empty() || mime_util::IsSupportedMimeType(mime_type) || |
| 585 content::PluginService::GetInstance()->GetPluginInfo( | 571 content::PluginService::GetInstance()->GetPluginInfo( |
| 586 -1, // process ID | 572 -1, // process ID |
| 587 MSG_ROUTING_NONE, // routing ID | 573 MSG_ROUTING_NONE, // routing ID |
| 588 model_->profile()->GetResourceContext(), url, GURL(), mime_type, | 574 model_->profile()->GetResourceContext(), url, GURL(), mime_type, |
| 589 false, NULL, &plugin, NULL)); | 575 false, NULL, &plugin, NULL)); |
| 590 } | 576 } |
| OLD | NEW |