summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordzhioev@chromium.org <dzhioev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-20 04:53:05 +0000
committerdzhioev@chromium.org <dzhioev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-20 04:53:05 +0000
commitfe708773c2c0ad00ab5c23c0ad9266a7f3a43593 (patch)
tree3d8ceb582d05818c5d5402a8c02d9c9969979e43
parentd1838364026ff62ca07323b79a45f2695cefedb7 (diff)
downloadchromium_src-fe708773c2c0ad00ab5c23c0ad9266a7f3a43593.zip
chromium_src-fe708773c2c0ad00ab5c23c0ad9266a7f3a43593.tar.gz
chromium_src-fe708773c2c0ad00ab5c23c0ad9266a7f3a43593.tar.bz2
Some improvements for first-run UI.
"Keep Exploring" button opens help app. Close button closes dialog. Added static methods to start and stop tutorial. BUG=319945, 269286 Review URL: https://codereview.chromium.org/76513002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236154 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/chromeos_strings.grdp2
-rw-r--r--chrome/browser/chromeos/first_run/first_run_controller.cc64
-rw-r--r--chrome/browser/chromeos/first_run/first_run_controller.h16
-rw-r--r--chrome/browser/chromeos/login/fake_user_manager.cc5
-rw-r--r--chrome/browser/chromeos/login/fake_user_manager.h1
-rw-r--r--chrome/browser/chromeos/login/login_display_host_impl.cc2
-rw-r--r--chrome/browser/chromeos/login/mock_user_manager.h1
-rw-r--r--chrome/browser/chromeos/login/user_manager.h3
-rw-r--r--chrome/browser/chromeos/login/user_manager_impl.cc12
-rw-r--r--chrome/browser/chromeos/login/user_manager_impl.h3
-rw-r--r--chrome/browser/resources/chromeos/first_run/help_step.html2
-rw-r--r--chrome/browser/resources/chromeos/first_run/step.js29
-rw-r--r--chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h6
-rw-r--r--chrome/browser/ui/webui/chromeos/first_run/first_run_handler.cc16
-rw-r--r--chrome/browser/ui/webui/chromeos/first_run/first_run_handler.h2
15 files changed, 135 insertions, 29 deletions
diff --git a/chrome/app/chromeos_strings.grdp b/chrome/app/chromeos_strings.grdp
index adda767..58ecd20 100644
--- a/chrome/app/chromeos_strings.grdp
+++ b/chrome/app/chromeos_strings.grdp
@@ -3868,7 +3868,7 @@ Battery full
Enjoy your Chromebook. Question? You can always get help by clicking the "?" in the Status tray.
</message>
<message name="IDS_FIRST_RUN_HELP_STEP_TEXT_2" desc="Second part of text shown on the first-run tutorial bubble pointing to help button in system tray. Part of the phrase &quot;Want to discover more awesome features? It's just one click away.&quot;">
- Want to discover more awsome features?
+ Want to discover more awesome features?
</message>
<message name="IDS_FIRST_RUN_HELP_STEP_TEXT_3" desc="Third part of text shown on the first-run tutorial bubble pointing to help button in system tray. Part of the phrase &quot;Want to discover more awesome features? It's just one click away.&quot;">
It's just one click away.
diff --git a/chrome/browser/chromeos/first_run/first_run_controller.cc b/chrome/browser/chromeos/first_run/first_run_controller.cc
index 120d841..4b6f341 100644
--- a/chrome/browser/chromeos/first_run/first_run_controller.cc
+++ b/chrome/browser/chromeos/first_run/first_run_controller.cc
@@ -13,31 +13,59 @@
#include "chrome/browser/chromeos/first_run/steps/greeting_step.h"
#include "chrome/browser/chromeos/first_run/steps/help_step.h"
#include "chrome/browser/chromeos/first_run/steps/tray_step.h"
-#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/chromeos/login/user_manager.h"
+#include "chrome/browser/ui/chrome_pages.h"
#include "ui/views/widget/widget.h"
namespace {
size_t NONE_STEP_INDEX = std::numeric_limits<size_t>::max();
+// Instance of currently running controller, or NULL if controller is not
+// running now.
+chromeos::FirstRunController* g_instance;
+
} // namespace
namespace chromeos {
+FirstRunController::~FirstRunController() {}
+
+// static
+void FirstRunController::Start() {
+ if (g_instance) {
+ LOG(WARNING) << "First-run tutorial is running already.";
+ return;
+ }
+ g_instance = new FirstRunController();
+ g_instance->Init();
+}
+
+// static
+void FirstRunController::Stop() {
+ if (!g_instance) {
+ LOG(WARNING) << "First-run tutorial is not running.";
+ return;
+ }
+ g_instance->Finalize();
+ base::MessageLoop::current()->DeleteSoon(FROM_HERE, g_instance);
+ g_instance = NULL;
+}
+
FirstRunController::FirstRunController()
: actor_(NULL),
- current_step_index_(NONE_STEP_INDEX) {
+ current_step_index_(NONE_STEP_INDEX),
+ user_profile_(NULL) {
}
-FirstRunController::~FirstRunController() {
- if (shell_helper_.get())
- Stop();
-}
+void FirstRunController::Init() {
+ UserManager* user_manager = UserManager::Get();
+ user_profile_ = user_manager->GetProfileByUser(user_manager->GetActiveUser());
-void FirstRunController::Start() {
shell_helper_.reset(ash::Shell::GetInstance()->CreateFirstRunHelper());
+
FirstRunView* view = new FirstRunView();
- view->Init(ProfileManager::GetDefaultProfile());
+ view->Init(user_profile_);
shell_helper_->GetOverlayWidget()->SetContentsView(view);
actor_ = view->GetActor();
actor_->set_delegate(this);
@@ -45,7 +73,7 @@ void FirstRunController::Start() {
OnActorInitialized();
}
-void FirstRunController::Stop() {
+void FirstRunController::Finalize() {
if (GetCurrentStep())
GetCurrentStep()->OnBeforeHide();
steps_.clear();
@@ -66,9 +94,23 @@ void FirstRunController::OnNextButtonClicked(const std::string& step_name) {
ShowNextStep();
}
+void FirstRunController::OnHelpButtonClicked() {
+ Stop();
+ chrome::ShowHelpForProfile(
+ user_profile_,
+ chrome::HOST_DESKTOP_TYPE_ASH,
+ chrome::HELP_SOURCE_MENU);
+}
+
+void FirstRunController::OnCloseButtonClicked() {
+ Stop();
+}
+
void FirstRunController::OnActorDestroyed() {
- // Called when overlay window was destroyed not by us.
- NOTIMPLEMENTED();
+ // Normally this shouldn't happen because we are implicitly controlling
+ // actor's lifetime.
+ NOTREACHED() <<
+ "FirstRunActor destroyed before FirstRunController::Finalize.";
}
void FirstRunController::RegisterSteps() {
diff --git a/chrome/browser/chromeos/first_run/first_run_controller.h b/chrome/browser/chromeos/first_run/first_run_controller.h
index bde71e2..989bb76 100644
--- a/chrome/browser/chromeos/first_run/first_run_controller.h
+++ b/chrome/browser/chromeos/first_run/first_run_controller.h
@@ -14,6 +14,8 @@
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h"
+class Profile;
+
namespace ash {
class FirstRunHelper;
}
@@ -31,19 +33,24 @@ class FirstRunController : public FirstRunActor::Delegate {
typedef std::vector<linked_ptr<first_run::Step> > Steps;
public:
- FirstRunController();
virtual ~FirstRunController();
// Creates first-run UI and starts tutorial.
- void Start();
+ static void Start();
// Finalizes first-run tutorial and destroys UI.
- void Stop();
+ static void Stop();
private:
+ FirstRunController();
+ void Init();
+ void Finalize();
+
// Overriden from FirstRunActor::Delegate.
virtual void OnActorInitialized() OVERRIDE;
virtual void OnNextButtonClicked(const std::string& step_name) OVERRIDE;
+ virtual void OnHelpButtonClicked() OVERRIDE;
+ virtual void OnCloseButtonClicked() OVERRIDE;
virtual void OnActorDestroyed() OVERRIDE;
void RegisterSteps();
@@ -64,6 +71,9 @@ class FirstRunController : public FirstRunActor::Delegate {
// Index of step that is currently shown.
size_t current_step_index_;
+ // Profile used for webui and help app.
+ Profile* user_profile_;
+
DISALLOW_COPY_AND_ASSIGN(FirstRunController);
};
diff --git a/chrome/browser/chromeos/login/fake_user_manager.cc b/chrome/browser/chromeos/login/fake_user_manager.cc
index 6c5925e..6d4d89e 100644
--- a/chrome/browser/chromeos/login/fake_user_manager.cc
+++ b/chrome/browser/chromeos/login/fake_user_manager.cc
@@ -177,6 +177,11 @@ User* FakeUserManager::GetUserByProfile(Profile* profile) const {
return primary_user_;
}
+Profile* FakeUserManager::GetProfileByUser(const User* user) const {
+ NOTIMPLEMENTED();
+ return NULL;
+}
+
string16 FakeUserManager::GetUserDisplayName(
const std::string& username) const {
return string16();
diff --git a/chrome/browser/chromeos/login/fake_user_manager.h b/chrome/browser/chromeos/login/fake_user_manager.h
index 8c987539..88927d4 100644
--- a/chrome/browser/chromeos/login/fake_user_manager.h
+++ b/chrome/browser/chromeos/login/fake_user_manager.h
@@ -69,6 +69,7 @@ class FakeUserManager : public UserManager {
virtual const User* GetLoggedInUser() const OVERRIDE;
virtual User* GetLoggedInUser() OVERRIDE;
virtual const User* GetPrimaryUser() const OVERRIDE;
+ virtual Profile* GetProfileByUser(const User* profile) const OVERRIDE;
virtual User* GetUserByProfile(Profile* profile) const OVERRIDE;
virtual void SaveUserOAuthStatus(
const std::string& username,
diff --git a/chrome/browser/chromeos/login/login_display_host_impl.cc b/chrome/browser/chromeos/login/login_display_host_impl.cc
index 173eebe..399788a 100644
--- a/chrome/browser/chromeos/login/login_display_host_impl.cc
+++ b/chrome/browser/chromeos/login/login_display_host_impl.cc
@@ -370,7 +370,7 @@ LoginDisplayHostImpl::~LoginDisplayHostImpl() {
chromeos::UserManager::Get()->IsCurrentUserNew()) {
// FirstRunController manages its lifetime and destructs after tutorial
// completion.
- (new FirstRunController())->Start();
+ FirstRunController::Start();
}
// TODO(tengs): This should be refactored together with the first run UI.
diff --git a/chrome/browser/chromeos/login/mock_user_manager.h b/chrome/browser/chromeos/login/mock_user_manager.h
index 94de587a..eec1f9d 100644
--- a/chrome/browser/chromeos/login/mock_user_manager.h
+++ b/chrome/browser/chromeos/login/mock_user_manager.h
@@ -41,6 +41,7 @@ class MockUserManager : public UserManager {
MOCK_METHOD1(FindUserAndModify, User*(const std::string&));
MOCK_METHOD2(SaveUserOAuthStatus, void(const std::string&,
User::OAuthTokenStatus));
+ MOCK_CONST_METHOD1(GetProfileByUser, Profile*(const User*));
MOCK_METHOD2(SaveUserDisplayName, void(const std::string&,
const string16&));
MOCK_METHOD3(UpdateUserAccountData,
diff --git a/chrome/browser/chromeos/login/user_manager.h b/chrome/browser/chromeos/login/user_manager.h
index 85b06c0..b71d2ac 100644
--- a/chrome/browser/chromeos/login/user_manager.h
+++ b/chrome/browser/chromeos/login/user_manager.h
@@ -198,6 +198,9 @@ class UserManager {
// Returns NULL if User is not created.
virtual User* GetUserByProfile(Profile* profile) const = 0;
+ /// Returns NULL if profile for user was not found.
+ virtual Profile* GetProfileByUser(const User* user) const = 0;
+
// Saves user's oauth token status in local state preferences.
virtual void SaveUserOAuthStatus(
const std::string& user_id,
diff --git a/chrome/browser/chromeos/login/user_manager_impl.cc b/chrome/browser/chromeos/login/user_manager_impl.cc
index 8978a81..2be23c2 100644
--- a/chrome/browser/chromeos/login/user_manager_impl.cc
+++ b/chrome/browser/chromeos/login/user_manager_impl.cc
@@ -593,6 +593,12 @@ User* UserManagerImpl::GetUserByProfile(Profile* profile) const {
return active_user_;
}
+Profile* UserManagerImpl::GetProfileByUser(const User* user) const {
+ if (IsMultipleProfilesAllowed())
+ return ProfileHelper::GetProfileByUserIdHash(user->username_hash());
+ return g_browser_process->profile_manager()->GetDefaultProfile();
+}
+
void UserManagerImpl::SaveUserOAuthStatus(
const std::string& user_id,
User::OAuthTokenStatus oauth_token_status) {
@@ -819,12 +825,6 @@ bool UserManagerImpl::RespectLocalePreference(
return true;
}
-Profile* UserManagerImpl::GetProfileByUser(const User* user) const {
- if (IsMultipleProfilesAllowed())
- return ProfileHelper::GetProfileByUserIdHash(user->username_hash());
- return g_browser_process->profile_manager()->GetDefaultProfile();
-}
-
void UserManagerImpl::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
diff --git a/chrome/browser/chromeos/login/user_manager_impl.h b/chrome/browser/chromeos/login/user_manager_impl.h
index f645e98..eee0b30 100644
--- a/chrome/browser/chromeos/login/user_manager_impl.h
+++ b/chrome/browser/chromeos/login/user_manager_impl.h
@@ -82,6 +82,7 @@ class UserManagerImpl
virtual User* GetActiveUser() OVERRIDE;
virtual const User* GetPrimaryUser() const OVERRIDE;
virtual User* GetUserByProfile(Profile* profile) const OVERRIDE;
+ virtual Profile* GetProfileByUser(const User* user) const OVERRIDE;
virtual void SaveUserOAuthStatus(
const std::string& user_id,
User::OAuthTokenStatus oauth_token_status) OVERRIDE;
@@ -316,8 +317,6 @@ class UserManagerImpl
void UpdateUserAccountDataImplCallbackDecorator(
const scoped_ptr<UpdateUserAccountDataCallbackData>& data);
- Profile* GetProfileByUser(const User* user) const;
-
// Implementation for RemoveUser method. This is an asynchronous part of the
// method, that verifies that owner will not get deleted, and calls
// |RemoveNonOwnerUserInternal|.
diff --git a/chrome/browser/resources/chromeos/first_run/help_step.html b/chrome/browser/resources/chromeos/first_run/help_step.html
index 743a291..e409632 100644
--- a/chrome/browser/resources/chromeos/first_run/help_step.html
+++ b/chrome/browser/resources/chromeos/first_run/help_step.html
@@ -8,7 +8,7 @@
</p>
<div class="controls">
<button i18n-content="helpKeepExploringButton"
- class="custom-appearance blue-button"></button>
+ class="help-button custom-appearance blue-button"></button>
<button i18n-content="helpFinishButton"
class="next-button custom-appearance white-button"></button>
</div>
diff --git a/chrome/browser/resources/chromeos/first_run/step.js b/chrome/browser/resources/chromeos/first_run/step.js
index 22f4c0c..56462c3 100644
--- a/chrome/browser/resources/chromeos/first_run/step.js
+++ b/chrome/browser/resources/chromeos/first_run/step.js
@@ -30,13 +30,17 @@ cr.define('cr.FirstRun', function() {
chrome.send('nextButtonClicked', [this.getName()]);
e.stopPropagation();
}).bind(this));
- // Make close unfocusable by mouse.
var topBar = this.getElementsByClassName('topbutton-bar')[0];
if (topBar) {
var closeButton = topBar.getElementsByClassName('close-button')[0];
if (closeButton) {
- closeButton.addEventListener('mousedown', function(event) {
- event.preventDefault();
+ // Make close unfocusable by mouse.
+ closeButton.addEventListener('mousedown', function(e) {
+ e.preventDefault();
+ });
+ closeButton.addEventListener('click', function(e) {
+ chrome.send('closeButtonClicked');
+ e.stopPropagation();
});
}
}
@@ -199,8 +203,25 @@ cr.define('cr.FirstRun', function() {
}
};
+ var HelpStep = cr.ui.define('div');
+
+ HelpStep.prototype = {
+ __proto__: Bubble.prototype,
+
+ decorate: function() {
+ Bubble.prototype.decorate.call(this);
+ var helpButton = this.getElementsByClassName('help-button')[0];
+ helpButton.addEventListener('click', function(e) {
+ chrome.send('helpButtonClicked');
+ e.stopPropagation();
+ });
+ },
+ };
+
var DecorateStep = function(el) {
- if (el.classList.contains('bubble'))
+ if (el.id == 'help')
+ HelpStep.decorate(el);
+ else if (el.classList.contains('bubble'))
Bubble.decorate(el);
else
Step.decorate(el);
diff --git a/chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h b/chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h
index 0793a2f..cb0efa3 100644
--- a/chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h
+++ b/chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h
@@ -27,6 +27,12 @@ class FirstRunActor {
// Called when user clicked "Next" button in step with name |step_name|.
virtual void OnNextButtonClicked(const std::string& step_name) = 0;
+ // Called when user clicked "Keep exploring" button.
+ virtual void OnHelpButtonClicked() = 0;
+
+ // Called when user clicked "X" button.
+ virtual void OnCloseButtonClicked() = 0;
+
// Notifies about about actor destruction.
virtual void OnActorDestroyed() = 0;
};
diff --git a/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.cc b/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.cc
index b4972088..64a8ed5 100644
--- a/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.cc
@@ -70,6 +70,12 @@ void FirstRunHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback("nextButtonClicked",
base::Bind(&FirstRunHandler::HandleNextButtonClicked,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback("helpButtonClicked",
+ base::Bind(&FirstRunHandler::HandleHelpButtonClicked,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback("closeButtonClicked",
+ base::Bind(&FirstRunHandler::HandleCloseButtonClicked,
+ base::Unretained(this)));
}
void FirstRunHandler::HandleInitialized(const base::ListValue* args) {
@@ -85,5 +91,15 @@ void FirstRunHandler::HandleNextButtonClicked(const base::ListValue* args) {
delegate()->OnNextButtonClicked(step_name);
}
+void FirstRunHandler::HandleHelpButtonClicked(const base::ListValue* args) {
+ if (delegate())
+ delegate()->OnHelpButtonClicked();
+}
+
+void FirstRunHandler::HandleCloseButtonClicked(const base::ListValue* args) {
+ if (delegate())
+ delegate()->OnCloseButtonClicked();
+}
+
} // namespace chromeos
diff --git a/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.h b/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.h
index 4bd026b7..b5c551b 100644
--- a/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.h
+++ b/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.h
@@ -39,6 +39,8 @@ class FirstRunHandler : public FirstRunActor,
// Handlers for calls from JS.
void HandleInitialized(const base::ListValue* args);
void HandleNextButtonClicked(const base::ListValue* args);
+ void HandleHelpButtonClicked(const base::ListValue* args);
+ void HandleCloseButtonClicked(const base::ListValue* args);
bool is_initialized_;