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

Side by Side Diff: chrome/browser/chromeos/login/existing_user_controller.cc

Issue 10313002: Merge 134293 - [cros] Open getting started guide in app window. Add support for new GSG URL. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1084/src/
Patch Set: Created 8 years, 7 months 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
« no previous file with comments | « chrome/browser/chromeos/login/existing_user_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/chromeos/login/existing_user_controller.h" 5 #include "chrome/browser/chromeos/login/existing_user_controller.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 14 matching lines...) Expand all
25 #include "chrome/browser/chromeos/customization_document.h" 25 #include "chrome/browser/chromeos/customization_document.h"
26 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" 26 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
27 #include "chrome/browser/chromeos/dbus/session_manager_client.h" 27 #include "chrome/browser/chromeos/dbus/session_manager_client.h"
28 #include "chrome/browser/chromeos/login/helper.h" 28 #include "chrome/browser/chromeos/login/helper.h"
29 #include "chrome/browser/chromeos/login/login_display_host.h" 29 #include "chrome/browser/chromeos/login/login_display_host.h"
30 #include "chrome/browser/chromeos/login/login_utils.h" 30 #include "chrome/browser/chromeos/login/login_utils.h"
31 #include "chrome/browser/chromeos/login/user_manager.h" 31 #include "chrome/browser/chromeos/login/user_manager.h"
32 #include "chrome/browser/chromeos/login/wizard_controller.h" 32 #include "chrome/browser/chromeos/login/wizard_controller.h"
33 #include "chrome/browser/chromeos/system/statistics_provider.h" 33 #include "chrome/browser/chromeos/system/statistics_provider.h"
34 #include "chrome/browser/google/google_util.h" 34 #include "chrome/browser/google/google_util.h"
35 #include "chrome/browser/net/browser_url_util.h"
35 #include "chrome/browser/policy/browser_policy_connector.h" 36 #include "chrome/browser/policy/browser_policy_connector.h"
36 #include "chrome/browser/prefs/pref_service.h" 37 #include "chrome/browser/prefs/pref_service.h"
37 #include "chrome/browser/prefs/session_startup_pref.h" 38 #include "chrome/browser/prefs/session_startup_pref.h"
38 #include "chrome/browser/profiles/profile_manager.h" 39 #include "chrome/browser/profiles/profile_manager.h"
39 #include "chrome/browser/ui/dialog_style.h" 40 #include "chrome/browser/ui/dialog_style.h"
40 #include "chrome/browser/ui/views/window.h" 41 #include "chrome/browser/ui/views/window.h"
41 #include "chrome/common/chrome_notification_types.h" 42 #include "chrome/common/chrome_notification_types.h"
42 #include "chrome/common/chrome_switches.h" 43 #include "chrome/common/chrome_switches.h"
43 #include "chrome/common/net/gaia/google_service_auth_error.h" 44 #include "chrome/common/net/gaia/google_service_auth_error.h"
44 #include "chrome/common/pref_names.h" 45 #include "chrome/common/pref_names.h"
45 #include "content/public/browser/browser_thread.h" 46 #include "content/public/browser/browser_thread.h"
46 #include "content/public/browser/notification_service.h" 47 #include "content/public/browser/notification_service.h"
47 #include "content/public/browser/notification_types.h" 48 #include "content/public/browser/notification_types.h"
48 #include "grit/generated_resources.h" 49 #include "grit/generated_resources.h"
49 #include "net/http/http_auth_cache.h" 50 #include "net/http/http_auth_cache.h"
50 #include "net/http/http_network_session.h" 51 #include "net/http/http_network_session.h"
51 #include "net/http/http_transaction_factory.h" 52 #include "net/http/http_transaction_factory.h"
52 #include "net/url_request/url_request_context.h" 53 #include "net/url_request/url_request_context.h"
53 #include "net/url_request/url_request_context_getter.h" 54 #include "net/url_request/url_request_context_getter.h"
54 #include "ui/base/l10n/l10n_util.h" 55 #include "ui/base/l10n/l10n_util.h"
55 #include "ui/views/widget/widget.h" 56 #include "ui/views/widget/widget.h"
56 57
57 namespace chromeos { 58 namespace chromeos {
58 59
59 namespace { 60 namespace {
60 61
61 // Url for setting up sync authentication. 62 // Url for setting up sync authentication.
62 const char kSettingsSyncLoginURL[] = "chrome://settings/personal"; 63 const char kSettingsSyncLoginURL[] = "chrome://settings/personal";
63 64
64 // URL that will be opened when user logs in first time on the device. 65 // Getting started guide URL, will be opened as in app window for each new
66 // user who logs on the device.
67 // TODO(nkostylev): Remove this when new URL is live.
68 #if defined(NEW_GSG_URL)
69 const char kGetStartedURLPattern[] =
70 "http://gweb-gettingstartedguide.appspot.com/";
71 #else
65 const char kGetStartedURLPattern[] = 72 const char kGetStartedURLPattern[] =
66 "http://www.gstatic.com/chromebook/gettingstarted/index-%s.html"; 73 "http://www.gstatic.com/chromebook/gettingstarted/index-%s.html";
67 74 #endif
68 // Divider that starts parameters in URL.
69 const char kGetStartedParamsStartMark[] = "#";
70 75
71 // Parameter to be added to GetStarted URL that contains board. 76 // Parameter to be added to GetStarted URL that contains board.
72 const char kGetStartedBoardParam[] = "board=%s"; 77 const char kGetStartedBoardParam[] = "board";
73 78
74 // Parameter to be added to GetStarted URL 79 // Parameter to be added to GetStarted URL
75 // when first user signs in for the first time. 80 // when first user signs in for the first time (OOBE case).
76 // TODO(nkostylev): Uncomment once server side supports new param format. 81 #if defined(NEW_GSG_URL)
77 // const char kGetStartedOwnerParam[] = "/first"; 82 const char kGetStartedOwnerParam[] = "owner";
78 const char kGetStartedOwnerParam[] = "first"; 83 const char kGetStartedOwnerParamValue[] = "true";
84 #else
85 const char kGetStartedOwnerParam[] = "#first";
86 #endif
79 87
80 // URL for account creation. 88 // URL for account creation.
81 const char kCreateAccountURL[] = 89 const char kCreateAccountURL[] =
82 "https://www.google.com/accounts/NewAccount?service=mail"; 90 "https://www.google.com/accounts/NewAccount?service=mail";
83 91
84 // ChromeVox tutorial URL (used in place of "getting started" url when 92 // ChromeVox tutorial URL (used in place of "getting started" url when
85 // accessibility is enabled). 93 // accessibility is enabled).
86 const char kChromeVoxTutorialURLPattern[] = 94 const char kChromeVoxTutorialURLPattern[] =
87 "http://www.chromevox.com/tutorial/index.html?lang=%s"; 95 "http://www.chromevox.com/tutorial/index.html?lang=%s";
88 96
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 } 687 }
680 host_->StartWizard(screen_name, params); 688 host_->StartWizard(screen_name, params);
681 } 689 }
682 690
683 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { 691 gfx::NativeWindow ExistingUserController::GetNativeWindow() const {
684 return host_->GetNativeWindow(); 692 return host_->GetNativeWindow();
685 } 693 }
686 694
687 void ExistingUserController::InitializeStartUrls() const { 695 void ExistingUserController::InitializeStartUrls() const {
688 std::vector<std::string> start_urls; 696 std::vector<std::string> start_urls;
697 // Guide URL is not added to start URLs as it should be passed as an app.
698 std::string guide_url;
699
689 PrefService* prefs = g_browser_process->local_state(); 700 PrefService* prefs = g_browser_process->local_state();
690 const std::string current_locale =
691 StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale));
692 std::string start_url;
693 const base::ListValue *urls; 701 const base::ListValue *urls;
694 if (UserManager::Get()->IsLoggedInAsDemoUser() && 702 if (UserManager::Get()->IsLoggedInAsDemoUser() &&
695 CrosSettings::Get()->GetList(kStartUpUrls, &urls)) { 703 CrosSettings::Get()->GetList(kStartUpUrls, &urls)) {
696 // the demo user will get its start urls from the special policy if it is 704 // the demo user will get its start urls from the special policy if it is
697 // set. 705 // set.
698 for (base::ListValue::const_iterator it = urls->begin(); 706 for (base::ListValue::const_iterator it = urls->begin();
699 it != urls->end(); ++it) { 707 it != urls->end(); ++it) {
700 std::string url; 708 std::string url;
701 if ((*it)->GetAsString(&url)) 709 if ((*it)->GetAsString(&url))
702 start_urls.push_back(url); 710 start_urls.push_back(url);
703 } 711 }
704 } else { 712 } else {
705 if (prefs->GetBoolean(prefs::kSpokenFeedbackEnabled)) { 713 if (prefs->GetBoolean(prefs::kSpokenFeedbackEnabled)) {
706 const char* url = kChromeVoxTutorialURLPattern; 714 const char* url = kChromeVoxTutorialURLPattern;
707 start_url = base::StringPrintf(url, current_locale.c_str()); 715 const std::string current_locale =
716 StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale));
717 std::string vox_url = base::StringPrintf(url, current_locale.c_str());
718 start_urls.push_back(vox_url);
708 } else { 719 } else {
709 const char* url = kGetStartedURLPattern; 720 guide_url = GetGettingStartedGuideURL();
710 start_url = base::StringPrintf(url, current_locale.c_str());
711 std::string params_str;
712 #if 0
713 const char kMachineInfoBoard[] = "CHROMEOS_RELEASE_BOARD";
714 std::string board;
715 system::StatisticsProvider* provider =
716 system::StatisticsProvider::GetInstance();
717 if (!provider->GetMachineStatistic(kMachineInfoBoard, &board))
718 LOG(ERROR) << "Failed to get board information";
719 if (!board.empty()) {
720 params_str.append(base::StringPrintf(kGetStartedBoardParam,
721 board.c_str()));
722 }
723 #endif
724 if (is_owner_login_)
725 params_str.append(kGetStartedOwnerParam);
726 if (!params_str.empty()) {
727 params_str.insert(0, kGetStartedParamsStartMark);
728 start_url.append(params_str);
729 }
730 } 721 }
731 start_urls.push_back(start_url);
732 } 722 }
733 723
734 ServicesCustomizationDocument* customization = 724 ServicesCustomizationDocument* customization =
735 ServicesCustomizationDocument::GetInstance(); 725 ServicesCustomizationDocument::GetInstance();
736 if (!ServicesCustomizationDocument::WasApplied() && 726 if (!ServicesCustomizationDocument::WasApplied() &&
737 customization->IsReady()) { 727 customization->IsReady()) {
738 std::string locale = g_browser_process->GetApplicationLocale(); 728 // Since we don't use OEM start URL anymore, just mark as applied.
739 std::string initial_start_page =
740 customization->GetInitialStartPage(locale);
741 if (!initial_start_page.empty())
742 start_urls.push_back(initial_start_page);
743 customization->ApplyCustomization(); 729 customization->ApplyCustomization();
744 } 730 }
745 731
746 for (size_t i = 0; i < start_urls.size(); ++i) 732 if (!guide_url.empty()) {
747 CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]); 733 CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kApp,
734 guide_url);
735 } else {
736 // We should not be adding any start URLs if guide
737 // is defined as it launches as a standalone app window.
738 for (size_t i = 0; i < start_urls.size(); ++i)
739 CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]);
740 }
748 } 741 }
749 742
750 void ExistingUserController::SetStatusAreaEnabled(bool enable) { 743 void ExistingUserController::SetStatusAreaEnabled(bool enable) {
751 if (!host_) 744 if (!host_)
752 return; 745 return;
753 host_->SetStatusAreaEnabled(enable); 746 host_->SetStatusAreaEnabled(enable);
754 } 747 }
755 748
749 #if defined(NEW_GSG_URL)
750 std::string ExistingUserController::GetGettingStartedGuideURL() const {
751 GURL guide_url(kGetStartedURLPattern);
752 std::string board;
753 const char kMachineInfoBoard[] = "CHROMEOS_RELEASE_BOARD";
754 system::StatisticsProvider* provider =
755 system::StatisticsProvider::GetInstance();
756 if (!provider->GetMachineStatistic(kMachineInfoBoard, &board))
757 LOG(ERROR) << "Failed to get board information";
758 if (!board.empty()) {
759 guide_url = chrome_browser_net::AppendQueryParameter(guide_url,
760 kGetStartedBoardParam,
761 board);
762 }
763 if (is_owner_login_) {
764 guide_url = chrome_browser_net::AppendQueryParameter(
765 guide_url,
766 kGetStartedOwnerParam,
767 kGetStartedOwnerParamValue);
768 }
769 guide_url = google_util::AppendGoogleLocaleParam(guide_url);
770 return guide_url.spec();
771 }
772 #else
773 std::string ExistingUserController::GetGettingStartedGuideURL() const {
774 const char* url = kGetStartedURLPattern;
775 PrefService* prefs = g_browser_process->local_state();
776 const std::string current_locale =
777 StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale));
778 std::string guide_url = base::StringPrintf(url, current_locale.c_str());
779 if (is_owner_login_)
780 guide_url.append(kGetStartedOwnerParam);
781 return guide_url;
782 }
783 #endif
784
756 void ExistingUserController::ShowError(int error_id, 785 void ExistingUserController::ShowError(int error_id,
757 const std::string& details) { 786 const std::string& details) {
758 // TODO(dpolukhin): show detailed error info. |details| string contains 787 // TODO(dpolukhin): show detailed error info. |details| string contains
759 // low level error info that is not localized and even is not user friendly. 788 // low level error info that is not localized and even is not user friendly.
760 // For now just ignore it because error_text contains all required information 789 // For now just ignore it because error_text contains all required information
761 // for end users, developers can see details string in Chrome logs. 790 // for end users, developers can see details string in Chrome logs.
762 VLOG(1) << details; 791 VLOG(1) << details;
763 HelpAppLauncher::HelpTopic help_topic_id; 792 HelpAppLauncher::HelpTopic help_topic_id;
764 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); 793 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary();
765 bool is_offline = !network_library || !network_library->Connected(); 794 bool is_offline = !network_library || !network_library->Connected();
(...skipping 23 matching lines...) Expand all
789 // changed. 818 // changed.
790 UserManager::Get()->SaveUserOAuthStatus(username, 819 UserManager::Get()->SaveUserOAuthStatus(username,
791 User::OAUTH_TOKEN_STATUS_INVALID); 820 User::OAUTH_TOKEN_STATUS_INVALID);
792 821
793 login_display_->SetUIEnabled(true); 822 login_display_->SetUIEnabled(true);
794 SetStatusAreaEnabled(true); 823 SetStatusAreaEnabled(true);
795 login_display_->ShowGaiaPasswordChanged(username); 824 login_display_->ShowGaiaPasswordChanged(username);
796 } 825 }
797 826
798 } // namespace chromeos 827 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/existing_user_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698