forked from chromium/chromium
-
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.
Move note taking related methods out of PaletteDelegate
Create ash::NoteTakingController and have chromeos::NoteTakingHelper communicate with it over mojo. Bug: 773698 Test: ash_unittests --gtest_filter=CreateNoteTest.* Change-Id: Ib41e9adc0d95624c450097c48d1c0779ed8ee763 Reviewed-on: https://chromium-review.googlesource.com/713195 Reviewed-by: James Cook <jamescook@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Jacob Dufault <jdufault@chromium.org> Commit-Queue: Vladislav Kaznacheev <kaznacheev@chromium.org> Cr-Commit-Position: refs/heads/master@{#508837}
- Loading branch information
1 parent
63ef7ef
commit 92edf62
Showing
23 changed files
with
359 additions
and
61 deletions.
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
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,45 @@ | ||
// Copyright 2017 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 "ash/note_taking_controller.h" | ||
|
||
namespace ash { | ||
|
||
NoteTakingController::NoteTakingController() : binding_(this) {} | ||
|
||
NoteTakingController::~NoteTakingController() = default; | ||
|
||
void NoteTakingController::BindRequest( | ||
mojom::NoteTakingControllerRequest request) { | ||
binding_.Bind(std::move(request)); | ||
} | ||
|
||
void NoteTakingController::SetClient( | ||
mojom::NoteTakingControllerClientPtr client) { | ||
DCHECK(!client_); | ||
client_ = std::move(client); | ||
client_.set_connection_error_handler(base::Bind( | ||
&NoteTakingController::OnClientConnectionLost, base::Unretained(this))); | ||
} | ||
|
||
bool NoteTakingController::CanCreateNote() const { | ||
return static_cast<bool>(client_); | ||
} | ||
|
||
void NoteTakingController::CreateNote() { | ||
DCHECK(client_); | ||
client_->CreateNote(); | ||
} | ||
|
||
void NoteTakingController::OnClientConnectionLost() { | ||
client_.reset(); | ||
binding_.Close(); | ||
} | ||
|
||
void NoteTakingController::FlushMojoForTesting() { | ||
if (client_) | ||
client_.FlushForTesting(); | ||
} | ||
|
||
} // namespace ash |
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,49 @@ | ||
// Copyright 2017 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 ASH_NOTETAKING_CONTROLLER_H_ | ||
#define ASH_NOTETAKING_CONTROLLER_H_ | ||
|
||
#include "ash/ash_export.h" | ||
#include "ash/public/interfaces/note_taking_controller.mojom.h" | ||
#include "mojo/public/cpp/bindings/binding.h" | ||
|
||
namespace ash { | ||
|
||
// Controller for the note taking functionality. | ||
class ASH_EXPORT NoteTakingController : public mojom::NoteTakingController { | ||
public: | ||
NoteTakingController(); | ||
~NoteTakingController() override; | ||
|
||
void BindRequest(mojom::NoteTakingControllerRequest request); | ||
|
||
// mojom::NoteTakingController: | ||
void SetClient(mojom::NoteTakingControllerClientPtr client) override; | ||
|
||
// Returns true if the client is attached. | ||
bool CanCreateNote() const; | ||
|
||
// Calls the method of the same name on |client_|. | ||
void CreateNote(); | ||
|
||
private: | ||
friend class TestNoteTakingControllerClient; | ||
|
||
void OnClientConnectionLost(); | ||
|
||
void FlushMojoForTesting(); | ||
|
||
// Binding for mojom::NoteTakingController interface. | ||
mojo::Binding<ash::mojom::NoteTakingController> binding_; | ||
|
||
// Interface to NoteTaking controller client (chrome). | ||
mojom::NoteTakingControllerClientPtr client_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(NoteTakingController); | ||
}; | ||
|
||
} // namespace ash | ||
|
||
#endif // ASH_NOTETAKING_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
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,19 @@ | ||
// Copyright 2017 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. | ||
|
||
module ash.mojom; | ||
|
||
// Interface for ash client (e.g. Chrome) to connect to the note taking | ||
// controller. | ||
interface NoteTakingController { | ||
// Sets the client interface. | ||
SetClient(NoteTakingControllerClient client); | ||
}; | ||
|
||
// Interface for ash to notify the client (e.g. Chrome) about the new note | ||
// creation. | ||
interface NoteTakingControllerClient { | ||
// Called when the controller needs to create a new note. | ||
CreateNote(); | ||
}; |
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
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
Oops, something went wrong.