diff options
author | jwd@chromium.org <jwd@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-17 04:33:40 +0000 |
---|---|---|
committer | jwd@chromium.org <jwd@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-17 04:33:40 +0000 |
commit | 4251165a510cacb88fd7ab028d3e902fcbf78195 (patch) | |
tree | 16b63403919ce96e7ca2cb2605a56416082d9f46 | |
parent | ca2704c8bb6f89adf2fd5686aba000700247b603 (diff) | |
download | chromium_src-4251165a510cacb88fd7ab028d3e902fcbf78195.zip chromium_src-4251165a510cacb88fd7ab028d3e902fcbf78195.tar.gz chromium_src-4251165a510cacb88fd7ab028d3e902fcbf78195.tar.bz2 |
Adding a first prototype of guest mode.
This currently doesn't support the guest contract (fresh profile each session). That will come in a future CL.
Screenshot of UI available at https://docs.google.com/file/d/0B2G_JZ2jrki9VFdQem1GRkp2RWM/edit?usp=sharing
BUG=103846
TEST=Launch chrome with the flag enable-desktop-guest-mode. The avatar menu should be shown even when there is only one profile, there should be a guest link in the menu and it should launch a new window with no avatar menu. Launching that window will also cause a directory called "Guest Profile" to be created in the user data dir.
Review URL: https://chromiumcodereview.appspot.com/11877033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211931 0039d316-1c4b-4281-b951-d872f2087c98
30 files changed, 117 insertions, 59 deletions
diff --git a/android_webview/browser/aw_browser_context.cc b/android_webview/browser/aw_browser_context.cc index 43411c6..7c94d79 100644 --- a/android_webview/browser/aw_browser_context.cc +++ b/android_webview/browser/aw_browser_context.cc @@ -157,7 +157,7 @@ void AwBrowserContext::CreateUserPrefServiceIfNecessary() { pref_service_builder.Create(pref_registry)); } -base::FilePath AwBrowserContext::GetPath() { +base::FilePath AwBrowserContext::GetPath() const { return context_storage_path_; } diff --git a/android_webview/browser/aw_browser_context.h b/android_webview/browser/aw_browser_context.h index 33aa409..8d1ff97 100644 --- a/android_webview/browser/aw_browser_context.h +++ b/android_webview/browser/aw_browser_context.h @@ -75,7 +75,7 @@ class AwBrowserContext : public content::BrowserContext, void CreateUserPrefServiceIfNecessary(); // content::BrowserContext implementation. - virtual base::FilePath GetPath() OVERRIDE; + virtual base::FilePath GetPath() const OVERRIDE; virtual bool IsOffTheRecord() const OVERRIDE; virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess( diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 87e5814..fa61ffd 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -11963,6 +11963,9 @@ Would you like to start <ph name="CONTROL_PANEL_APPLET_NAME">$1<ex>Add/Remove Pr <message name="IDS_PROFILES_PROFILE_USERS_BUTTON" desc="Button in the avatar menu bubble view for switching users."> Users </message> + <message name="IDS_PROFILES_GUEST_PROFILE_NAME" desc="Name of the guest profile."> + Guest + </message> <message name="IDS_PROFILES_PROFILE_GUEST_BUTTON" desc="Button in the avatar menu bubble view for guest browsing."> Guest browsing </message> diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index fd0c851..823d2a5 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -1035,13 +1035,6 @@ const Experiment kExperiments[] = { SINGLE_VALUE_TYPE(chromeos::switches::kEnableTouchpadThreeFingerClick) }, #endif - { - "enable-desktop-guest-mode", - IDS_FLAGS_DESKTOP_GUEST_MODE_NAME, - IDS_FLAGS_DESKTOP_GUEST_MODE_DESCRIPTION, - kOsMac | kOsWin | kOsLinux, - SINGLE_VALUE_TYPE(switches::kEnableDesktopGuestMode) - }, #if defined(USE_ASH) { "show-launcher-alignment-menu", diff --git a/chrome/browser/profiles/avatar_menu_model.cc b/chrome/browser/profiles/avatar_menu_model.cc index f05dd2f..4a86e7f 100644 --- a/chrome/browser/profiles/avatar_menu_model.cc +++ b/chrome/browser/profiles/avatar_menu_model.cc @@ -192,6 +192,18 @@ base::FilePath AvatarMenuModel::GetProfilePath(size_t index) { return profile_info_->GetPathOfProfileAtIndex(item.model_index); } +// static +void AvatarMenuModel::SwitchToGuestProfileWindow(Browser* browser) { + ProfileManager* profile_manager = g_browser_process->profile_manager(); + profile_manager->CreateProfileAsync(ProfileManager::GetGuestProfilePath(), + base::Bind(&OnProfileCreated, + false, + browser->host_desktop_type()), + string16(), + string16(), + false); +} + size_t AvatarMenuModel::GetNumberOfItems() { return items_.size(); } @@ -272,9 +284,12 @@ bool AvatarMenuModel::ShouldShowAvatarMenu() { DCHECK(ProfileManager::IsMultipleProfilesEnabled()); return true; } - return ProfileManager::IsMultipleProfilesEnabled() && - g_browser_process->profile_manager() && - g_browser_process->profile_manager()->GetNumberOfProfiles() > 1; + if (ProfileManager::IsMultipleProfilesEnabled()) { + return ProfileManager::IsNewProfileManagementEnabled() || + (g_browser_process->profile_manager() && + g_browser_process->profile_manager()->GetNumberOfProfiles() > 1); + } + return false; } void AvatarMenuModel::RebuildMenu() { diff --git a/chrome/browser/profiles/avatar_menu_model.h b/chrome/browser/profiles/avatar_menu_model.h index 0ab6818..95668b4 100644 --- a/chrome/browser/profiles/avatar_menu_model.h +++ b/chrome/browser/profiles/avatar_menu_model.h @@ -74,6 +74,8 @@ class AvatarMenuModel : public content::NotificationObserver { void EditProfile(size_t index); // Creates a new profile. void AddNewProfile(ProfileMetrics::ProfileAdd type); + // Creates a new guest user window. + static void SwitchToGuestProfileWindow(Browser* browser); // Gets the path associated with the profile at |index|. base::FilePath GetProfilePath(size_t index); diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc index 52fda4c..cf95b53 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.cc +++ b/chrome/browser/profiles/off_the_record_profile_impl.cc @@ -189,7 +189,7 @@ std::string OffTheRecordProfileImpl::GetProfileName() { return std::string(); } -base::FilePath OffTheRecordProfileImpl::GetPath() { +base::FilePath OffTheRecordProfileImpl::GetPath() const { return profile_->GetPath(); } diff --git a/chrome/browser/profiles/off_the_record_profile_impl.h b/chrome/browser/profiles/off_the_record_profile_impl.h index 1a7b946..6559269c 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.h +++ b/chrome/browser/profiles/off_the_record_profile_impl.h @@ -83,7 +83,7 @@ class OffTheRecordProfileImpl : public Profile { virtual GURL GetHomePage() OVERRIDE; // content::BrowserContext implementation: - virtual base::FilePath GetPath() OVERRIDE; + virtual base::FilePath GetPath() const OVERRIDE; virtual scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() OVERRIDE; virtual bool IsOffTheRecord() const OVERRIDE; virtual content::DownloadManagerDelegate* diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc index cea0f90..93415c7 100644 --- a/chrome/browser/profiles/profile.cc +++ b/chrome/browser/profiles/profile.cc @@ -10,6 +10,7 @@ #include "build/build_config.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/first_run/first_run.h" +#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/sync_prefs.h" @@ -168,7 +169,7 @@ bool Profile::IsGuestSession() const { chromeos::switches::kGuestSession); return is_guest_session; #else - return false; + return GetPath() == ProfileManager::GetGuestProfilePath(); #endif } diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h index 61ef0ca..19a232a9 100644 --- a/chrome/browser/profiles/profile.h +++ b/chrome/browser/profiles/profile.h @@ -325,7 +325,7 @@ class Profile : public content::BrowserContext { std::string GetDebugName(); // Returns whether it is a guest session. - bool IsGuestSession() const; + virtual bool IsGuestSession() const; // Did the user restore the last session? This is set by SessionRestore. void set_restored_last_session(bool restored_last_session) { diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index 5bf3a34..d363656a 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -663,7 +663,7 @@ std::string ProfileImpl::GetProfileName() { return GetPrefs()->GetString(prefs::kGoogleServicesUsername); } -base::FilePath ProfileImpl::GetPath() { +base::FilePath ProfileImpl::GetPath() const { return path_; } diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h index d7520a7..d2c7396 100644 --- a/chrome/browser/profiles/profile_impl.h +++ b/chrome/browser/profiles/profile_impl.h @@ -61,7 +61,7 @@ class ProfileImpl : public Profile { static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); // content::BrowserContext implementation: - virtual base::FilePath GetPath() OVERRIDE; + virtual base::FilePath GetPath() const OVERRIDE; virtual content::DownloadManagerDelegate* GetDownloadManagerDelegate() OVERRIDE; virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc index 6811e87..d0079b7 100644 --- a/chrome/browser/profiles/profile_manager.cc +++ b/chrome/browser/profiles/profile_manager.cc @@ -929,6 +929,16 @@ base::FilePath ProfileManager::CreateMultiProfileAsync( } // static +base::FilePath ProfileManager::GetGuestProfilePath() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + + ProfileManager* profile_manager = g_browser_process->profile_manager(); + + base::FilePath guest_path = profile_manager->user_data_dir(); + return guest_path.Append(chrome::kGuestProfileDir); +} + +// static void ProfileManager::RegisterPrefs(PrefRegistrySimple* registry) { registry->RegisterStringPref(prefs::kProfileLastUsed, std::string()); registry->RegisterIntegerPref(prefs::kProfilesNumCreated, 1); @@ -965,6 +975,8 @@ ProfileShortcutManager* ProfileManager::profile_shortcut_manager() { } void ProfileManager::AddProfileToCache(Profile* profile) { + if (profile->IsGuestSession()) + return; ProfileInfoCache& cache = GetProfileInfoCache(); if (profile->GetPath().DirName() != cache.GetUserDataDir()) return; @@ -998,25 +1010,30 @@ void ProfileManager::InitProfileUserPrefs(Profile* profile) { if (profile->GetPath().DirName() != cache.GetUserDataDir()) return; + bool is_managed = false; size_t avatar_index; std::string profile_name; - bool is_managed = false; - size_t profile_cache_index = - cache.GetIndexOfProfileWithPath(profile->GetPath()); - // If the cache has an entry for this profile, use the cache data. - if (profile_cache_index != std::string::npos) { - avatar_index = - cache.GetAvatarIconIndexOfProfileAtIndex(profile_cache_index); - profile_name = - UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_cache_index)); - is_managed = cache.ProfileIsManagedAtIndex(profile_cache_index); - } else if (profile->GetPath() == - GetDefaultProfileDir(cache.GetUserDataDir())) { + if (profile->IsGuestSession()) { + profile_name = l10n_util::GetStringUTF8(IDS_PROFILES_GUEST_PROFILE_NAME); avatar_index = 0; - profile_name = l10n_util::GetStringUTF8(IDS_DEFAULT_PROFILE_NAME); } else { - avatar_index = cache.ChooseAvatarIconIndexForNewProfile(); - profile_name = UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)); + size_t profile_cache_index = + cache.GetIndexOfProfileWithPath(profile->GetPath()); + // If the cache has an entry for this profile, use the cache data. + if (profile_cache_index != std::string::npos) { + avatar_index = + cache.GetAvatarIconIndexOfProfileAtIndex(profile_cache_index); + profile_name = + UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_cache_index)); + is_managed = cache.ProfileIsManagedAtIndex(profile_cache_index); + } else if (profile->GetPath() == + GetDefaultProfileDir(cache.GetUserDataDir())) { + avatar_index = 0; + profile_name = l10n_util::GetStringUTF8(IDS_DEFAULT_PROFILE_NAME); + } else { + avatar_index = cache.ChooseAvatarIconIndexForNewProfile(); + profile_name = UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)); + } } if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileAvatarIndex)) @@ -1164,6 +1181,12 @@ bool ProfileManager::IsMultipleProfilesEnabled() { return true; } +// static +bool ProfileManager::IsNewProfileManagementEnabled() { + return CommandLine::ForCurrentProcess()->HasSwitch( + switches::kNewProfileManagement); +} + void ProfileManager::AutoloadProfiles() { // If running in the background is disabled for the browser, do not autoload // any profiles. diff --git a/chrome/browser/profiles/profile_manager.h b/chrome/browser/profiles/profile_manager.h index 1b2ba42..c26bd56 100644 --- a/chrome/browser/profiles/profile_manager.h +++ b/chrome/browser/profiles/profile_manager.h @@ -202,6 +202,9 @@ class ProfileManager : public base::NonThreadSafe, const CreateCallback& callback, bool is_managed); + // Returns the full path to be used for guest profiles. + static base::FilePath GetGuestProfilePath(); + // Register multi-profile related preferences in Local State. static void RegisterPrefs(PrefRegistrySimple* registry); @@ -222,6 +225,9 @@ class ProfileManager : public base::NonThreadSafe, // Checks if multiple profiles is enabled. static bool IsMultipleProfilesEnabled(); + // Checks if new profile management is enabled. + static bool IsNewProfileManagementEnabled(); + // Autoloads profiles if they are running background apps. void AutoloadProfiles(); diff --git a/chrome/browser/profiles/profile_manager_unittest.cc b/chrome/browser/profiles/profile_manager_unittest.cc index 3ceedcb..86f9f57 100644 --- a/chrome/browser/profiles/profile_manager_unittest.cc +++ b/chrome/browser/profiles/profile_manager_unittest.cc @@ -302,6 +302,13 @@ TEST_F(ProfileManagerTest, CreateProfilesAsync) { message_loop_.RunUntilIdle(); } +TEST_F(ProfileManagerTest, GetGuestProfilePath) { + base::FilePath guest_path = ProfileManager::GetGuestProfilePath(); + base::FilePath expected_path = temp_dir_.path(); + expected_path = expected_path.Append(chrome::kGuestProfileDir); + EXPECT_EQ(expected_path, guest_path); +} + TEST_F(ProfileManagerTest, AutoloadProfilesWithBackgroundApps) { ProfileManager* profile_manager = g_browser_process->profile_manager(); ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); diff --git a/chrome/browser/ui/views/avatar_menu_button.cc b/chrome/browser/ui/views/avatar_menu_button.cc index 1dc46f1..323d2e1 100644 --- a/chrome/browser/ui/views/avatar_menu_button.cc +++ b/chrome/browser/ui/views/avatar_menu_button.cc @@ -8,15 +8,14 @@ #include "base/prefs/pref_service.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/command_updater.h" #include "chrome/browser/profiles/avatar_menu_model.h" #include "chrome/browser/profiles/profile_info_util.h" +#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_metrics.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/profile_chooser_view.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "content/public/browser/notification_service.h" #include "ui/gfx/canvas.h" @@ -97,8 +96,7 @@ void AvatarMenuButton::ShowAvatarBubble() { gfx::Point origin; views::View::ConvertPointToScreen(this, &origin); gfx::Rect bounds(origin, size()); - if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kNewProfileManagement)) { + if (ProfileManager::IsNewProfileManagementEnabled()) { ProfileChooserView::ShowBubble( this, views::BubbleBorder::TOP_LEFT, views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, bounds, browser_); diff --git a/chrome/browser/ui/views/profile_chooser_view.cc b/chrome/browser/ui/views/profile_chooser_view.cc index 0c16b40..280853f 100644 --- a/chrome/browser/ui/views/profile_chooser_view.cc +++ b/chrome/browser/ui/views/profile_chooser_view.cc @@ -66,7 +66,7 @@ ProfileChooserView::ProfileChooserView( : BubbleDelegateView(anchor_view, arrow), browser_(browser), current_profile_view_(NULL), - option_buttons_view_(NULL), + guest_button_view_(NULL), other_profiles_view_(NULL), signout_current_profile_view_(NULL) { avatar_menu_model_.reset(new AvatarMenuModel( @@ -105,13 +105,18 @@ void ProfileChooserView::OnMouseReleased(const ui::MouseEvent& event) { void ProfileChooserView::ButtonPressed(views::Button* sender, const ui::Event& event) { - DCHECK(sender == signout_current_profile_view_); // Disable button after clicking so that it doesn't get clicked twice and - // start a second sign-out procedure... which will crash Chrome. But don't - // disable if it has no parent (like in tests) because that will also - // crash. + // start a second action... which can crash Chrome. But don't disable if it + // has no parent (like in tests) because that will also crash. if (sender->parent()) sender->SetEnabled(false); + + if (sender == guest_button_view_) { + avatar_menu_model_->SwitchToGuestProfileWindow(browser_); + return; + } + + DCHECK_EQ(sender, signout_current_profile_view_); avatar_menu_model_->BeginSignOut(); } @@ -120,8 +125,8 @@ void ProfileChooserView::OnAvatarMenuModelChanged( // Unset all our child view references and call RemoveAllChildViews() which // will actually delete them. current_profile_view_ = NULL; + guest_button_view_ = NULL; open_other_profile_indexes_map_.clear(); - option_buttons_view_ = NULL; other_profiles_view_ = NULL; signout_current_profile_view_ = NULL; RemoveAllChildViews(true); @@ -160,10 +165,10 @@ void ProfileChooserView::OnAvatarMenuModelChanged( layout->StartRow(0, 0); layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); - option_buttons_view_ = CreateOptionsView(); - option_buttons_view_->SetSize(current_profile_view_->GetPreferredSize()); + views::View* option_buttons_view = CreateOptionsView(); + option_buttons_view->SetSize(current_profile_view_->GetPreferredSize()); layout->StartRow(0, 0); - layout->AddView(option_buttons_view_); + layout->AddView(option_buttons_view); layout->StartRow(0, 0); layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); @@ -301,6 +306,9 @@ views::View* ProfileChooserView::CreateOptionsView() { guest_button->SetHorizontalAlignment(gfx::ALIGN_CENTER); guest_button->set_tag(IDS_PROFILES_PROFILE_GUEST_BUTTON); + DCHECK(!guest_button_view_); + guest_button_view_ = guest_button; + views::GridLayout* layout = new views::GridLayout(view); view->SetLayoutManager(layout); diff --git a/chrome/browser/ui/views/profile_chooser_view.h b/chrome/browser/ui/views/profile_chooser_view.h index fe8f1a1..e2de425 100644 --- a/chrome/browser/ui/views/profile_chooser_view.h +++ b/chrome/browser/ui/views/profile_chooser_view.h @@ -77,8 +77,8 @@ class ProfileChooserView : public views::BubbleDelegateView, scoped_ptr<AvatarMenuModel> avatar_menu_model_; Browser* browser_; views::View* current_profile_view_; + views::View* guest_button_view_; ViewIndexes open_other_profile_indexes_map_; - views::View* option_buttons_view_; views::View* other_profiles_view_; views::View* signout_current_profile_view_; diff --git a/chrome/common/chrome_constants.cc b/chrome/common/chrome_constants.cc index a5dda14..f6960d0 100644 --- a/chrome/common/chrome_constants.cc +++ b/chrome/common/chrome_constants.cc @@ -142,6 +142,7 @@ const wchar_t kCrashReportLog[] = L"Reported Crashes.txt"; const wchar_t kTestingInterfaceDLL[] = L"testing_interface.dll"; const char kInitialProfile[] = "Default"; const char kMultiProfileDirPrefix[] = "Profile "; +const base::FilePath::CharType kGuestProfileDir[] = FPL("Guest Profile"); const wchar_t kBrowserResourcesDll[] = L"chrome.dll"; const base::FilePath::CharType kExtensionFileExtension[] = FPL(".crx"); const base::FilePath::CharType kExtensionKeyFileExtension[] = FPL(".pem"); diff --git a/chrome/common/chrome_constants.h b/chrome/common/chrome_constants.h index 04d6073..03d57ba 100644 --- a/chrome/common/chrome_constants.h +++ b/chrome/common/chrome_constants.h @@ -44,6 +44,7 @@ extern const wchar_t kCrashReportLog[]; extern const wchar_t kTestingInterfaceDLL[]; extern const char kInitialProfile[]; extern const char kMultiProfileDirPrefix[]; +extern const base::FilePath::CharType kGuestProfileDir[]; extern const wchar_t kBrowserResourcesDll[]; extern const base::FilePath::CharType kExtensionFileExtension[]; extern const base::FilePath::CharType kExtensionKeyFileExtension[]; diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 02128fb..39b868d 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -523,9 +523,6 @@ const char kEnableComponentCloudPolicy[] = "enable-component-cloud-policy"; // Chrome OS apps list. const char kEnableContacts[] = "enable-contacts"; -// Enables desktop guest mode. -const char kEnableDesktopGuestMode[] = "enable-desktop-guest-mode"; - // Enables device discovery. const char kEnableDeviceDiscovery[] = "enable-device-discovery"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index c2fdba5..9911c4f 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -153,7 +153,6 @@ extern const char kEnableBetterPopupBlocking[]; extern const char kEnableCloudPrintProxy[]; extern const char kEnableComponentCloudPolicy[]; extern const char kEnableContacts[]; -extern const char kEnableDesktopGuestMode[]; extern const char kEnableDeviceDiscovery[]; extern const char kEnableDevToolsExperiments[]; extern const char kEnableExperimentalExtensionApis[]; diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc index c2cc6fa..4536bce 100644 --- a/chrome/test/base/testing_profile.cc +++ b/chrome/test/base/testing_profile.cc @@ -482,7 +482,7 @@ void TestingProfile::BlockUntilTopSitesLoaded() { top_sites_loaded_observer.Wait(); } -base::FilePath TestingProfile::GetPath() { +base::FilePath TestingProfile::GetPath() const { return profile_path_; } @@ -774,6 +774,9 @@ bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) { return true; } +bool TestingProfile::IsGuestSession() const { + return false; +} Profile::ExitType TestingProfile::GetLastSessionExitType() { return last_session_exited_cleanly_ ? EXIT_NORMAL : EXIT_CRASHED; } diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h index c4feca2..916bc33 100644 --- a/chrome/test/base/testing_profile.h +++ b/chrome/test/base/testing_profile.h @@ -169,7 +169,7 @@ class TestingProfile : public Profile { TestingPrefServiceSyncable* GetTestingPrefService(); // content::BrowserContext - virtual base::FilePath GetPath() OVERRIDE; + virtual base::FilePath GetPath() const OVERRIDE; virtual scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() OVERRIDE; virtual bool IsOffTheRecord() const OVERRIDE; virtual content::DownloadManagerDelegate* @@ -258,6 +258,7 @@ class TestingProfile : public Profile { virtual base::FilePath last_selected_directory() OVERRIDE; virtual void set_last_selected_directory(const base::FilePath& path) OVERRIDE; virtual bool WasCreatedByVersionOrLater(const std::string& version) OVERRIDE; + virtual bool IsGuestSession() const OVERRIDE; virtual void SetExitType(ExitType exit_type) OVERRIDE {} virtual ExitType GetLastSessionExitType() OVERRIDE; #if defined(OS_CHROMEOS) diff --git a/content/browser/download/download_manager_impl_unittest.cc b/content/browser/download/download_manager_impl_unittest.cc index 099696f..cbba7a3 100644 --- a/content/browser/download/download_manager_impl_unittest.cc +++ b/content/browser/download/download_manager_impl_unittest.cc @@ -385,7 +385,7 @@ class MockBrowserContext : public BrowserContext { MockBrowserContext() {} ~MockBrowserContext() {} - MOCK_METHOD0(GetPath, base::FilePath()); + MOCK_CONST_METHOD0(GetPath, base::FilePath()); MOCK_CONST_METHOD0(IsOffTheRecord, bool()); MOCK_METHOD0(GetRequestContext, net::URLRequestContextGetter*()); MOCK_METHOD1(GetRequestContextForRenderProcess, diff --git a/content/public/browser/browser_context.h b/content/public/browser/browser_context.h index c7b916f..cbac82f 100644 --- a/content/public/browser/browser_context.h +++ b/content/public/browser/browser_context.h @@ -93,7 +93,7 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData { virtual ~BrowserContext(); // Returns the path of the directory where this context's data is stored. - virtual base::FilePath GetPath() = 0; + virtual base::FilePath GetPath() const = 0; // Return whether this context is incognito. Default is false. virtual bool IsOffTheRecord() const = 0; diff --git a/content/public/test/test_browser_context.cc b/content/public/test/test_browser_context.cc index 3e909c2..ae2fcff 100644 --- a/content/public/test/test_browser_context.cc +++ b/content/public/test/test_browser_context.cc @@ -57,7 +57,7 @@ void TestBrowserContext::SetSpecialStoragePolicy( special_storage_policy_ = policy; } -base::FilePath TestBrowserContext::GetPath() { +base::FilePath TestBrowserContext::GetPath() const { return browser_context_dir_.path(); } diff --git a/content/public/test/test_browser_context.h b/content/public/test/test_browser_context.h index e877059..4799180 100644 --- a/content/public/test/test_browser_context.h +++ b/content/public/test/test_browser_context.h @@ -27,7 +27,7 @@ class TestBrowserContext : public BrowserContext { void SetSpecialStoragePolicy(quota::SpecialStoragePolicy* policy); - virtual base::FilePath GetPath() OVERRIDE; + virtual base::FilePath GetPath() const OVERRIDE; virtual bool IsOffTheRecord() const OVERRIDE; virtual DownloadManagerDelegate* GetDownloadManagerDelegate() OVERRIDE; virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc index 8d3dc3b..281862f 100644 --- a/content/shell/shell_browser_context.cc +++ b/content/shell/shell_browser_context.cc @@ -104,7 +104,7 @@ void ShellBrowserContext::InitWhileIOAllowed() { file_util::CreateDirectory(path_); } -base::FilePath ShellBrowserContext::GetPath() { +base::FilePath ShellBrowserContext::GetPath() const { return path_; } diff --git a/content/shell/shell_browser_context.h b/content/shell/shell_browser_context.h index 5176b0b..640f237 100644 --- a/content/shell/shell_browser_context.h +++ b/content/shell/shell_browser_context.h @@ -30,7 +30,7 @@ class ShellBrowserContext : public BrowserContext { virtual ~ShellBrowserContext(); // BrowserContext implementation. - virtual base::FilePath GetPath() OVERRIDE; + virtual base::FilePath GetPath() const OVERRIDE; virtual bool IsOffTheRecord() const OVERRIDE; virtual DownloadManagerDelegate* GetDownloadManagerDelegate() OVERRIDE; virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; |