| 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/chrome_browser_main_extra_parts_views.h" | 5 #include "chrome/browser/ui/views/chrome_browser_main_extra_parts_views.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chrome_browser_main.h" | 7 #include "chrome/browser/chrome_browser_main.h" |
| 8 #include "chrome/browser/toolkit_extra_parts.h" | 8 #include "chrome/browser/toolkit_extra_parts.h" |
| 9 #include "chrome/browser/ui/views/chrome_views_delegate.h" | 9 #include "chrome/browser/ui/views/chrome_views_delegate.h" |
| 10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| 11 #include "ui/base/ui_base_switches.h" | 11 #include "ui/base/ui_base_switches.h" |
| 12 | 12 |
| 13 ChromeBrowserMainExtraPartsViews::ChromeBrowserMainExtraPartsViews() { | 13 ChromeBrowserMainExtraPartsViews::ChromeBrowserMainExtraPartsViews() { |
| 14 } | 14 } |
| 15 | 15 |
| 16 void ChromeBrowserMainExtraPartsViews::ToolkitInitialized() { | 16 void ChromeBrowserMainExtraPartsViews::ToolkitInitialized() { |
| 17 // The delegate needs to be set before any UI is created so that windows | 17 // The delegate needs to be set before any UI is created so that windows |
| 18 // display the correct icon. | 18 // display the correct icon. |
| 19 if (!views::ViewsDelegate::views_delegate) | 19 if (!views::ViewsDelegate::views_delegate) |
| 20 views::ViewsDelegate::views_delegate = new ChromeViewsDelegate; | 20 views::ViewsDelegate::views_delegate = new ChromeViewsDelegate; |
| 21 } | 21 } |
| 22 | 22 |
| 23 void ChromeBrowserMainExtraPartsViews::PreBrowserStart() { |
| 24 // Any views UI running at this point will need to start refcounting the |
| 25 // browser process. |
| 26 if (views::ViewsDelegate::views_delegate) |
| 27 views::ViewsDelegate::views_delegate->SetRefCounting(true); |
| 28 } |
| 29 |
| 23 void ChromeBrowserMainExtraPartsViews::PreCreateThreads() { | 30 void ChromeBrowserMainExtraPartsViews::PreCreateThreads() { |
| 24 // Enable the new style dialogs when using the interactive autocomplete | 31 // Enable the new style dialogs when using the interactive autocomplete |
| 25 // dialog. Modifying the command line is only safe before starting threads. | 32 // dialog. Modifying the command line is only safe before starting threads. |
| 26 // It also has to come after about flags modifies the command line, which | 33 // It also has to come after about flags modifies the command line, which |
| 27 // is why it's not possible to do this in ToolkitInitialized. | 34 // is why it's not possible to do this in ToolkitInitialized. |
| 28 // TODO(estade): remove this. | 35 // TODO(estade): remove this. |
| 29 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 36 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 30 if (command_line->HasSwitch(switches::kEnableInteractiveAutocomplete)) | 37 if (command_line->HasSwitch(switches::kEnableInteractiveAutocomplete)) |
| 31 command_line->AppendSwitch(switches::kEnableNewDialogStyle); | 38 command_line->AppendSwitch(switches::kEnableNewDialogStyle); |
| 32 } | 39 } |
| 33 | 40 |
| 34 namespace chrome { | 41 namespace chrome { |
| 35 | 42 |
| 36 void AddViewsToolkitExtraParts(ChromeBrowserMainParts* main_parts) { | 43 void AddViewsToolkitExtraParts(ChromeBrowserMainParts* main_parts) { |
| 37 main_parts->AddParts(new ChromeBrowserMainExtraPartsViews()); | 44 main_parts->AddParts(new ChromeBrowserMainExtraPartsViews()); |
| 38 } | 45 } |
| 39 | 46 |
| 40 } // namespace chrome | 47 } // namespace chrome |
| OLD | NEW |