Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/extensions/extension_browsertest.cc

Issue 11362166: Merge 166715 - Revert r165772: Keep browser process alive while there are platform apps with backgr… (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1320/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/extensions/extension_browsertest.h" 5 #include "chrome/browser/extensions/extension_browsertest.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/scoped_temp_dir.h" 13 #include "base/scoped_temp_dir.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "chrome/browser/extensions/app_shortcut_manager.h" 17 #include "chrome/browser/extensions/app_shortcut_manager.h"
18 #include "chrome/browser/extensions/component_loader.h" 18 #include "chrome/browser/extensions/component_loader.h"
19 #include "chrome/browser/extensions/crx_installer.h" 19 #include "chrome/browser/extensions/crx_installer.h"
20 #include "chrome/browser/extensions/extension_creator.h" 20 #include "chrome/browser/extensions/extension_creator.h"
21 #include "chrome/browser/extensions/extension_error_reporter.h" 21 #include "chrome/browser/extensions/extension_error_reporter.h"
22 #include "chrome/browser/extensions/extension_host.h" 22 #include "chrome/browser/extensions/extension_host.h"
23 #include "chrome/browser/extensions/extension_install_prompt.h" 23 #include "chrome/browser/extensions/extension_install_prompt.h"
24 #include "chrome/browser/extensions/extension_service.h" 24 #include "chrome/browser/extensions/extension_service.h"
25 #include "chrome/browser/extensions/extension_system.h" 25 #include "chrome/browser/extensions/extension_system.h"
26 #include "chrome/browser/extensions/shell_window_registry.h"
27 #include "chrome/browser/extensions/unpacked_installer.h" 26 #include "chrome/browser/extensions/unpacked_installer.h"
28 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
29 #include "chrome/browser/ui/browser.h" 28 #include "chrome/browser/ui/browser.h"
30 #include "chrome/browser/ui/browser_window.h" 29 #include "chrome/browser/ui/browser_window.h"
31 #include "chrome/browser/ui/extensions/shell_window.h"
32 #include "chrome/browser/ui/omnibox/location_bar.h" 30 #include "chrome/browser/ui/omnibox/location_bar.h"
33 #include "chrome/browser/ui/tabs/tab_strip_model.h" 31 #include "chrome/browser/ui/tabs/tab_strip_model.h"
34 #include "chrome/common/chrome_notification_types.h" 32 #include "chrome/common/chrome_notification_types.h"
35 #include "chrome/common/chrome_paths.h" 33 #include "chrome/common/chrome_paths.h"
36 #include "chrome/common/chrome_switches.h" 34 #include "chrome/common/chrome_switches.h"
37 #include "chrome/common/chrome_version_info.h" 35 #include "chrome/common/chrome_version_info.h"
38 #include "chrome/test/base/ui_test_utils.h" 36 #include "chrome/test/base/ui_test_utils.h"
39 #include "content/public/browser/navigation_controller.h" 37 #include "content/public/browser/navigation_controller.h"
40 #include "content/public/browser/navigation_entry.h" 38 #include "content/public/browser/navigation_entry.h"
41 #include "content/public/browser/notification_registrar.h" 39 #include "content/public/browser/notification_registrar.h"
42 #include "content/public/browser/notification_service.h" 40 #include "content/public/browser/notification_service.h"
43 #include "content/public/browser/render_view_host.h" 41 #include "content/public/browser/render_view_host.h"
44 #include "content/public/test/browser_test_utils.h" 42 #include "content/public/test/browser_test_utils.h"
45 #include "sync/api/string_ordinal.h" 43 #include "sync/api/string_ordinal.h"
46 44
47 using extensions::Extension; 45 using extensions::Extension;
48 using extensions::ExtensionCreator; 46 using extensions::ExtensionCreator;
49 using extensions::FeatureSwitch; 47 using extensions::FeatureSwitch;
50 using extensions::ShellWindowRegistry;
51 48
52 ExtensionBrowserTest::ExtensionBrowserTest() 49 ExtensionBrowserTest::ExtensionBrowserTest()
53 : loaded_(false), 50 : loaded_(false),
54 installed_(false), 51 installed_(false),
55 extension_installs_observed_(0), 52 extension_installs_observed_(0),
56 extension_load_errors_observed_(0), 53 extension_load_errors_observed_(0),
57 target_page_action_count_(-1), 54 target_page_action_count_(-1),
58 target_visible_page_action_count_(-1), 55 target_visible_page_action_count_(-1),
59 current_channel_(chrome::VersionInfo::CHANNEL_DEV), 56 current_channel_(chrome::VersionInfo::CHANNEL_DEV),
60 override_prompt_for_external_extensions_( 57 override_prompt_for_external_extensions_(
(...skipping 11 matching lines...) Expand all
72 69
73 #if defined(OS_CHROMEOS) 70 #if defined(OS_CHROMEOS)
74 // This makes sure that we create the Default profile first, with no 71 // This makes sure that we create the Default profile first, with no
75 // ExtensionService and then the real profile with one, as we do when 72 // ExtensionService and then the real profile with one, as we do when
76 // running on chromeos. 73 // running on chromeos.
77 command_line->AppendSwitchASCII(switches::kLoginUser, 74 command_line->AppendSwitchASCII(switches::kLoginUser,
78 "TestUser@gmail.com"); 75 "TestUser@gmail.com");
79 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); 76 command_line->AppendSwitchASCII(switches::kLoginProfile, "user");
80 command_line->AppendSwitch(switches::kNoFirstRun); 77 command_line->AppendSwitch(switches::kNoFirstRun);
81 #endif 78 #endif
82
83 // Make event pages get suspended quicker.
84 command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "1");
85 command_line->AppendSwitchASCII(switches::kEventPageUnloadingTime, "1");
86 } 79 }
87 80
88 const Extension* ExtensionBrowserTest::LoadExtensionWithFlags( 81 const Extension* ExtensionBrowserTest::LoadExtensionWithFlags(
89 const FilePath& path, int flags) { 82 const FilePath& path, int flags) {
90 ExtensionService* service = browser()->profile()->GetExtensionService(); 83 ExtensionService* service = browser()->profile()->GetExtensionService();
91 { 84 {
92 content::NotificationRegistrar registrar; 85 content::NotificationRegistrar registrar;
93 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 86 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
94 content::NotificationService::AllSources()); 87 content::NotificationService::AllSources());
95 scoped_refptr<extensions::UnpackedInstaller> installer( 88 scoped_refptr<extensions::UnpackedInstaller> installer(
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 529 }
537 530
538 bool ExtensionBrowserTest::WaitForCrxInstallerDone() { 531 bool ExtensionBrowserTest::WaitForCrxInstallerDone() {
539 int before = crx_installers_done_observed_; 532 int before = crx_installers_done_observed_;
540 ui_test_utils::RegisterAndWait(this, 533 ui_test_utils::RegisterAndWait(this,
541 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 534 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
542 content::NotificationService::AllSources()); 535 content::NotificationService::AllSources());
543 return crx_installers_done_observed_ == (before + 1); 536 return crx_installers_done_observed_ == (before + 1);
544 } 537 }
545 538
546 void ExtensionBrowserTest::CloseShellWindow(ShellWindow* window) {
547 content::WindowedNotificationObserver destroyed_observer(
548 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
549 content::NotificationService::AllSources());
550 window->GetBaseWindow()->Close();
551 destroyed_observer.Wait();
552 }
553
554 void ExtensionBrowserTest::CloseShellWindowsAndWaitForAppToExit() {
555 content::WindowedNotificationObserver destroyed_observer(
556 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
557 content::NotificationService::AllSources());
558
559 // Close all the windows.
560 ShellWindowRegistry* app_registry =
561 ShellWindowRegistry::Get(browser()->profile());
562 ShellWindowRegistry::const_iterator iter;
563 ShellWindowRegistry::ShellWindowSet shell_windows =
564 app_registry->shell_windows();
565 for (iter = shell_windows.begin(); iter != shell_windows.end(); ++iter)
566 CloseShellWindow(*iter);
567
568 // Now wait for the lazy background page of the platform app to be unloaded.
569 destroyed_observer.Wait();
570 }
571
572 void ExtensionBrowserTest::OpenWindow(content::WebContents* contents, 539 void ExtensionBrowserTest::OpenWindow(content::WebContents* contents,
573 const GURL& url, 540 const GURL& url,
574 bool newtab_process_should_equal_opener, 541 bool newtab_process_should_equal_opener,
575 content::WebContents** newtab_result) { 542 content::WebContents** newtab_result) {
576 content::WindowedNotificationObserver observer( 543 content::WindowedNotificationObserver observer(
577 content::NOTIFICATION_LOAD_STOP, 544 content::NOTIFICATION_LOAD_STOP,
578 content::NotificationService::AllSources()); 545 content::NotificationService::AllSources());
579 ASSERT_TRUE(content::ExecuteJavaScript( 546 ASSERT_TRUE(content::ExecuteJavaScript(
580 contents->GetRenderViewHost(), L"", 547 contents->GetRenderViewHost(), L"",
581 L"window.open('" + UTF8ToWide(url.spec()) + L"');")); 548 L"window.open('" + UTF8ToWide(url.spec()) + L"');"));
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 case content::NOTIFICATION_LOAD_STOP: 681 case content::NOTIFICATION_LOAD_STOP:
715 VLOG(1) << "Got LOAD_STOP notification."; 682 VLOG(1) << "Got LOAD_STOP notification.";
716 MessageLoopForUI::current()->Quit(); 683 MessageLoopForUI::current()->Quit();
717 break; 684 break;
718 685
719 default: 686 default:
720 NOTREACHED(); 687 NOTREACHED();
721 break; 688 break;
722 } 689 }
723 } 690 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_browsertest.h ('k') | chrome/browser/extensions/extension_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698