forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented skeleton of new first-run overlay UI.
UI can be enabled by 'enable-first-run-ui' flag. Currently only one example step will be shown right after login. BUG=269286 TBR=jochen,nkostylev Review URL: https://chromiumcodereview.appspot.com/23604021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220877 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
dzhioev@chromium.org
committed
Sep 2, 2013
1 parent
a471f65
commit 798edb2
Showing
30 changed files
with
895 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dzhioev@chromium.org |
106 changes: 106 additions & 0 deletions
106
chrome/browser/chromeos/first_run/first_run_controller.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// Copyright 2013 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/chromeos/first_run/first_run_controller.h" | ||
|
||
#include "ash/launcher/launcher.h" | ||
#include "ash/shell.h" | ||
#include "ash/shell_window_ids.h" | ||
#include "base/logging.h" | ||
#include "base/message_loop/message_loop.h" | ||
#include "chrome/browser/chromeos/first_run/first_run_view.h" | ||
#include "chrome/browser/profiles/profile_manager.h" | ||
#include "ui/views/widget/widget.h" | ||
|
||
namespace { | ||
|
||
gfx::Rect GetScreenBounds() { | ||
return ash::Shell::GetScreen()->GetPrimaryDisplay().bounds(); | ||
} | ||
|
||
views::Widget* CreateFirstRunWindow() { | ||
views::Widget::InitParams params( | ||
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | ||
params.bounds = GetScreenBounds(); | ||
params.show_state = ui::SHOW_STATE_FULLSCREEN; | ||
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | ||
params.parent = | ||
ash::Shell::GetContainer( | ||
ash::Shell::GetPrimaryRootWindow(), | ||
ash::internal::kShellWindowId_OverlayContainer); | ||
views::Widget* window = new views::Widget; | ||
window->Init(params); | ||
return window; | ||
} | ||
|
||
// We can't get launcher size now in normal way. This workaround uses fact that | ||
// AppList button is the rightmost button in Launcher. | ||
gfx::Rect GetLauncherBounds() { | ||
ash::Launcher* launcher = ash::Launcher::ForPrimaryDisplay(); | ||
views::View* app_button = launcher->GetAppListButtonView(); | ||
gfx::Rect bounds = app_button->GetBoundsInScreen(); | ||
return gfx::Rect(0, bounds.y(), bounds.right(), bounds.height()); | ||
} | ||
|
||
} // anonymous namespace | ||
|
||
namespace chromeos { | ||
|
||
FirstRunController::FirstRunController() | ||
: window_(NULL), | ||
actor_(NULL) { | ||
} | ||
|
||
FirstRunController::~FirstRunController() { | ||
if (window_) | ||
Stop(); | ||
} | ||
|
||
void FirstRunController::Start() { | ||
if (window_) | ||
return; | ||
window_ = CreateFirstRunWindow(); | ||
FirstRunView* view = new FirstRunView(); | ||
view->Init(ProfileManager::GetDefaultProfile()); | ||
window_->SetContentsView(view); | ||
actor_ = view->GetActor(); | ||
actor_->set_delegate(this); | ||
if (actor_->IsInitialized()) | ||
OnActorInitialized(); | ||
} | ||
|
||
void FirstRunController::Stop() { | ||
window_->Close(); | ||
window_ = NULL; | ||
if (actor_) | ||
actor_->set_delegate(NULL); | ||
actor_ = NULL; | ||
} | ||
|
||
void FirstRunController::OnActorInitialized() { | ||
window_->Show(); | ||
gfx::Rect launcher_bounds = GetLauncherBounds(); | ||
actor_->AddBackgroundHole(launcher_bounds.x(), | ||
launcher_bounds.y(), | ||
launcher_bounds.width(), | ||
launcher_bounds.height()); | ||
actor_->ShowStep("first-step", | ||
FirstRunActor::StepPosition() | ||
.SetLeft(0) | ||
.SetBottom( | ||
GetScreenBounds().height() - launcher_bounds.y())); | ||
} | ||
|
||
void FirstRunController::OnNextButtonClicked(const std::string& step_name) { | ||
CHECK(step_name == "first-step"); | ||
Stop(); | ||
base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | ||
} | ||
|
||
void FirstRunController::OnActorDestroyed() { | ||
actor_ = NULL; | ||
} | ||
|
||
} // namespace chromeos | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2013 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_BROWSER_CHROMEOS_FIRST_RUN_FIRST_RUN_CONTROLLER_H_ | ||
#define CHROME_BROWSER_CHROMEOS_FIRST_RUN_FIRST_RUN_CONTROLLER_H_ | ||
|
||
#include <string> | ||
|
||
#include "base/basictypes.h" | ||
#include "base/compiler_specific.h" | ||
#include "chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h" | ||
|
||
namespace views { | ||
class Widget; | ||
} | ||
|
||
namespace chromeos { | ||
|
||
// FirstRunController creates and manages first-run tutorial. | ||
// Object manages its lifetime and deletes itself after completion of the | ||
// tutorial. | ||
class FirstRunController : public FirstRunActor::Delegate { | ||
public: | ||
FirstRunController(); | ||
virtual ~FirstRunController(); | ||
|
||
// Creates first-run UI and starts tutorial. | ||
void Start(); | ||
|
||
// Finalizes first-run tutorial and destroys UI. | ||
void Stop(); | ||
|
||
private: | ||
// Overriden from FirstRunActor::Delegate. | ||
virtual void OnActorInitialized() OVERRIDE; | ||
virtual void OnNextButtonClicked(const std::string& step_name) OVERRIDE; | ||
virtual void OnActorDestroyed() OVERRIDE; | ||
|
||
// Window with UI. FirstRunController closes window after tutorial completes. | ||
views::Widget* window_; | ||
// The object providing interface to UI layer. It's not directly owned by | ||
// FirstRunController. | ||
FirstRunActor* actor_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(FirstRunController); | ||
}; | ||
|
||
} // namespace chromeos | ||
|
||
#endif // CHROME_BROWSER_CHROMEOS_FIRST_RUN_FIRST_RUN_CONTROLLER_H_ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2013 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/chromeos/first_run/first_run_view.h" | ||
|
||
#include "chrome/browser/ui/webui/chromeos/first_run/first_run_ui.h" | ||
#include "chrome/common/url_constants.h" | ||
#include "content/public/browser/render_view_host.h" | ||
#include "content/public/browser/render_widget_host_view.h" | ||
#include "content/public/browser/web_contents.h" | ||
#include "third_party/skia/include/core/SkBitmap.h" | ||
#include "ui/views/controls/webview/webview.h" | ||
#include "url/gurl.h" | ||
|
||
namespace chromeos { | ||
|
||
FirstRunView::FirstRunView() | ||
: web_view_(NULL) { | ||
} | ||
|
||
void FirstRunView::Init(content::BrowserContext* context) { | ||
web_view_ = new views::WebView(context); | ||
AddChildView(web_view_); | ||
web_view_->LoadInitialURL(GURL(chrome::kChromeUIFirstRunURL)); | ||
web_view_->RequestFocus(); | ||
|
||
web_view_->web_contents()->SetDelegate(this); | ||
|
||
SkBitmap background; | ||
background.setConfig(SkBitmap::kA8_Config, 1, 1); | ||
background.allocPixels(); | ||
background.eraseARGB(0, 0, 0, 0); | ||
web_view_->web_contents()->GetRenderViewHost()->GetView()-> | ||
SetBackground(background); | ||
} | ||
|
||
FirstRunActor* FirstRunView::GetActor() { | ||
return static_cast<FirstRunUI*>( | ||
web_view_->web_contents()->GetWebUI()->GetController())->get_actor(); | ||
} | ||
|
||
void FirstRunView::Layout() { | ||
web_view_->SetBoundsRect(bounds()); | ||
} | ||
|
||
bool FirstRunView::HandleContextMenu( | ||
const content::ContextMenuParams& params) { | ||
// Discards context menu. | ||
return true; | ||
} | ||
|
||
} // namespace chromeos | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2013 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_BROWSER_CHROMEOS_FIRST_RUN_FIRST_RUN_VIEW_H_ | ||
#define CHROME_BROWSER_CHROMEOS_FIRST_RUN_FIRST_RUN_VIEW_H_ | ||
|
||
#include "base/basictypes.h" | ||
#include "base/compiler_specific.h" | ||
#include "content/public/browser/web_contents_delegate.h" | ||
#include "ui/views/view.h" | ||
|
||
class Profile; | ||
|
||
namespace content { | ||
class BrowserContext; | ||
} | ||
|
||
namespace views { | ||
class WebView; | ||
} | ||
|
||
namespace chromeos { | ||
|
||
class FirstRunActor; | ||
|
||
// WebUI view used for first run tutorial. | ||
class FirstRunView : public views::View, | ||
public content::WebContentsDelegate { | ||
public: | ||
FirstRunView(); | ||
void Init(content::BrowserContext* context); | ||
FirstRunActor* GetActor(); | ||
private: | ||
// Overriden from views::View. | ||
virtual void Layout() OVERRIDE; | ||
|
||
// Overriden from content::WebContentsDelegate. | ||
virtual bool HandleContextMenu( | ||
const content::ContextMenuParams& params) OVERRIDE; | ||
|
||
views::WebView* web_view_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(FirstRunView); | ||
}; | ||
|
||
} // namespace chromeos | ||
|
||
#endif // CHROME_BROWSER_CHROMEOS_FIRST_RUN_FIRST_RUN_VIEW_H_ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dzhioev@chromium.org |
18 changes: 18 additions & 0 deletions
18
chrome/browser/resources/chromeos/first_run/background.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright 2013 The Chromium Authors. All rights reserved. | ||
* Use of this source code is governed by a BSD-style license that can be | ||
* found in the LICENSE file. | ||
*/ | ||
|
||
html, | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
body { | ||
background-color: rgba(0, 0, 0, 0); | ||
cursor: default; | ||
height: 100%; | ||
width: 100%; | ||
} | ||
|
||
#background { | ||
height: 100%; | ||
left: 0; | ||
position: absolute; | ||
top: 0; | ||
width: 100%; | ||
z-index: -1; | ||
} | ||
|
||
#background .fill { | ||
fill: rgba(0, 0, 0, 0.7); | ||
} |
19 changes: 19 additions & 0 deletions
19
chrome/browser/resources/chromeos/first_run/first_run.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset=utf-8> | ||
<title></title> | ||
<link rel="stylesheet" href="chrome://resources/css/widgets.css"> | ||
<link rel="stylesheet" href="first_run.css"> | ||
<link rel="stylesheet" href="step.css"> | ||
<script src="chrome://resources/js/util.js"></script> | ||
<script src="chrome://resources/js/cr.js"></script> | ||
<script src="chrome://resources/js/cr/ui.js"></script> | ||
<script src="chrome://first-run/first_run.js"></script> | ||
</head> | ||
<body> | ||
<include src="background.svg"> | ||
<include src="first_step.html"> | ||
</body> | ||
</html> | ||
|
Oops, something went wrong.