OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/base_paths.h" | 13 #include "base/base_paths.h" |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/location.h" | 16 #include "base/location.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/metrics/histogram_macros.h" | 19 #include "base/metrics/histogram_macros.h" |
| 20 #include "base/metrics/user_metrics.h" |
20 #include "base/process/process_info.h" | 21 #include "base/process/process_info.h" |
21 #include "base/profiler/scoped_tracker.h" | 22 #include "base/profiler/scoped_tracker.h" |
22 #include "base/single_thread_task_runner.h" | 23 #include "base/single_thread_task_runner.h" |
23 #include "base/strings/string_number_conversions.h" | 24 #include "base/strings/string_number_conversions.h" |
24 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
25 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
26 #include "base/threading/thread.h" | 27 #include "base/threading/thread.h" |
27 #include "base/threading/thread_restrictions.h" | 28 #include "base/threading/thread_restrictions.h" |
28 #include "base/threading/thread_task_runner_handle.h" | 29 #include "base/threading/thread_task_runner_handle.h" |
29 #include "base/time/time.h" | 30 #include "base/time/time.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 #include "content/public/browser/notification_details.h" | 183 #include "content/public/browser/notification_details.h" |
183 #include "content/public/browser/notification_service.h" | 184 #include "content/public/browser/notification_service.h" |
184 #include "content/public/browser/plugin_service.h" | 185 #include "content/public/browser/plugin_service.h" |
185 #include "content/public/browser/render_frame_host.h" | 186 #include "content/public/browser/render_frame_host.h" |
186 #include "content/public/browser/render_process_host.h" | 187 #include "content/public/browser/render_process_host.h" |
187 #include "content/public/browser/render_view_host.h" | 188 #include "content/public/browser/render_view_host.h" |
188 #include "content/public/browser/render_widget_host.h" | 189 #include "content/public/browser/render_widget_host.h" |
189 #include "content/public/browser/render_widget_host_view.h" | 190 #include "content/public/browser/render_widget_host_view.h" |
190 #include "content/public/browser/site_instance.h" | 191 #include "content/public/browser/site_instance.h" |
191 #include "content/public/browser/ssl_status.h" | 192 #include "content/public/browser/ssl_status.h" |
192 #include "content/public/browser/user_metrics.h" | |
193 #include "content/public/browser/web_contents.h" | 193 #include "content/public/browser/web_contents.h" |
194 #include "content/public/common/content_constants.h" | 194 #include "content/public/common/content_constants.h" |
195 #include "content/public/common/content_switches.h" | 195 #include "content/public/common/content_switches.h" |
196 #include "content/public/common/page_zoom.h" | 196 #include "content/public/common/page_zoom.h" |
197 #include "content/public/common/renderer_preferences.h" | 197 #include "content/public/common/renderer_preferences.h" |
198 #include "content/public/common/webplugininfo.h" | 198 #include "content/public/common/webplugininfo.h" |
199 #include "extensions/browser/extension_prefs.h" | 199 #include "extensions/browser/extension_prefs.h" |
200 #include "extensions/browser/extension_registry.h" | 200 #include "extensions/browser/extension_registry.h" |
201 #include "extensions/browser/extension_system.h" | 201 #include "extensions/browser/extension_system.h" |
202 #include "extensions/common/constants.h" | 202 #include "extensions/common/constants.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 // that is disallowed by policy. The crash prevents the disabled window type | 387 // that is disallowed by policy. The crash prevents the disabled window type |
388 // from opening at all, but the path that triggered it should be fixed. | 388 // from opening at all, but the path that triggered it should be fixed. |
389 CHECK(IncognitoModePrefs::CanOpenBrowser(profile_)); | 389 CHECK(IncognitoModePrefs::CanOpenBrowser(profile_)); |
390 CHECK(!profile_->IsGuestSession() || profile_->IsOffTheRecord()) | 390 CHECK(!profile_->IsGuestSession() || profile_->IsOffTheRecord()) |
391 << "Only off the record browser may be opened in guest mode"; | 391 << "Only off the record browser may be opened in guest mode"; |
392 DCHECK(!profile_->IsSystemProfile()) | 392 DCHECK(!profile_->IsSystemProfile()) |
393 << "The system profile should never have a real browser."; | 393 << "The system profile should never have a real browser."; |
394 // TODO(mlerman): After this hits stable channel, see if there are counts | 394 // TODO(mlerman): After this hits stable channel, see if there are counts |
395 // for this metric. If not, change the DCHECK above to a CHECK. | 395 // for this metric. If not, change the DCHECK above to a CHECK. |
396 if (profile_->IsSystemProfile()) | 396 if (profile_->IsSystemProfile()) |
397 content::RecordAction(base::UserMetricsAction("BrowserForSystemProfile")); | 397 base::RecordAction(base::UserMetricsAction("BrowserForSystemProfile")); |
398 | 398 |
399 // TODO(jeremy): Move to initializer list once flag is removed. | 399 // TODO(jeremy): Move to initializer list once flag is removed. |
400 if (IsFastTabUnloadEnabled()) | 400 if (IsFastTabUnloadEnabled()) |
401 fast_unload_controller_.reset(new chrome::FastUnloadController(this)); | 401 fast_unload_controller_.reset(new chrome::FastUnloadController(this)); |
402 else | 402 else |
403 unload_controller_.reset(new chrome::UnloadController(this)); | 403 unload_controller_.reset(new chrome::UnloadController(this)); |
404 | 404 |
405 tab_strip_model_->AddObserver(this); | 405 tab_strip_model_->AddObserver(this); |
406 | 406 |
407 toolbar_model_.reset(new ToolbarModelImpl(toolbar_model_delegate_.get(), | 407 toolbar_model_.reset(new ToolbarModelImpl(toolbar_model_delegate_.get(), |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 | 861 |
862 bool Browser::SupportsWindowFeature(WindowFeature feature) const { | 862 bool Browser::SupportsWindowFeature(WindowFeature feature) const { |
863 return SupportsWindowFeatureImpl(feature, true); | 863 return SupportsWindowFeatureImpl(feature, true); |
864 } | 864 } |
865 | 865 |
866 bool Browser::CanSupportWindowFeature(WindowFeature feature) const { | 866 bool Browser::CanSupportWindowFeature(WindowFeature feature) const { |
867 return SupportsWindowFeatureImpl(feature, false); | 867 return SupportsWindowFeatureImpl(feature, false); |
868 } | 868 } |
869 | 869 |
870 void Browser::OpenFile() { | 870 void Browser::OpenFile() { |
871 content::RecordAction(UserMetricsAction("OpenFile")); | 871 base::RecordAction(UserMetricsAction("OpenFile")); |
872 select_file_dialog_ = ui::SelectFileDialog::Create( | 872 select_file_dialog_ = ui::SelectFileDialog::Create( |
873 this, new ChromeSelectFilePolicy( | 873 this, new ChromeSelectFilePolicy( |
874 tab_strip_model_->GetActiveWebContents())); | 874 tab_strip_model_->GetActiveWebContents())); |
875 | 875 |
876 const base::FilePath directory = profile_->last_selected_directory(); | 876 const base::FilePath directory = profile_->last_selected_directory(); |
877 | 877 |
878 // TODO(beng): figure out how to juggle this. | 878 // TODO(beng): figure out how to juggle this. |
879 gfx::NativeWindow parent_window = window_->GetNativeWindow(); | 879 gfx::NativeWindow parent_window = window_->GetNativeWindow(); |
880 ui::SelectFileDialog::FileTypeInfo file_types; | 880 ui::SelectFileDialog::FileTypeInfo file_types; |
881 file_types.allowed_paths = ui::SelectFileDialog::FileTypeInfo::ANY_PATH; | 881 file_types.allowed_paths = ui::SelectFileDialog::FileTypeInfo::ANY_PATH; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 if (old_contents && new_contents) { | 1055 if (old_contents && new_contents) { |
1056 // While GetMainFrame() is guaranteed to return non-null, GetView() is not, | 1056 // While GetMainFrame() is guaranteed to return non-null, GetView() is not, |
1057 // e.g. between WebContents creation and creation of the | 1057 // e.g. between WebContents creation and creation of the |
1058 // RenderWidgetHostView. | 1058 // RenderWidgetHostView. |
1059 RenderWidgetHostView* old_view = old_contents->GetMainFrame()->GetView(); | 1059 RenderWidgetHostView* old_view = old_contents->GetMainFrame()->GetView(); |
1060 RenderWidgetHostView* new_view = new_contents->GetMainFrame()->GetView(); | 1060 RenderWidgetHostView* new_view = new_contents->GetMainFrame()->GetView(); |
1061 if (old_view && new_view) | 1061 if (old_view && new_view) |
1062 new_view->SetBackgroundColor(old_view->background_color()); | 1062 new_view->SetBackgroundColor(old_view->background_color()); |
1063 } | 1063 } |
1064 | 1064 |
1065 content::RecordAction(UserMetricsAction("ActiveTabChanged")); | 1065 base::RecordAction(UserMetricsAction("ActiveTabChanged")); |
1066 | 1066 |
1067 // Update the bookmark state, since the BrowserWindow may query it during | 1067 // Update the bookmark state, since the BrowserWindow may query it during |
1068 // OnActiveTabChanged() below. | 1068 // OnActiveTabChanged() below. |
1069 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH); | 1069 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_SWITCH); |
1070 | 1070 |
1071 // Let the BrowserWindow do its handling. On e.g. views this changes the | 1071 // Let the BrowserWindow do its handling. On e.g. views this changes the |
1072 // focused object, which should happen before we update the toolbar below, | 1072 // focused object, which should happen before we update the toolbar below, |
1073 // since the omnibox expects the correct element to already be focused when it | 1073 // since the omnibox expects the correct element to already be focused when it |
1074 // is updated. | 1074 // is updated. |
1075 window_->OnActiveTabChanged(old_contents, new_contents, index, reason); | 1075 window_->OnActiveTabChanged(old_contents, new_contents, index, reason); |
(...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2638 // new window later, thus we need to navigate the window now. | 2638 // new window later, thus we need to navigate the window now. |
2639 if (contents) { | 2639 if (contents) { |
2640 contents->web_contents()->GetController().LoadURL( | 2640 contents->web_contents()->GetController().LoadURL( |
2641 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, | 2641 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, |
2642 std::string()); // No extra headers. | 2642 std::string()); // No extra headers. |
2643 } | 2643 } |
2644 } | 2644 } |
2645 | 2645 |
2646 return contents != NULL; | 2646 return contents != NULL; |
2647 } | 2647 } |
OLD | NEW |